diff --git a/components/configureDevice_2/configureDevice_2.js b/components/configureDevice_2/configureDevice_2.js
index 9c5e5a7..1e33205 100644
--- a/components/configureDevice_2/configureDevice_2.js
+++ b/components/configureDevice_2/configureDevice_2.js
@@ -181,13 +181,13 @@ Component({
let rawList = Array.isArray(deviceUserIds) ? deviceUserIds : [];
// 兼容对象数组和纯ID数组,统一转为字符串比对
let deviceIds = rawList.map(item => ({
- userID: item.userID,
- memberID: item.memberID
+ id: item,
+ memberID: ""
}));
let localIds = userList.map(user => user.id);
-
+
// 秤有、列表没有 → 需要从秤删除
- let needDeleteList = deviceIds.filter(d => !localIds.includes(d.userID));
+ let needDeleteList = deviceIds.filter(d => !localIds.includes(d.id));
// 秤没有、列表有 → 需要下发到秤
let needSyncList = userList.filter(user => !deviceIds.some(d => d.userID == user.id));
@@ -257,7 +257,7 @@ Component({
wx.showLoading({ title: "正在删除第" + (delIndex + 1) + "/" + needDeleteList.length + "个多余用户...", mask: true });
let item = needDeleteList[delIndex];
app.globalData.ppScale.activeProtocol.dataDeleteUser({
- userID: item.userID,
+ userID: item.id,
memberID: ""
}, (status) => {
if (status == 0) {
diff --git a/components/configureDevice_4/configureDevice_4.js b/components/configureDevice_4/configureDevice_4.js
index 19be1bf..b035d54 100644
--- a/components/configureDevice_4/configureDevice_4.js
+++ b/components/configureDevice_4/configureDevice_4.js
@@ -1,9 +1,141 @@
+const app = getApp();
+
Component({
+ data: {
+ otaProgress: 0,
+ otaStatus: '', // 'upgrading' | 'success' | 'failed' | ''
+ otaMessage: ''
+ },
+
methods: {
bindOk() {
this.triggerEvent('deviceEvent', {
status: true
});
+ },
+
+ // OTA 升级方法
+ updateOta() {
+ wx.showModal({
+ title: '提示',
+ content: '确定要进行 OTA 升级吗?升级过程中请保持设备与手机的连接,升级可能需要几分钟时间。',
+ success: (res) => {
+ if (res.confirm) {
+ this.startOtaUpgrade();
+ }
+ }
+ });
+ },
+
+ // 开始 OTA 升级
+ startOtaUpgrade() {
+ wx.showLoading({
+ title: '正在升级...',
+ mask: true
+ });
+
+ this.setData({
+ otaProgress: 0,
+ otaStatus: 'upgrading',
+ otaMessage: '升级初始化中...'
+ });
+
+ const activeProtocol = app.globalData.ppScale.activeProtocol;
+
+ if (!activeProtocol) {
+ wx.hideLoading();
+ wx.showToast({
+ title: '设备未连接,请重新连接',
+ icon: 'none'
+ });
+ return;
+ }
+
+ // 调用蓝牙插件的 OTA 升级接口
+ activeProtocol.codeOtaUpdate((status) => {
+ console.log('OTA 升级状态:', status);
+
+ // status 可能是进度百分比或状态码
+ if (typeof status === 'object') {
+ // 处理进度对象 { progress: 0-100, status: 0/1 }
+ if (status.progress !== undefined) {
+ this.setData({
+ otaProgress: status.progress,
+ otaMessage: `升级进度: ${status.progress}%`
+ });
+ }
+
+ // 升级完成或失败
+ if (status.status === 0) {
+ this.handleOtaSuccess();
+ } else if (status.status === 1) {
+ this.handleOtaFailed();
+ }
+ } else if (typeof status === 'number') {
+ // 处理数字状态码
+ if (status === 0) {
+ this.handleOtaSuccess();
+ } else if (status === 1) {
+ this.handleOtaFailed();
+ } else {
+ // 当作进度百分比处理
+ this.setData({
+ otaProgress: Math.min(status, 100),
+ otaMessage: `升级进度: ${Math.min(status, 100)}%`
+ });
+ }
+ }
+ });
+ },
+
+ // OTA 升级成功处理
+ handleOtaSuccess() {
+ wx.hideLoading();
+ this.setData({
+ otaProgress: 100,
+ otaStatus: 'success',
+ otaMessage: '升级成功'
+ });
+
+ wx.showToast({
+ title: 'OTA 升级成功',
+ icon: 'success',
+ duration: 2000
+ });
+
+ // 2秒后重置状态
+ setTimeout(() => {
+ this.setData({
+ otaProgress: 0,
+ otaStatus: '',
+ otaMessage: ''
+ });
+ }, 2000);
+ },
+
+ // OTA 升级失败处理
+ handleOtaFailed() {
+ wx.hideLoading();
+ this.setData({
+ otaProgress: 0,
+ otaStatus: 'failed',
+ otaMessage: '升级失败,请重试'
+ });
+
+ wx.showToast({
+ title: '升级失败,请重试',
+ icon: 'none',
+ duration: 2000
+ });
+
+ // 2秒后重置状态
+ setTimeout(() => {
+ this.setData({
+ otaProgress: 0,
+ otaStatus: '',
+ otaMessage: ''
+ });
+ }, 2000);
}
}
});
\ No newline at end of file
diff --git a/components/configureDevice_4/configureDevice_4.wxml b/components/configureDevice_4/configureDevice_4.wxml
index 2a2c30f..74150b5 100644
--- a/components/configureDevice_4/configureDevice_4.wxml
+++ b/components/configureDevice_4/configureDevice_4.wxml
@@ -8,5 +8,15 @@
随时随地同步测量数据
+
+
+ {{otaMessage}}
+
+
+
+ {{otaProgress}}%
+
+
完成
+ OTA升级
\ No newline at end of file
diff --git a/components/configureDevice_4/configureDevice_4.wxss b/components/configureDevice_4/configureDevice_4.wxss
index d3107e8..4180d91 100644
--- a/components/configureDevice_4/configureDevice_4.wxss
+++ b/components/configureDevice_4/configureDevice_4.wxss
@@ -7,7 +7,7 @@
.icon {
width: 100%;
- margin-bottom: 475rpx;
+ margin-bottom: 400rpx;
}
.icon>view:first-of-type {
@@ -45,5 +45,58 @@
line-height: 88rpx;
text-align: center;
border-radius: 44rpx;
+ margin-bottom: 45rpx;
background-color: #1385FA;
}
+
+.ota {
+ color: #1385FA;
+ width: 100%;
+ height: 88rpx;
+ font-size: 32rpx;
+ font-weight: bold;
+ line-height: 86rpx;
+ text-align: center;
+ border-radius: 44rpx;
+ box-sizing: border-box;
+ border: 1rpx solid #1385FA;
+}
+
+/* OTA 升级进度样式 */
+.ota-progress-container {
+ width: 100%;
+ margin-bottom: 30rpx;
+ padding: 20rpx;
+ background-color: #F5F5F5;
+ border-radius: 12rpx;
+ box-sizing: border-box;
+}
+
+.ota-message {
+ color: #252535;
+ font-size: 28rpx;
+ margin-bottom: 15rpx;
+ text-align: center;
+}
+
+.progress-bar {
+ width: 100%;
+ height: 8rpx;
+ background-color: #E0E0E0;
+ border-radius: 4rpx;
+ overflow: hidden;
+ margin-bottom: 10rpx;
+}
+
+.progress-fill {
+ height: 100%;
+ background-color: #1385FA;
+ transition: width 0.3s ease;
+}
+
+.progress-text {
+ color: #1385FA;
+ font-size: 24rpx;
+ text-align: center;
+ font-weight: bold;
+}
diff --git a/pages/my/my.js b/pages/my/my.js
index aff6204..54cc19d 100644
--- a/pages/my/my.js
+++ b/pages/my/my.js
@@ -25,6 +25,12 @@ Page({
}
},
+ wifiChange() {
+ wx.navigateTo({
+ url: "/pages/searchDevice/searchDevice"
+ })
+ },
+
starLogin() {
return new Promise((resolve, reject) => {
wx.login({
diff --git a/pages/my/my.wxml b/pages/my/my.wxml
index c8e2fc9..ba3a353 100644
--- a/pages/my/my.wxml
+++ b/pages/my/my.wxml
@@ -13,6 +13,13 @@
我的服务
+
+
+
+
+ 更换网络
+
+