更新设备名称时候的为空的bug

This commit is contained in:
wyf
2025-07-25 16:29:04 +08:00
parent 4a3ddd0006
commit 5e00649fba
2 changed files with 27 additions and 7 deletions

View File

@@ -1,3 +1,5 @@
import 'dart:math';
import 'package:ef/ef.dart';
import 'package:flutter/material.dart';
import 'package:vbvs_app/common/color/ServiceConstant.dart';
@@ -94,6 +96,18 @@ class _EditBedPageState extends State<EditBedPage> {
borderRadius: 16.rpx,
gradientDirection: GradientDirection.vertical,
onTap: () async {
final MHTBlueToothController bluetoothController =
Get.find();
final device =
bluetoothController.currentFullDevice;
if (editedData['name'] == null ||
editedData['name'] == '') {
if (device!.type == 2) {
editedData['name'] = '智能电动床';
} else {
editedData['name'] = '律动智能床垫';
}
}
String serviceAddress =
ServiceConstant.service_address;
String serviceName = ServiceConstant.server_service;
@@ -112,12 +126,7 @@ class _EditBedPageState extends State<EditBedPage> {
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);
@@ -193,7 +202,6 @@ class _EditBedPageState extends State<EditBedPage> {
maxLength: AppConstants().text_length,
decoration: InputDecoration(
hintText: "请输入设备的名称",
// counterText: "",
contentPadding:
const EdgeInsetsDirectional
.fromSTEB(10, 0, 10, 0),
@@ -271,6 +279,14 @@ class _EditBedPageState extends State<EditBedPage> {
ServiceConstant.device_show;
String queryUrl =
"$serviceAddress$serviceName$serviceApi";
if (editedData['name'] == null ||
editedData['name'] == '') {
if (editedData['device_type'] == 2) {
editedData['name'] = '智能电动床';
} else {
editedData['name'] = '律动智能床垫';
}
}
await requestWithLog(
logTitle: "更新设备信息",
method: MyHttpMethod.put,

View File

@@ -199,7 +199,11 @@ class MHTLoginController extends GetControllerEx<LoginModel> {
String serviceName = ServiceConstant.server_service;
String serviceApi = ServiceConstant.send_code;
String queryUrl = "${serviceAddress}${serviceName}${serviceApi}";
var data = {"userName": model.phone, "type": 1};
var data = {
"userName": model.phone,
"type": 1,
};
data['code'] = "mht";
await requestWithLog(
data: data,
logTitle: "发送验证码",