更新分享设备权限
This commit is contained in:
@@ -607,5 +607,6 @@
|
||||
"选择分数": "Select Score",
|
||||
"离床时长": "Bed Exit Duration",
|
||||
"已关闭": "Disabled",
|
||||
"时": " h"
|
||||
"时": " h",
|
||||
"允许对方配置wifi": "Allow other to configure WiFi"
|
||||
}
|
||||
@@ -607,5 +607,6 @@
|
||||
"选择分数": "选择分数",
|
||||
"离床时长": "离床时长",
|
||||
"已关闭": "已关闭",
|
||||
"时": "时"
|
||||
"时": "时",
|
||||
"允许对方配置wifi": "允许对方配置wifi"
|
||||
}
|
||||
@@ -603,5 +603,6 @@
|
||||
"选择分数": "選擇分數",
|
||||
"离床时长": "離床時長",
|
||||
"已关闭": "已關閉",
|
||||
"时": "時"
|
||||
"时": "時",
|
||||
"允许对方配置wifi": "允許對方設定wifi"
|
||||
}
|
||||
@@ -46,6 +46,7 @@ class DeviceShareController extends GetControllerEx<DeviceShareModel> {
|
||||
RxString account = "".obs;
|
||||
RxString msg = "".obs;
|
||||
RxInt code = 0.obs;
|
||||
RxInt type = 1.obs;//分享权限类型 1 wifi开 2 wifi关
|
||||
|
||||
Future<ApiResponse> getDeviceType() async {
|
||||
ApiResponse apiResponse = ApiResponse(code: -1, msg: "请求失败".tr);
|
||||
@@ -118,7 +119,12 @@ class DeviceShareController extends GetControllerEx<DeviceShareModel> {
|
||||
queryUrl += "?lang=$language";
|
||||
}
|
||||
}
|
||||
var data = {"type": 1, "userName": account.value, "mac": mac};
|
||||
var data = {
|
||||
"type": 1,
|
||||
"userName": account.value,
|
||||
"mac": mac,
|
||||
"opType": type.value,
|
||||
};
|
||||
var response =
|
||||
await EasyDartModule.dio.post(queryUrl, data: jsonEncode(data));
|
||||
if (response != null) {
|
||||
|
||||
@@ -203,9 +203,12 @@ class _BodyDevicePageState extends State<BodyDeviceWidget> {
|
||||
}
|
||||
|
||||
// 标签切换回调
|
||||
void _onTabChanged(int index) {
|
||||
Future<void> _onTabChanged(int index) async {
|
||||
_pageController.animateToPage(index,
|
||||
duration: const Duration(milliseconds: 300), curve: Curves.easeInOut);
|
||||
BodyDeviceController deviceController = Get.find();
|
||||
await deviceController.getDeviceList();
|
||||
await deviceController.getSleepReport();
|
||||
}
|
||||
|
||||
// 页面切换回调
|
||||
|
||||
@@ -106,8 +106,12 @@ class _DeviceDataComponentWidgetState extends State<DeviceDataComponentWidget> {
|
||||
// 计算弹窗需要的实际高度(估算)
|
||||
final estimatedItemHeight = 66.rpx; // 每个菜单项的估算高度
|
||||
//todo 更新菜单项,需要在此添加数量
|
||||
final itemCount =
|
||||
widget.device['bind_type'] == BindType.active.code ? 9 : 5;
|
||||
// final itemCount =
|
||||
// widget.device['bind_type'] == BindType.active.code ? 9 : 5;
|
||||
final itemCount = widget.device['bind_type'] == BindType.active.code
|
||||
? 9
|
||||
: (getWifiPermissionByOpType(widget.device) ? 6 : 5);
|
||||
|
||||
final estimatedPopupHeight =
|
||||
(itemCount * estimatedItemHeight) + 40.rpx; // 加上padding
|
||||
|
||||
@@ -288,9 +292,74 @@ class _DeviceDataComponentWidgetState extends State<DeviceDataComponentWidget> {
|
||||
),
|
||||
];
|
||||
|
||||
if (widget.device['bind_type'] == BindType.active.code &&
|
||||
!AppConstants.is_test_account) {
|
||||
items.addAll([
|
||||
// if ((widget.device['bind_type'] == BindType.active.code &&
|
||||
// !AppConstants.is_test_account) ||
|
||||
// (getWifiPermissionByOpType(widget.device))) {
|
||||
// items.addAll([
|
||||
// _buildMenuItem(
|
||||
// text: "WIFI配置".tr,
|
||||
// onTap: () {
|
||||
// setState(() {
|
||||
// _isPopupOpen = false;
|
||||
// });
|
||||
// _popupEntry?.remove();
|
||||
// _popupEntry = null;
|
||||
// dealWifi(widget.device);
|
||||
// },
|
||||
// ),
|
||||
// _buildMenuItem(
|
||||
// text: "设备校准".tr,
|
||||
// onTap: () async {
|
||||
// setState(() {
|
||||
// _isPopupOpen = false;
|
||||
// });
|
||||
// _popupEntry?.remove();
|
||||
// _popupEntry = null;
|
||||
// BlueteethBindController blueteethBindController = Get.find();
|
||||
// blueteethBindController.currentDeviceMac?.value =
|
||||
// widget.device['mac'];
|
||||
// await Get.toNamed("/calibrationPersonPage", arguments: 2);
|
||||
// },
|
||||
// ),
|
||||
// _buildMenuItem(
|
||||
// text: "分享设备".tr,
|
||||
// onTap: () {
|
||||
// setState(() {
|
||||
// _isPopupOpen = false;
|
||||
// });
|
||||
// _popupEntry?.remove();
|
||||
// _popupEntry = null;
|
||||
// Get.toNamed("/deviceSharePage", arguments: widget.device);
|
||||
// },
|
||||
// ),
|
||||
// _buildMenuItem(
|
||||
// text: "消息设置".tr,
|
||||
// onTap: () {
|
||||
// setState(() {
|
||||
// _isPopupOpen = false;
|
||||
// });
|
||||
// _popupEntry?.remove();
|
||||
// _popupEntry = null;
|
||||
// // Get.toNamed("/deviceDetail", arguments: widget.device);
|
||||
// Get.toNamed("/messageSettingPage", arguments: widget.device);
|
||||
// // TopSlideNotification.show(context, text: "待开发功能".tr);
|
||||
// },
|
||||
// ),
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// 是否有基础操作权限(除 WIFI 外)
|
||||
bool hasBasePermission =
|
||||
widget.device['bind_type'] == BindType.active.code &&
|
||||
!AppConstants.is_test_account;
|
||||
|
||||
// 是否有 WIFI 权限
|
||||
bool hasWifiPermission = getWifiPermissionByOpType(widget.device);
|
||||
|
||||
// WIFI 配置 —— 单独判断
|
||||
if (hasBasePermission || hasWifiPermission) {
|
||||
if (hasWifiPermission) {
|
||||
items.add(
|
||||
_buildMenuItem(
|
||||
text: "WIFI配置".tr,
|
||||
onTap: () {
|
||||
@@ -302,6 +371,12 @@ class _DeviceDataComponentWidgetState extends State<DeviceDataComponentWidget> {
|
||||
dealWifi(widget.device);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 下面这些 **只受 hasBasePermission 影响**
|
||||
if (hasBasePermission) {
|
||||
items.addAll([
|
||||
_buildMenuItem(
|
||||
text: "设备校准".tr,
|
||||
onTap: () async {
|
||||
@@ -335,13 +410,12 @@ class _DeviceDataComponentWidgetState extends State<DeviceDataComponentWidget> {
|
||||
});
|
||||
_popupEntry?.remove();
|
||||
_popupEntry = null;
|
||||
// Get.toNamed("/deviceDetail", arguments: widget.device);
|
||||
Get.toNamed("/messageSettingPage", arguments: widget.device);
|
||||
// TopSlideNotification.show(context, text: "待开发功能".tr);
|
||||
},
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
items.addAll([
|
||||
_buildMenuItem(
|
||||
@@ -1620,4 +1694,12 @@ class _DeviceDataComponentWidgetState extends State<DeviceDataComponentWidget> {
|
||||
personController.updateAll();
|
||||
}
|
||||
}
|
||||
|
||||
getWifiPermissionByOpType(Map<String, dynamic> device) {
|
||||
int opType = device['op_type'] ?? 2;
|
||||
if (opType != null && opType == 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
538
lib/pages/device_bind/THShareDeviceDetailWidget.dart
Normal file
538
lib/pages/device_bind/THShareDeviceDetailWidget.dart
Normal file
@@ -0,0 +1,538 @@
|
||||
import 'package:ef/base/widget/flutterflow/FlutterFlowTheme.dart';
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:vbvs_app/common/color/ServiceConstant.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/common/util/requestWithLog.dart';
|
||||
import 'package:vbvs_app/component/tool/CustomCard.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/controller/device/body_device_controller.dart';
|
||||
import 'package:vbvs_app/controller/device/device_share_list_controller.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/test/WebviewTestModel.dart';
|
||||
|
||||
class THShareDeviceDetailWidget extends GetView {
|
||||
final scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
List data; // 保持原始类型
|
||||
String device; // 新增:设备信息
|
||||
|
||||
THShareDeviceDetailWidget(
|
||||
{super.key, required this.data, required this.device}); // 修改构造函数
|
||||
|
||||
DeviceShareListController deviceShareListController = Get.find();
|
||||
|
||||
// 转换为List<Map>的getter
|
||||
List<Map<String, dynamic>> get dataList {
|
||||
if (data is List<Map<String, dynamic>>) {
|
||||
return data as List<Map<String, dynamic>>;
|
||||
} else if (data is List) {
|
||||
// 尝试转换
|
||||
return (data as List).map((item) {
|
||||
if (item is Map<String, dynamic>) {
|
||||
return item;
|
||||
} else if (item is Map) {
|
||||
// 转换为Map<String, dynamic>
|
||||
return Map<String, dynamic>.from(item);
|
||||
}
|
||||
return <String, dynamic>{};
|
||||
}).toList();
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
// 获取分享id
|
||||
String? get shareId {
|
||||
try {
|
||||
for (var item in dataList) {
|
||||
if (item.containsKey('id') && item['id'] != null) {
|
||||
return item['id'].toString();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
print('获取shareId错误: $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取uid
|
||||
String? get uid {
|
||||
try {
|
||||
for (var item in dataList) {
|
||||
if (item.containsKey('uid') && item['uid'] != null) {
|
||||
return item['uid'].toString();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
print('获取uid错误: $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取opType
|
||||
int get currentOpType {
|
||||
try {
|
||||
for (var item in dataList) {
|
||||
if (item.containsKey('opType') && item['opType'] != null) {
|
||||
return int.tryParse(item['opType'].toString()) ?? 1;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
} catch (e) {
|
||||
print('获取opType错误: $e');
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// 切换wifi配置开关的方法
|
||||
void toggleWifiConfig() {
|
||||
int newOpType;
|
||||
|
||||
if (opType.value == 1) {
|
||||
// 如果当前是允许配置wifi,则切换为不允许
|
||||
newOpType = 2;
|
||||
} else {
|
||||
// 如果当前是不允许配置wifi,则切换为允许
|
||||
newOpType = 1;
|
||||
}
|
||||
|
||||
// 更新数据列表中的opType
|
||||
bool updated = false;
|
||||
for (var i = 0; i < dataList.length; i++) {
|
||||
if (dataList[i].containsKey('opType')) {
|
||||
// 如果是原始数据是List<Map>类型,我们需要更新原始数据
|
||||
if (data is List<Map>) {
|
||||
(data as List<Map>)[i]['opType'] = newOpType;
|
||||
} else if (data is List) {
|
||||
// 尝试更新原始数据
|
||||
try {
|
||||
(data as List)[i] = {...dataList[i], 'opType': newOpType};
|
||||
} catch (e) {
|
||||
print('更新opType错误: $e');
|
||||
}
|
||||
}
|
||||
updated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果没有找到opType项,添加一个
|
||||
if (!updated) {
|
||||
if (data is List<Map>) {
|
||||
(data as List<Map>).add({'opType': newOpType});
|
||||
} else if (data is List) {
|
||||
(data as List).add({'opType': newOpType});
|
||||
}
|
||||
}
|
||||
|
||||
opType.value = newOpType;
|
||||
print('切换opType为: $newOpType');
|
||||
}
|
||||
|
||||
// 检查是否允许配置wifi
|
||||
bool get isAllowWifiConfig => opType.value == 1;
|
||||
|
||||
getLine() {
|
||||
return Divider(
|
||||
color: const Color(0XFF929699),
|
||||
thickness: 0.5.rpx,
|
||||
);
|
||||
}
|
||||
|
||||
var opType = 2.obs;
|
||||
bool isProgrammaticPop = false;
|
||||
DateTime? _lastBackPressedTime;
|
||||
BodyDeviceController bodyDeviceController = Get.find();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 初始化opType
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
final current = currentOpType;
|
||||
if (opType.value != current) {
|
||||
opType.value = current;
|
||||
}
|
||||
print('初始化opType: ${opType.value}');
|
||||
});
|
||||
|
||||
return GestureDetector(
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/img/bgNoImg.png'), // 本地图片
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
child: Scaffold(
|
||||
key: scaffoldKey,
|
||||
backgroundColor: Colors.transparent,
|
||||
appBar: AppBar(
|
||||
iconTheme: IconThemeData(color: themeController.currentColor.sc3),
|
||||
backgroundColor: themeController.currentColor.sc17,
|
||||
automaticallyImplyLeading: false,
|
||||
titleSpacing: 0,
|
||||
title: SizedBox(
|
||||
width: double.infinity,
|
||||
height: 180.rpx,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'详情'.tr,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 30.rpx,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
left: 0.rpx,
|
||||
child: returnIconButtomNew(onBack: () async {
|
||||
// await _updateDeviceInfo(context);
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
centerTitle: false,
|
||||
),
|
||||
body: PopScope(
|
||||
canPop: false,
|
||||
onPopInvokedWithResult: (disposition, result) async {
|
||||
if (isProgrammaticPop) {
|
||||
isProgrammaticPop = false;
|
||||
return;
|
||||
}
|
||||
await _updateDeviceInfo(context);
|
||||
},
|
||||
child: Container(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
height: MediaQuery.sizeOf(context).height * 1,
|
||||
child: Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(30.rpx, 34.rpx, 30.rpx, 0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Container(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 展示数据项(k:v格式)
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.only(
|
||||
start: 27.rpx,
|
||||
bottom: 18.rpx,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: _buildDataItems(),
|
||||
),
|
||||
),
|
||||
getLine(),
|
||||
SizedBox(height: 25.rpx),
|
||||
// opType选择部分 - 保持原来的样式
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
// color: Color(0xFF003058),
|
||||
borderRadius: BorderRadius.circular(16.rpx)),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.only(
|
||||
start: 30.rpx,
|
||||
top: 0.rpx,
|
||||
end: 30.rpx,
|
||||
bottom: 0.rpx),
|
||||
child: Column(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
print('点击允许配置wifi');
|
||||
toggleWifiConfig();
|
||||
},
|
||||
child: Container(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
constraints: const BoxConstraints(
|
||||
minHeight: 46,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
BorderRadius.circular(0),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'允许对方配置wifi'.tr,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Readex Pro',
|
||||
color: const Color(0xFFFFFFFF),
|
||||
fontSize: 27.rpx,
|
||||
letterSpacing: 0.0,
|
||||
),
|
||||
),
|
||||
Obx(() {
|
||||
print(
|
||||
'Obx重建,当前opType: ${opType.value}');
|
||||
return Container(
|
||||
height: 33.rpx,
|
||||
child: AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: Center(
|
||||
child: Container(
|
||||
height: 33.rpx,
|
||||
width: 33.rpx,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
BorderRadius
|
||||
.circular(
|
||||
33.rpx / 2),
|
||||
border: Border.all(
|
||||
width:
|
||||
opType.value == 1
|
||||
? 1
|
||||
: 0.5,
|
||||
color:
|
||||
Color(0xFFC8CBD2),
|
||||
),
|
||||
),
|
||||
child: opType.value == 1
|
||||
? Center(
|
||||
child: ClipOval(
|
||||
child:
|
||||
Container(
|
||||
width:
|
||||
33.rpx *
|
||||
0.6,
|
||||
height:
|
||||
33.rpx *
|
||||
0.6,
|
||||
color: const Color(
|
||||
0xFF6BFDAC),
|
||||
),
|
||||
),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
})
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
// 解除分享按钮
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
AppConstants.page_button_bottom_padding,
|
||||
),
|
||||
child: Container(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
height: MediaQuery.sizeOf(context).height * 0.056,
|
||||
constraints: const BoxConstraints(minHeight: 46),
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
FlutterFlowTheme.of(context).secondaryBackground,
|
||||
borderRadius: BorderRadius.circular(16.rpx),
|
||||
),
|
||||
child: CustomCard(
|
||||
borderRadius: 16.rpx,
|
||||
gradientDirection: GradientDirection.vertical,
|
||||
onTap: () async {
|
||||
if (uid != null) {
|
||||
showConfirmDialog(context, Container(), "删除提示".tr,
|
||||
onConfirm: () async {
|
||||
String serviceAddress =
|
||||
ServiceConstant.service_address;
|
||||
String serviceName =
|
||||
ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.device_bind;
|
||||
String queryUrl =
|
||||
"${serviceAddress}${serviceName}${serviceApi}";
|
||||
final data = {
|
||||
"mac": device, // 修改:使用传入的device参数
|
||||
"uid": uid,
|
||||
};
|
||||
await requestWithLog(
|
||||
logTitle: "删除分享设备",
|
||||
method: MyHttpMethod.delete,
|
||||
queryUrl: queryUrl,
|
||||
data: data,
|
||||
onSuccess: (res) {
|
||||
TopSlideNotification.show(context,
|
||||
text: res.msg!);
|
||||
// deviceShareListController.model.all = 0;
|
||||
// deviceShareListController
|
||||
// .selectedShareInfo.value = [];
|
||||
deviceShareListController
|
||||
.getDeviceShareList(
|
||||
device); // 修改:使用传入的device参数
|
||||
deviceShareListController.updateAll();
|
||||
Get.back();
|
||||
},
|
||||
onFailure: (res) {
|
||||
TopSlideNotification.show(context,
|
||||
text: res.msg!,
|
||||
textColor:
|
||||
themeController.currentColor.sc9);
|
||||
deviceShareListController.updateAll();
|
||||
},
|
||||
);
|
||||
}, onCancel: () {});
|
||||
}
|
||||
},
|
||||
colors: const [
|
||||
Color(0xFFFCFCFC),
|
||||
Color(0xFFF8FAF9),
|
||||
Color(0XFFECF6F3),
|
||||
Color(0XFFD9F0E9),
|
||||
Color(0xFFCEECE3)
|
||||
],
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: 90.rpx,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(16.rpx),
|
||||
),
|
||||
child: Text(
|
||||
"解除分享".tr,
|
||||
style: TextStyle(
|
||||
color: const Color(0xFF003058),
|
||||
fontSize: 30.rpx,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 构建数据项列表(k:v格式)
|
||||
List<Widget> _buildDataItems() {
|
||||
List<Widget> widgets = [];
|
||||
|
||||
for (var item in dataList) {
|
||||
// 只显示包含k和v的项
|
||||
if (item.containsKey('k') &&
|
||||
item.containsKey('v') &&
|
||||
item['k'] != null &&
|
||||
item['v'] != null) {
|
||||
String key = item['k'].toString();
|
||||
String value = item['v'].toString();
|
||||
|
||||
// 跳过opType相关的显示,因为我们在下面单独处理了
|
||||
if (key.toLowerCase().contains('optype')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
widgets.add(
|
||||
Padding(
|
||||
padding: EdgeInsets.only(bottom: 10.rpx),
|
||||
child: Text(
|
||||
'$key: $value',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Readex Pro',
|
||||
color: key == '名称' ? Color(0xFFFFFFFF) : Color(0xFF9EA4B7),
|
||||
fontSize: key == '名称' ? 28.rpx : 20.rpx,
|
||||
letterSpacing: 0.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return widgets;
|
||||
}
|
||||
|
||||
// 更新设备信息
|
||||
Future<void> _updateDeviceInfo(BuildContext context) async {
|
||||
try {
|
||||
String? id = shareId;
|
||||
if (id == null) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "设备ID不存在".tr,
|
||||
textColor: Color(0xFFFF7159),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.device_show;
|
||||
String queryUrl = "$serviceAddress$serviceName$serviceApi";
|
||||
|
||||
print('准备更新设备信息,id: $id, opType: ${opType.value}');
|
||||
|
||||
await requestWithLog(
|
||||
logTitle: "更新设备信息".tr,
|
||||
method: MyHttpMethod.put,
|
||||
queryUrl: queryUrl,
|
||||
data: {
|
||||
"id": id,
|
||||
"opType": opType.value,
|
||||
},
|
||||
onSuccess: (res) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "更新成功".tr,
|
||||
textColor: Color(0XFF00C1AA),
|
||||
);
|
||||
bodyDeviceController.getDeviceList();
|
||||
try {
|
||||
WebviewTestController webviewTestController = Get.find();
|
||||
webviewTestController.web.jsbridge?.dart.alterDevice();
|
||||
} catch (e) {
|
||||
ef.log("[h5]通知列表更新错误:$e");
|
||||
}
|
||||
isProgrammaticPop = true;
|
||||
},
|
||||
onFailure: (res) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "更新失败".tr,
|
||||
textColor: Color(0xFFFF7159),
|
||||
);
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
print('更新设备信息错误: $e');
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "更新失败".tr,
|
||||
textColor: Color(0xFFFF7159),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,9 @@ import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
|
||||
|
||||
class DeviceShareInfoWidget extends StatefulWidget {
|
||||
final data;
|
||||
final String device; // 新增:设备信息
|
||||
|
||||
const DeviceShareInfoWidget({super.key, required this.data});
|
||||
const DeviceShareInfoWidget({super.key, required this.data, required this.device}); // 修改构造函数
|
||||
|
||||
@override
|
||||
State<DeviceShareInfoWidget> createState() => _DeviceShareInfoWidgetState();
|
||||
@@ -45,7 +46,13 @@ class _DeviceShareInfoWidgetState extends State<DeviceShareInfoWidget> {
|
||||
highlightColor: themeController.currentColor.sc4,
|
||||
borderRadius: 20.rpx,
|
||||
padding: EdgeInsetsDirectional.fromSTEB(0.rpx, 33.rpx, 0.rpx, 33.rpx),
|
||||
onTap: () {},
|
||||
onTap: () {
|
||||
print("aa");
|
||||
Get.toNamed("/thShareDeviceDetailWidget", arguments: {
|
||||
'data': widget.data,
|
||||
'device': widget.device // 修改:使用传入的device参数
|
||||
});
|
||||
},
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
|
||||
@@ -465,7 +465,7 @@ class _DeviceShareListPageState extends State<DeviceShareListPage> {
|
||||
child: Column(
|
||||
children: list
|
||||
.map((item) =>
|
||||
DeviceShareInfoWidget(data: item))
|
||||
DeviceShareInfoWidget(data: item,device: widget.device,))
|
||||
.toList()
|
||||
.divide(SizedBox(height: 30.rpx))
|
||||
.addToEnd(SizedBox(height: 30.rpx)),
|
||||
|
||||
@@ -29,6 +29,7 @@ class _DeviceSharePageState extends State<DeviceSharePage> {
|
||||
deviceShareController.msg = "".obs;
|
||||
deviceShareController.code = 0.obs;
|
||||
deviceShareController.account = "".obs;
|
||||
deviceShareController.type = 1.obs;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@@ -139,32 +140,184 @@ class _DeviceSharePageState extends State<DeviceSharePage> {
|
||||
),
|
||||
].divide(SizedBox(width: 20.rpx)),
|
||||
),
|
||||
// Row(
|
||||
Container(
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.only(
|
||||
start: 0.rpx,
|
||||
top: 0.rpx,
|
||||
end: 0.rpx,
|
||||
bottom: 0.rpx),
|
||||
child: Column(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
// 当点击时,将 type 设置为 0(允许控制)
|
||||
// data['info'][3]['opType'] = 1;
|
||||
// opType.value = 1;
|
||||
updateWifiConfigSwitch();
|
||||
deviceShareController.updateAll();
|
||||
},
|
||||
child: Container(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
constraints: const BoxConstraints(
|
||||
minHeight: 46,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
BorderRadius.circular(0),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'允许对方配置wifi'.tr,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Readex Pro',
|
||||
color: const Color(0xFFFFFFFF),
|
||||
fontSize: 27.rpx,
|
||||
letterSpacing: 0.0,
|
||||
),
|
||||
),
|
||||
Obx(() {
|
||||
return Container(
|
||||
height: 33.rpx,
|
||||
child: AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: Center(
|
||||
child: Container(
|
||||
height: 33.rpx,
|
||||
width: 33.rpx,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
BorderRadius
|
||||
.circular(
|
||||
33.rpx / 2),
|
||||
border: Border.all(
|
||||
width:
|
||||
getWifiConfigSwitch()
|
||||
? 1
|
||||
: 0.5,
|
||||
color:
|
||||
Color(0xFFC8CBD2),
|
||||
),
|
||||
),
|
||||
child:
|
||||
getWifiConfigSwitch()
|
||||
? Center(
|
||||
child:
|
||||
ClipOval(
|
||||
child:
|
||||
Container(
|
||||
width:
|
||||
33.rpx *
|
||||
0.6,
|
||||
height:
|
||||
33.rpx *
|
||||
0.6,
|
||||
color: const Color(
|
||||
0xFF6BFDAC),
|
||||
),
|
||||
),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
})
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
// GestureDetector(
|
||||
// onTap: () {
|
||||
// // 当点击时,将 type 设置为 1(仅允许查看)
|
||||
// // data['info'][3]['opType'] = 2;
|
||||
// // opType.value = 2;
|
||||
// },
|
||||
// child: Container(
|
||||
// width: MediaQuery.sizeOf(context)
|
||||
// .width,
|
||||
// constraints: const BoxConstraints(
|
||||
// minHeight: 46,
|
||||
// ),
|
||||
// decoration: BoxDecoration(
|
||||
// borderRadius:
|
||||
// BorderRadius.circular(0),
|
||||
// ),
|
||||
// child: Row(
|
||||
// mainAxisSize: MainAxisSize.max,
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// mainAxisAlignment:
|
||||
// MainAxisAlignment
|
||||
// .spaceBetween,
|
||||
// children: [
|
||||
// Obx(() => FancyCircleCheckbox(
|
||||
// borderColor:
|
||||
// themeController.currentColor.sc3,
|
||||
// fillColor:
|
||||
// themeController.currentColor.sc2,
|
||||
// value: true,
|
||||
// onChanged: (value) {},
|
||||
// )),
|
||||
// Text(
|
||||
// '主设备:蓝盈盈(A9876451)',
|
||||
// style: FlutterFlowTheme.of(context)
|
||||
// .bodyMedium
|
||||
// .override(
|
||||
// fontFamily: 'Inter',
|
||||
// fontSize: 26.rpx,
|
||||
// letterSpacing: 0.0,
|
||||
// '仅允许对方查看该设备'.tr,
|
||||
// style: TextStyle(
|
||||
// fontFamily: 'Readex Pro',
|
||||
// color:
|
||||
// themeController.currentColor.sc3,
|
||||
// const Color(0xFFFFFFFF),
|
||||
// fontSize: 27.rpx,
|
||||
// letterSpacing: 0.0,
|
||||
// ),
|
||||
// ),
|
||||
// ].divide(SizedBox(width: 20.rpx)),
|
||||
// Obx(() {
|
||||
// flag2;
|
||||
// return Container(
|
||||
// height: 33.rpx,
|
||||
// child: AspectRatio(
|
||||
// aspectRatio: 1,
|
||||
// child: Center(
|
||||
// child: Container(
|
||||
// height: 33.rpx,
|
||||
// width: 33.rpx,
|
||||
// decoration:
|
||||
// BoxDecoration(
|
||||
// borderRadius:
|
||||
// BorderRadius
|
||||
// .circular(
|
||||
// 33.rpx /
|
||||
// 2),
|
||||
// border: Border.all(
|
||||
// width: 2 == 2
|
||||
// ? 1
|
||||
// : 0.5,
|
||||
// color: Color(
|
||||
// 0xFFC8CBD2),
|
||||
// ),
|
||||
// ),
|
||||
// child: 2 == 2
|
||||
// ? Center(
|
||||
// child:
|
||||
// ClipOval(
|
||||
// child:
|
||||
// Container(
|
||||
// width:
|
||||
// 33.rpx *
|
||||
// 0.6,
|
||||
// height:
|
||||
// 33.rpx *
|
||||
// 0.6,
|
||||
// color: const Color(
|
||||
// 0xFF6BFDAC),
|
||||
// ),
|
||||
// ),
|
||||
// )
|
||||
// : null,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// })
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
)),
|
||||
].divide(SizedBox(height: 64.rpx)),
|
||||
),
|
||||
),
|
||||
@@ -361,4 +514,19 @@ class _DeviceSharePageState extends State<DeviceSharePage> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
getWifiConfigSwitch() {
|
||||
if (deviceShareController.type.value == 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void updateWifiConfigSwitch() {
|
||||
if (deviceShareController.type.value == 1) {
|
||||
deviceShareController.type.value = 2;
|
||||
} else if (deviceShareController.type.value == 2) {
|
||||
deviceShareController.type.value = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,6 +397,7 @@ class ShareDeviceDetailWidget extends GetView {
|
||||
],
|
||||
),
|
||||
))
|
||||
|
||||
]),
|
||||
),
|
||||
Padding(
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:vbvs_app/pages/device/device_detail.dart';
|
||||
import 'package:vbvs_app/pages/device/instant_body_page.dart';
|
||||
import 'package:vbvs_app/pages/device/message_review_page.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/MobileScannerTestPage.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/THShareDeviceDetailWidget.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/after/after_device_calibration_person.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/after/after_update_person_page.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/after/after_wifi_page_person.dart';
|
||||
@@ -132,6 +133,13 @@ var routes = {
|
||||
"/singleMessageSetting": (context, {arguments}) =>
|
||||
SingleMessageSetting(
|
||||
data: arguments),
|
||||
// "/thShareDeviceDetailWidget": (context, {arguments}) =>
|
||||
// THShareDeviceDetailWidget(
|
||||
// data: arguments),
|
||||
"/thShareDeviceDetailWidget": (context, {arguments}) =>
|
||||
THShareDeviceDetailWidget(
|
||||
data: arguments['data'], // 从arguments中获取data
|
||||
device: arguments['device']), // 从arguments中获取device
|
||||
};
|
||||
|
||||
var onGenerateRoute = (RouteSettings settings) {
|
||||
|
||||
39
pubspec.lock
39
pubspec.lock
@@ -211,10 +211,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: built_value
|
||||
sha256: ba95c961bafcd8686d1cf63be864eb59447e795e124d98d6a27d91fcd13602fb
|
||||
sha256: a30f0a0e38671e89a492c44d005b5545b830a961575bbd8336d42869ff71066d
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "8.11.1"
|
||||
version: "8.12.0"
|
||||
cached_network_image:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -435,8 +435,8 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: main
|
||||
resolved-ref: "9a4baafc40913f48d707dbe2ed6a9590f35f809a"
|
||||
ref: b782e61b20
|
||||
resolved-ref: b782e61b20ccd1017f2b441154362dd53c8e2ec1
|
||||
url: "https://gitea.wslpc.real.he-info.cn:94/flutter/easydevice.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
@@ -445,7 +445,7 @@ packages:
|
||||
description:
|
||||
path: "."
|
||||
ref: main
|
||||
resolved-ref: a1173d7a01589144d32ca33c300464646274b8fe
|
||||
resolved-ref: ea1d95737ab262ea8b18f073fd60cffe04e5e871
|
||||
url: "https://gitea.wslpc.real.he-info.cn:94/flutter/easyweb.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
@@ -704,10 +704,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_pdfview
|
||||
sha256: c402ad1f51ba8ea73b9fb04c003ca0a9286118ba5ac9787ee2aa58956b3fcf8a
|
||||
sha256: "51413e36ab3f1a2fe0edf97ebfa770e20182ea4a066bc9f292920330d9245c9d"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.4.1+1"
|
||||
version: "1.4.0+1"
|
||||
flutter_plugin_android_lifecycle:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1239,6 +1239,15 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.15.0"
|
||||
mhtctrl:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: main
|
||||
resolved-ref: ad7cf59cd3bd4fa607e8cd89cc773df752919751
|
||||
url: "https://gitea.wslpc.real.he-info.cn:94/flutter/mhtctrl.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
mime:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1547,10 +1556,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pool
|
||||
sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a"
|
||||
sha256: "978783255c543aa3586a1b3c21f6e9d720eb315376a915872c61ef8b5c20177d"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.5.1"
|
||||
version: "1.5.2"
|
||||
posix:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1635,10 +1644,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: rfc_6901
|
||||
sha256: df1bbfa3d023009598f19636d6114c6ac1e0b7bb7bf6a260f0e6e6ce91416820
|
||||
sha256: "6a43b1858dca2febaf93e15639aa6b0c49ccdfd7647775f15a499f872b018154"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
version: "0.2.1"
|
||||
rive:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -2024,10 +2033,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: unorm_dart
|
||||
sha256: "8e3870a1caa60bde8352f9597dd3535d8068613269444f8e35ea8925ec84c1f5"
|
||||
sha256: "0c69186b03ca6addab0774bcc0f4f17b88d4ce78d9d4d8f0619e30a99ead58e7"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.3.1+1"
|
||||
version: "0.3.2"
|
||||
url_launcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -2152,10 +2161,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: watcher
|
||||
sha256: "5bf046f41320ac97a469d506261797f35254fa61c641741ef32dacda98b7d39c"
|
||||
sha256: "592ab6e2892f67760543fb712ff0177f4ec76c031f02f5b4ff8d3fc5eb9fb61a"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.3"
|
||||
version: "1.1.4"
|
||||
weather:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
||||
@@ -15,7 +15,7 @@ fluwx:
|
||||
# interrupt_wx_request: true # Defaults to true.
|
||||
# flutter_activity: 'MainActivity' # Defaults to app's launcher
|
||||
ios:
|
||||
universal_link: https://zhmht.swes.com.cn
|
||||
# universal_link: https://zhmht.swes.com.cn
|
||||
no_pay: true # Set to true to disable payment.
|
||||
|
||||
dependencies:
|
||||
@@ -79,7 +79,8 @@ dependencies:
|
||||
url: https://gitea.wslpc.real.he-info.cn:94/flutter/easyweb.git
|
||||
ref: main
|
||||
archive: ^4.0.0
|
||||
jpush_flutter: ^3.3.6
|
||||
# archive: ^3.6.1
|
||||
jpush_flutter: 3.3.6
|
||||
share_plus: ^11.1.0
|
||||
mhtctrl:
|
||||
git:
|
||||
@@ -119,6 +120,7 @@ flutter:
|
||||
- assets/img/icon/
|
||||
- assets/file.json
|
||||
- assets/miniapp/
|
||||
- assets/city/
|
||||
fonts:
|
||||
- family: calculatrix
|
||||
fonts:
|
||||
|
||||
Reference in New Issue
Block a user