更新绑定时候选择房间和设置房间名称
This commit is contained in:
@@ -241,6 +241,7 @@ class MHTBlueToothController extends GetControllerEx<MHTBlueToothModel> {
|
|||||||
if (currentFullDevice != null) {
|
if (currentFullDevice != null) {
|
||||||
currentFullDevice!.macAID = res.data['macA'];
|
currentFullDevice!.macAID = res.data['macA'];
|
||||||
currentFullDevice!.macBID = res.data['macB'];
|
currentFullDevice!.macBID = res.data['macB'];
|
||||||
|
currentFullDevice!.deviceID = res.data['id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -195,7 +195,12 @@ class _MHTPeopleInfoPageState extends State<MHTPeopleInfoPage> {
|
|||||||
TopSlideNotification.show(context, text: "保存成功");
|
TopSlideNotification.show(context, text: "保存成功");
|
||||||
MHTHomeController mhtHomeController = Get.find();
|
MHTHomeController mhtHomeController = Get.find();
|
||||||
mhtHomeController.getPersonList();
|
mhtHomeController.getPersonList();
|
||||||
Get.offNamed("/bindDeviceSuccess");
|
// Get.offNamed("/bindDeviceSuccess");
|
||||||
|
Map data = {};
|
||||||
|
final device = bluetoothController.currentFullDevice;
|
||||||
|
data['_id'] = device!.deviceID;
|
||||||
|
data['isNextStep'] = true;
|
||||||
|
Get.toNamed("/editBedPage", arguments: data);
|
||||||
},
|
},
|
||||||
colors: const [
|
colors: const [
|
||||||
Color(0xFFFCFCFC),
|
Color(0xFFFCFCFC),
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ class BlueToothDataModel {
|
|||||||
int type;
|
int type;
|
||||||
String? macAID;
|
String? macAID;
|
||||||
String? macBID;
|
String? macBID;
|
||||||
DateTime lastSeen; // 添加的最后可见时间字段
|
DateTime lastSeen; // 最后可见时间
|
||||||
|
String? deviceID; // 设备ID
|
||||||
|
|
||||||
BlueToothDataModel({
|
BlueToothDataModel({
|
||||||
this.name = '',
|
this.name = '',
|
||||||
@@ -20,12 +21,18 @@ class BlueToothDataModel {
|
|||||||
required this.type,
|
required this.type,
|
||||||
this.macA = '',
|
this.macA = '',
|
||||||
this.macB = '',
|
this.macB = '',
|
||||||
required this.lastSeen, // 添加到构造函数参数
|
required this.lastSeen,
|
||||||
|
this.deviceID, // ✅ 加入构造函数参数
|
||||||
});
|
});
|
||||||
|
|
||||||
factory BlueToothDataModel.fromScanResult(ScanResult result, int type,
|
factory BlueToothDataModel.fromScanResult(
|
||||||
{bool bind = false, String name = '', String mac = ''}) {
|
ScanResult result,
|
||||||
// 如果外部没有传入 name,则取 localName
|
int type, {
|
||||||
|
bool bind = false,
|
||||||
|
String name = '',
|
||||||
|
String mac = '',
|
||||||
|
String? deviceID, // ✅ 工厂方法接收 deviceID
|
||||||
|
}) {
|
||||||
String finalName =
|
String finalName =
|
||||||
name.isNotEmpty ? name : (result.advertisementData.localName ?? '');
|
name.isNotEmpty ? name : (result.advertisementData.localName ?? '');
|
||||||
|
|
||||||
@@ -35,9 +42,10 @@ class BlueToothDataModel {
|
|||||||
mac: mac,
|
mac: mac,
|
||||||
scanResult: result,
|
scanResult: result,
|
||||||
type: type,
|
type: type,
|
||||||
macA: '', // 保持原有默认值
|
macA: '',
|
||||||
macB: '', // 保持原有默认值
|
macB: '',
|
||||||
lastSeen: DateTime.now(), // 设置为当前时间
|
lastSeen: DateTime.now(),
|
||||||
|
deviceID: deviceID, // ✅ 赋值
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,17 @@ import 'package:vbvs_app/component/tool/CustomCard.dart';
|
|||||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||||
import 'package:vbvs_app/controller/mh_controller/device_list_controller.dart';
|
import 'package:vbvs_app/controller/mh_controller/device_list_controller.dart';
|
||||||
import 'package:vbvs_app/pages/mh_page/bluetooth.dart';
|
import 'package:vbvs_app/pages/mh_page/bluetooth.dart';
|
||||||
|
import 'package:vbvs_app/pages/mh_page/device/controller/mht_bluetooth_controller.dart';
|
||||||
import 'package:vbvs_app/pages/mh_page/test/WebviewTestModel.dart';
|
import 'package:vbvs_app/pages/mh_page/test/WebviewTestModel.dart';
|
||||||
|
|
||||||
class EditBedPage extends StatefulWidget {
|
class EditBedPage extends StatefulWidget {
|
||||||
final Map data;
|
final Map data;
|
||||||
EditBedPage({Key? key, required this.data});
|
|
||||||
|
EditBedPage({
|
||||||
|
Key? key,
|
||||||
|
required this.data,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_EditBedPageState createState() => _EditBedPageState();
|
_EditBedPageState createState() => _EditBedPageState();
|
||||||
}
|
}
|
||||||
@@ -79,6 +85,70 @@ class _EditBedPageState extends State<EditBedPage> {
|
|||||||
left: 0.rpx,
|
left: 0.rpx,
|
||||||
child: returnIconButtomNew,
|
child: returnIconButtomNew,
|
||||||
),
|
),
|
||||||
|
if (widget.data != null &&
|
||||||
|
(widget.data['isNextStep'] != null &&
|
||||||
|
widget.data['isNextStep'] == true))
|
||||||
|
Positioned(
|
||||||
|
right: 30.rpx,
|
||||||
|
child: CustomCard(
|
||||||
|
borderRadius: 16.rpx,
|
||||||
|
gradientDirection: GradientDirection.vertical,
|
||||||
|
onTap: () async {
|
||||||
|
String serviceAddress =
|
||||||
|
ServiceConstant.service_address;
|
||||||
|
String serviceName = ServiceConstant.server_service;
|
||||||
|
String serviceApi = ServiceConstant.device_show;
|
||||||
|
String queryUrl =
|
||||||
|
"$serviceAddress$serviceName$serviceApi";
|
||||||
|
await requestWithLog(
|
||||||
|
logTitle: "更新设备信息",
|
||||||
|
method: MyHttpMethod.put,
|
||||||
|
queryUrl: queryUrl,
|
||||||
|
data: {
|
||||||
|
"id": editedData["_id"],
|
||||||
|
"name": editedData["name"],
|
||||||
|
},
|
||||||
|
onSuccess: (res) {
|
||||||
|
TopSlideNotification.show(context,
|
||||||
|
text: "修改名称成功".tr);
|
||||||
|
deviceListController.getDeviceList();
|
||||||
|
|
||||||
|
Map data = {};
|
||||||
|
final MHTBlueToothController
|
||||||
|
bluetoothController = Get.find();
|
||||||
|
final device =
|
||||||
|
bluetoothController.currentFullDevice;
|
||||||
|
data['_id'] = device!.deviceID;
|
||||||
|
data['isNextStep'] = true;
|
||||||
|
Get.toNamed("/roomPickerPage",
|
||||||
|
arguments: data);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
colors: const [
|
||||||
|
Color(0xFFFCFCFC),
|
||||||
|
Color(0xFFF8FAF9),
|
||||||
|
Color(0XFFECF6F3),
|
||||||
|
Color(0XFFD9F0E9),
|
||||||
|
Color(0xFFCEECE3)
|
||||||
|
],
|
||||||
|
child: Container(
|
||||||
|
width: 120.rpx,
|
||||||
|
height: 60.rpx,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: Text(
|
||||||
|
"下一步",
|
||||||
|
style: TextStyle(
|
||||||
|
fontFamily: 'Readex Pro',
|
||||||
|
color: Color(0XFF011D33),
|
||||||
|
letterSpacing: 0,
|
||||||
|
fontSize: 30.rpx,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -186,64 +256,67 @@ class _EditBedPageState extends State<EditBedPage> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
if (widget.data['isNextStep'] == null ||
|
||||||
padding: EdgeInsets.only(
|
widget.data['isNextStep'] == false)
|
||||||
left: 30.rpx, right: 30.rpx, bottom: 85.rpx),
|
Padding(
|
||||||
child: CustomCard(
|
padding: EdgeInsets.only(
|
||||||
borderRadius: 16.rpx,
|
left: 30.rpx, right: 30.rpx, bottom: 85.rpx),
|
||||||
gradientDirection: GradientDirection.vertical,
|
child: CustomCard(
|
||||||
onTap: () async {
|
borderRadius: 16.rpx,
|
||||||
String serviceAddress =
|
gradientDirection: GradientDirection.vertical,
|
||||||
ServiceConstant.service_address;
|
onTap: () async {
|
||||||
String serviceName =
|
String serviceAddress =
|
||||||
ServiceConstant.server_service;
|
ServiceConstant.service_address;
|
||||||
String serviceApi = ServiceConstant.device_show;
|
String serviceName =
|
||||||
String queryUrl =
|
ServiceConstant.server_service;
|
||||||
"$serviceAddress$serviceName$serviceApi";
|
String serviceApi =
|
||||||
await requestWithLog(
|
ServiceConstant.device_show;
|
||||||
logTitle: "更新设备信息",
|
String queryUrl =
|
||||||
method: MyHttpMethod.put,
|
"$serviceAddress$serviceName$serviceApi";
|
||||||
queryUrl: queryUrl,
|
await requestWithLog(
|
||||||
data: {
|
logTitle: "更新设备信息",
|
||||||
"id": editedData["_id"],
|
method: MyHttpMethod.put,
|
||||||
"name": editedData["name"],
|
queryUrl: queryUrl,
|
||||||
},
|
data: {
|
||||||
onSuccess: (res) {
|
"id": editedData["_id"],
|
||||||
TopSlideNotification.show(context,
|
"name": editedData["name"],
|
||||||
text: "修改名称成功".tr);
|
},
|
||||||
deviceListController.getDeviceList();
|
onSuccess: (res) {
|
||||||
try {
|
TopSlideNotification.show(context,
|
||||||
WebviewTestController
|
text: "修改名称成功".tr);
|
||||||
webviewTestController = Get.find();
|
deviceListController.getDeviceList();
|
||||||
webviewTestController.web.jsbridge?.dart
|
try {
|
||||||
.alterDevice();
|
WebviewTestController
|
||||||
} catch (e) {
|
webviewTestController = Get.find();
|
||||||
ef.log("[h5]通知列表更新错误:$e");
|
webviewTestController.web.jsbridge?.dart
|
||||||
}
|
.alterDevice();
|
||||||
Get.back(result: editedData);
|
} catch (e) {
|
||||||
},
|
ef.log("[h5]通知列表更新错误:$e");
|
||||||
);
|
}
|
||||||
},
|
Get.back(result: editedData);
|
||||||
colors: const [
|
},
|
||||||
Color(0xFFFCFCFC),
|
);
|
||||||
Color(0xFFF8FAF9),
|
},
|
||||||
Color(0XFFECF6F3),
|
colors: const [
|
||||||
Color(0XFFD9F0E9),
|
Color(0xFFFCFCFC),
|
||||||
Color(0xFFCEECE3)
|
Color(0xFFF8FAF9),
|
||||||
],
|
Color(0XFFECF6F3),
|
||||||
child: Container(
|
Color(0XFFD9F0E9),
|
||||||
width: double.infinity,
|
Color(0xFFCEECE3)
|
||||||
height: 90.rpx,
|
],
|
||||||
alignment: Alignment.center,
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
width: double.infinity,
|
||||||
borderRadius: BorderRadius.circular(6),
|
height: 90.rpx,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
),
|
||||||
|
child: Text("完成".tr,
|
||||||
|
style: TextStyle(
|
||||||
|
color: const Color(0xFF003058),
|
||||||
|
fontSize: 26.rpx)),
|
||||||
),
|
),
|
||||||
child: Text("完成".tr,
|
))
|
||||||
style: TextStyle(
|
|
||||||
color: const Color(0xFF003058),
|
|
||||||
fontSize: 26.rpx)),
|
|
||||||
),
|
|
||||||
))
|
|
||||||
],
|
],
|
||||||
))),
|
))),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -85,6 +85,75 @@ class _RoomPickerPageState extends State<RoomPickerPage> {
|
|||||||
left: 0.rpx,
|
left: 0.rpx,
|
||||||
child: returnIconButtomNew,
|
child: returnIconButtomNew,
|
||||||
),
|
),
|
||||||
|
if (widget.data != null &&
|
||||||
|
(widget.data['isNextStep'] != null &&
|
||||||
|
widget.data['isNextStep'] == true))
|
||||||
|
Positioned(
|
||||||
|
right: 30.rpx,
|
||||||
|
child: CustomCard(
|
||||||
|
borderRadius: 16.rpx,
|
||||||
|
gradientDirection: GradientDirection.vertical,
|
||||||
|
onTap: () async {
|
||||||
|
// Get.toNamed("/applyRepairPage");
|
||||||
|
try {
|
||||||
|
String serviceAddress =
|
||||||
|
ServiceConstant.service_address;
|
||||||
|
String serviceName =
|
||||||
|
ServiceConstant.server_service;
|
||||||
|
String serviceApi =
|
||||||
|
ServiceConstant.device_show;
|
||||||
|
String queryUrl =
|
||||||
|
"$serviceAddress$serviceName$serviceApi";
|
||||||
|
await requestWithLog(
|
||||||
|
logTitle: "更新设备信息",
|
||||||
|
method: MyHttpMethod.put,
|
||||||
|
queryUrl: queryUrl,
|
||||||
|
data: {
|
||||||
|
"id": editedData["_id"],
|
||||||
|
"roomId": rooms[selectedIndex]['_id'],
|
||||||
|
},
|
||||||
|
onSuccess: (res) {
|
||||||
|
editedData['roomName'] =
|
||||||
|
rooms[selectedIndex]['name'];
|
||||||
|
TopSlideNotification.show(context,
|
||||||
|
text: "更新成功".tr,
|
||||||
|
textColor: Color(0XFF00C1AA));
|
||||||
|
deviceListController.getDeviceList();
|
||||||
|
Get.offNamed("/bindDeviceSuccess");
|
||||||
|
},
|
||||||
|
onFailure: (res) {
|
||||||
|
TopSlideNotification.show(context,
|
||||||
|
text: "更新失败".tr,
|
||||||
|
textColor: Color(0xFFFF7159));
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
print(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
colors: const [
|
||||||
|
Color(0xFFFCFCFC),
|
||||||
|
Color(0xFFF8FAF9),
|
||||||
|
Color(0XFFECF6F3),
|
||||||
|
Color(0XFFD9F0E9),
|
||||||
|
Color(0xFFCEECE3)
|
||||||
|
],
|
||||||
|
child: Container(
|
||||||
|
width: 120.rpx,
|
||||||
|
height: 60.rpx,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: Text(
|
||||||
|
"下一步",
|
||||||
|
style: TextStyle(
|
||||||
|
fontFamily: 'Readex Pro',
|
||||||
|
color: Color(0XFF011D33),
|
||||||
|
letterSpacing: 0,
|
||||||
|
fontSize: 30.rpx,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -157,86 +226,90 @@ class _RoomPickerPageState extends State<RoomPickerPage> {
|
|||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
// 完成按钮
|
// 完成按钮
|
||||||
Padding(
|
if (widget.data['isNextStep'] == null ||
|
||||||
padding: EdgeInsets.only(
|
widget.data['isNextStep'] == false)
|
||||||
left: 30.rpx,
|
Padding(
|
||||||
right: 30.rpx,
|
padding: EdgeInsets.only(
|
||||||
bottom: 83.rpx,
|
left: 30.rpx,
|
||||||
),
|
right: 30.rpx,
|
||||||
child: SizedBox(
|
bottom: 83.rpx,
|
||||||
width: double.infinity,
|
),
|
||||||
height: 50,
|
child: SizedBox(
|
||||||
child: CustomCard(
|
width: double.infinity,
|
||||||
borderRadius: 16.rpx,
|
height: 50,
|
||||||
gradientDirection: GradientDirection.vertical,
|
child: CustomCard(
|
||||||
onTap: () async {
|
borderRadius: 16.rpx,
|
||||||
// Get.toNamed("/applyRepairPage");
|
gradientDirection: GradientDirection.vertical,
|
||||||
try {
|
onTap: () async {
|
||||||
String serviceAddress =
|
// Get.toNamed("/applyRepairPage");
|
||||||
ServiceConstant.service_address;
|
try {
|
||||||
String serviceName =
|
String serviceAddress =
|
||||||
ServiceConstant.server_service;
|
ServiceConstant.service_address;
|
||||||
String serviceApi =
|
String serviceName =
|
||||||
ServiceConstant.device_show;
|
ServiceConstant.server_service;
|
||||||
String queryUrl =
|
String serviceApi =
|
||||||
"$serviceAddress$serviceName$serviceApi";
|
ServiceConstant.device_show;
|
||||||
await requestWithLog(
|
String queryUrl =
|
||||||
logTitle: "更新设备信息",
|
"$serviceAddress$serviceName$serviceApi";
|
||||||
method: MyHttpMethod.put,
|
await requestWithLog(
|
||||||
queryUrl: queryUrl,
|
logTitle: "更新设备信息",
|
||||||
data: {
|
method: MyHttpMethod.put,
|
||||||
"id": editedData["_id"],
|
queryUrl: queryUrl,
|
||||||
"roomId": rooms[selectedIndex]['_id'],
|
data: {
|
||||||
},
|
"id": editedData["_id"],
|
||||||
onSuccess: (res) {
|
"roomId": rooms[selectedIndex]['_id'],
|
||||||
editedData['roomName'] =
|
},
|
||||||
rooms[selectedIndex]['name'];
|
onSuccess: (res) {
|
||||||
TopSlideNotification.show(context,
|
editedData['roomName'] =
|
||||||
text: "更新成功".tr,
|
rooms[selectedIndex]['name'];
|
||||||
textColor: Color(0XFF00C1AA));
|
TopSlideNotification.show(context,
|
||||||
deviceListController.getDeviceList();
|
text: "更新成功".tr,
|
||||||
try {
|
textColor: Color(0XFF00C1AA));
|
||||||
WebviewTestController
|
deviceListController.getDeviceList();
|
||||||
webviewTestController = Get.find();
|
try {
|
||||||
webviewTestController.web.jsbridge?.dart
|
WebviewTestController
|
||||||
.alterDevice();
|
webviewTestController =
|
||||||
} catch (e) {
|
Get.find();
|
||||||
ef.log("[h5]通知列表更新错误:$e");
|
webviewTestController
|
||||||
}
|
.web.jsbridge?.dart
|
||||||
Get.back(result: editedData);
|
.alterDevice();
|
||||||
},
|
} catch (e) {
|
||||||
onFailure: (res) {
|
ef.log("[h5]通知列表更新错误:$e");
|
||||||
TopSlideNotification.show(context,
|
}
|
||||||
text: "更新失败".tr,
|
Get.back(result: editedData);
|
||||||
textColor: Color(0xFFFF7159));
|
},
|
||||||
},
|
onFailure: (res) {
|
||||||
);
|
TopSlideNotification.show(context,
|
||||||
} catch (e) {
|
text: "更新失败".tr,
|
||||||
print(e);
|
textColor: Color(0xFFFF7159));
|
||||||
}
|
},
|
||||||
},
|
);
|
||||||
colors: const [
|
} catch (e) {
|
||||||
Color(0xFFFCFCFC),
|
print(e);
|
||||||
Color(0xFFF8FAF9),
|
}
|
||||||
Color(0XFFECF6F3),
|
},
|
||||||
Color(0XFFD9F0E9),
|
colors: const [
|
||||||
Color(0xFFCEECE3)
|
Color(0xFFFCFCFC),
|
||||||
],
|
Color(0xFFF8FAF9),
|
||||||
child: Container(
|
Color(0XFFECF6F3),
|
||||||
width: double.infinity,
|
Color(0XFFD9F0E9),
|
||||||
height: 90.rpx,
|
Color(0xFFCEECE3)
|
||||||
alignment: Alignment.center,
|
],
|
||||||
decoration: BoxDecoration(
|
child: Container(
|
||||||
borderRadius: BorderRadius.circular(6),
|
width: double.infinity,
|
||||||
|
height: 90.rpx,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
),
|
||||||
|
child: Text("完成".tr,
|
||||||
|
style: TextStyle(
|
||||||
|
color: const Color(0xFF003058),
|
||||||
|
fontSize: 30.rpx,
|
||||||
|
)),
|
||||||
),
|
),
|
||||||
child: Text("完成".tr,
|
)),
|
||||||
style: TextStyle(
|
),
|
||||||
color: const Color(0xFF003058),
|
|
||||||
fontSize: 30.rpx,
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user