Explorar el Código

Merge branch 'develop/3.2.4' of http://60.205.190.38:9000/zhaoheqing/wxmini into develop/3.2.4

Damon hace 8 meses
padre
commit
064ac0d5eb

+ 0 - 1
devices/bluetooth/bt_parse.js

@@ -407,7 +407,6 @@ class BtParse {
             case CmdRtc.querySleepAfterPlayPause:
             case CmdRtc.setSleepAfterPlayPause:
                 {
-                    console.log("pauseSleep=====", value);
                     const hour = parseInt(cmd[8], 16) ?? 0;
                     const minutes = parseInt(cmd[9], 16) ?? 0;
                     const seconds = parseInt(cmd[10], 16) ?? 0;

+ 18 - 19
devices/bt_helper.js

@@ -137,18 +137,18 @@ class BtHelper {
         mDevice.volume = volume;
         break;
 
-        ///电量
+      ///电量
       case EnumCmdEvent.battery:
         mDevice.kwh = event.kwh;
         break;
 
-        ///低时延模式  低时延模式开启 1:音乐 , 2: 游戏 , 3: movie
+      ///低时延模式  低时延模式开启 1:音乐 , 2: 游戏 , 3: movie
       case EnumCmdEvent.lowDelayMode:
         mDevice.lowDelayMode = event.lowDelayMode;
         mDevice.lowDelayModeOpen = event.lowDelayModeOpen;
         break;
 
-        ///电量 耳机电量
+      ///电量 耳机电量
       case EnumCmdEvent.batteryEarphone:
         mDevice.kwh = event.kwh;
         mDevice.kwhLeft = event.kwhLeft;
@@ -156,12 +156,12 @@ class BtHelper {
         mDevice.kwhBox = event.kwhBox;
         break;
 
-        ///是否支持TTS
+      ///是否支持TTS
       case EnumCmdEvent.enableTTS:
         mDevice.enableTTS = event.enableTTS;
         break;
 
-        ///切换设备连接模式 0:未知 1:低功耗蓝牙 2:wifi类型 3:经典蓝牙(不做任何操作) 4:4G类型
+      ///切换设备连接模式 0:未知 1:低功耗蓝牙 2:wifi类型 3:经典蓝牙(不做任何操作) 4:4G类型
       case EnumCmdEvent.switchDeviceMode:
         var deviceMode = event.deviceMode.index;
         if (deviceMode != null) {
@@ -170,14 +170,14 @@ class BtHelper {
         }
         break;
 
-        ///4G外插卡  4G虚拟卡 当前使用的sim卡
+      ///4G外插卡  4G虚拟卡 当前使用的sim卡
       case EnumCmdEvent.sim:
         mDevice.sim = event.sim;
         mDevice.eSim = event.eSim;
         mDevice.simIndex = event.simIndex;
         break;
 
-        ///闹钟是否开启  闹钟周期 闹钟唤醒时间
+      ///闹钟是否开启  闹钟周期 闹钟唤醒时间
       case EnumCmdEvent.wake:
         mDevice.wakeSwitch = event.wakeSwitch;
         mDevice.wakeCycle = event.wakeCycle;
@@ -185,14 +185,14 @@ class BtHelper {
         mDevice.wakeMinutes = event.wakeMinutes;
         break;
 
-        ///休眠是否开启 休眠时间
+      ///休眠是否开启 休眠时间
       case EnumCmdEvent.sleep:
         mDevice.sleepSwitch = event.sleepSwitch;
         mDevice.sleepHour = event.sleepHour;
         mDevice.sleepMinutes = event.sleepMinutes;
         break;
 
-        ///版本和型号
+      ///版本和型号
       case EnumCmdEvent.version:
         mDevice.version = event.version;
         var clientType = mDevice.clientType ?? "";
@@ -225,7 +225,7 @@ class BtHelper {
         // }
         break;
 
-        ///云小微授权
+      ///云小微授权
       case EnumCmdEvent.auth:
         var authInfo = event.authInfo;
         mDevice.authInfo = authInfo;
@@ -241,17 +241,17 @@ class BtHelper {
         // });
         break;
 
-        ///EQ音效
+      ///EQ音效
       case EnumCmdEvent.eq:
         mDevice.eqs = event.eqs;
         break;
 
-        ///payId 充流量使用
+      ///payId 充流量使用
       case EnumCmdEvent.payId:
         mDevice.payId = event.payId;
         break;
 
-        ///QQ音乐使用dsn授权
+      ///QQ音乐使用dsn授权
       case EnumCmdEvent.dsn:
         var dsn = event.dsn;
         mDevice.dsn = dsn;
@@ -260,13 +260,13 @@ class BtHelper {
         // ProviderUtil.twelvePublic.wifiDeviceConnected();
         break;
 
-        ///自动切换 0,1不能
-        ///
+      ///自动切换 0,1不能
+      ///
       case EnumCmdEvent.netModeAuto:
         mDevice.netModeAuto = event.netModeAuto;
         break;
 
-        ///解绑设备
+      ///解绑设备
       case EnumCmdEvent.unbind:
         //   let unbindAddress = event.item.address ?? "";
         //     if (unbindAddress != mDevice.address) {
@@ -282,7 +282,7 @@ class BtHelper {
 
         break;
 
-        ///解绑设备
+      ///解绑设备
       case EnumCmdEvent.ctrlStatus:
         // List < int > ctrlList = event.ctrlStatus;
         // if (ctrlList.length == 3) {
@@ -304,7 +304,7 @@ class BtHelper {
         notifyListeners();
         break;
 
-        ///设备信息
+      ///设备信息
       case EnumCmdEvent.getDeviceInfo:
         //   List list = [];
         //   String userId = ProviderUtil.user.userModel.uid ?? "";
@@ -412,7 +412,6 @@ class BtHelper {
         console.log('订阅数据:', charc.uuid);
         // 订阅的
         this.bleManager.notifyCharacteristicValueChange(charc.uuid, (res) => {
-          console.log("dfadsfqweerqewrq====" + JSON.stringify(res));
           BtParse.parseTLV(res);
         })
       }

+ 21 - 23
pages/deviceDetail/detail.js

@@ -14,7 +14,6 @@ Page({
       showCapsule: 1, //是否显示左上角图标   1表示显示    0表示不显示
       title: '设备详情', //导航栏 中间的标题
     },
-    hasNew: false,
     // 页面数据
     device: {},
     btHelper: null,
@@ -24,13 +23,13 @@ Page({
   },
   checkOtaVersion(device) {
     let _this = this;
-          console.log("OTA:", device);
+    console.log("OTA1:", device);
     deviceVersion(device.clientType, device.connectType, device.version).then(res => {
-      console.log("OTA:", res);
+      console.log("OTA2:", res);
       let updateData = res.data ?? {};
       let hasNewVersion = updateData.isEnforcement === 1 || updateData.isEnforcement === 2;
+      updateData.hasNewVersion = hasNewVersion;
       _this.setData({
-        hasNew: hasNewVersion,
         updateData: updateData
       });
     })
@@ -43,21 +42,15 @@ Page({
   },
 
   goToOta: function () {
-    if (this.data.hasNew) {
-      let param = {
-        "device": this.data.device,
-        "otaData": this.data.updateData,
-      }
-      let newParam = JSON.stringify(param);
-      // wx.navigateTo({
-      //   url: '/pages/ota/ota' + "?param=" + param
-      // });
-      route_util.jumpParam('/pages/ota/ota', newParam)
-    } else {
-      wx.showToast({
-        title: '没有新版本',
-      })
+    let param = {
+      "device": this.data.device,
+      "otaData": this.data.updateData,
     }
+    let newParam = JSON.stringify(param);
+    // wx.navigateTo({
+    //   url: '/pages/ota/ota' + "?param=" + param
+    // });
+    route_util.jumpParam('/pages/ota/ota', newParam)
   },
   powerTap(e) {
     console.log(e)
@@ -103,6 +96,8 @@ Page({
     }
     this.setData({
       device: device,
+      powerOpen: (device.pauseSleep ?? -1) > 0
+
     })
 
     const btHelper = BtHelper.getInstance();
@@ -116,13 +111,16 @@ Page({
       switch (name) {
         case EnumCmdEvent.version:
           _this.data.device.version = event.version;
+          console.log("详情页1:", event.version)
+
           _this.checkOtaVersion(_this.data.device);
           break;
-             case EnumCmdEvent.setPauseSleep:
-             let value = event.pauseSleep;
-      _this.setData({
-         powerOpen: (value??-1) > 0
-       })
+        case EnumCmdEvent.setPauseSleep:
+          let value = event.pauseSleep;
+          console.log("详情页2:", value)
+          _this.setData({
+            powerOpen: (value ?? -1) > 0
+          })
           break;
       }
     }, this)

+ 1 - 1
pages/deviceDetail/detail.wxml

@@ -21,7 +21,7 @@
         <view class="item" bindtap="goToOta">
             <view class="left-content">
                 <text class="label">固件信息</text>
-                <view wx:if="{{hasNew}}" class="red"></view>
+                <view wx:if="{{updateData.hasNewVersion}}" class="red"></view>
             </view>
             <image class="arrow" src="../../images/common/icon_arrow.png"></image>
         </view>

+ 45 - 50
pages/ota/ota.js

@@ -1,5 +1,5 @@
 const { BtHelper } = require("../../devices/bt_helper");
-import { EnumCmdEvent } from '../../devices/cmd_key_event';
+import { EnumCmdEvent, CmdEvent } from '../../devices/cmd_key_event';
 import EventManager from '../../utils/event_bus'
 // pages/OTA/ota.js
 Page({
@@ -8,7 +8,7 @@ Page({
    * 页面的初始数据
    */
   data: {
-    nvabarData: {
+    navbarData: {
       showCapsule: 1, //
       title: '固件信息',
     },
@@ -19,6 +19,10 @@ Page({
     otaStatus: 0,
     buttonTips: "固件更新",
     _chunks: [],
+    progressPercent: 0,
+    progress: 0,
+    progressTextLeft: "0%",
+    _timer: null,
   },
   setOtaStatus(status) {
     switch (status) {
@@ -45,6 +49,7 @@ Page({
           otaStatus: 3,
           buttonTips: "更新中..."
         });
+        this.startProgress();
         break;
 
       case 4:
@@ -66,6 +71,15 @@ Page({
       })
       return;
     }
+
+    let hasNewVersion = this.data.otaData.hasNewVersion ?? false
+    if (!hasNewVersion) {
+      wx.showToast({
+        title: '没有可升级的固件',
+      })
+      return;
+    }
+
     let _this = this
     wx.showModal({
       title: '有新固件可升级',
@@ -204,6 +218,7 @@ Page({
     this.data._chunks.forEach(element => {
       btHelper.otaData(element)
     });
+    this.startProgress()
   },
   endEnd() {
     const btHelper = BtHelper.getInstance();
@@ -231,6 +246,34 @@ Page({
       }
     }, 500);
   },
+  startProgress: function () {
+    const _this = this;
+    let progress = 0;
+    // 定时器,每100毫秒执行一次
+    _this._timer = setInterval(function () {
+      if (progress >= 100) {
+        clearInterval(_this._timer); // 停止定时器
+        _this.setData({
+          progress: 0,
+          progressPercent: 0,
+          showProgress: false,
+        });
+        _this.data.otaData.hasNewVersion = false;
+        _this.setOtaStatus(0)
+        wx.showToast({
+          title: '数据上传成功',
+        })
+      } else {
+        progress += 1; // 每次增加1%
+        let ptl = (progress / 2) + "%"
+        _this.setData({
+          progress: progress,
+          progressPercent: progress,
+          progressTextLeft:ptl  // 文字位置跟随进度     
+        });
+      }
+    }, 100);
+  },
   /**
    * 生命周期函数--监听页面加载
    */
@@ -268,52 +311,4 @@ Page({
 
   },
 
-  /**
-   * 生命周期函数--监听页面初次渲染完成
-   */
-  onReady() {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面显示
-   */
-  onShow() {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面隐藏
-   */
-  onHide() {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面卸载
-   */
-  onUnload() {
-    EventManager.removeNotification(CmdEvent.eventName, this);
-  },
-
-  /**
-   * 页面相关事件处理函数--监听用户下拉动作
-   */
-  onPullDownRefresh() {
-
-  },
-
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom() {
-
-  },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage() {
-
-  }
 })

+ 10 - 5
pages/ota/ota.wxml

@@ -1,6 +1,6 @@
 <!-- pages/OTA/ota.wxml -->
 <view class="section">
-    <nav-bar bind:goBack="_goBack" nav-bgc-class="ex-nav-bgc-class" nav-title-class="ex-nav-title-class" ex-back-pre="ex-back-pre" navbar-data='{{nvabarData}}'></nav-bar>
+    <nav-bar bind:goBack="_goBack" nav-bgc-class="ex-nav-bgc-class" nav-title-class="ex-nav-title-class" ex-back-pre="ex-back-pre" navbar-data='{{navbarData}}'></nav-bar>
     <view style="height: 32rpx;"></view>
     <view class="item">
         <text class="label">制造商</text>
@@ -16,11 +16,16 @@
     </view>
     <view class="button main_color" bind:tap="startOtaTap">{{buttonTips}}</view>
 </view>
-<view wx:if="{{otaStatus === 3}}" class="container">
-    <view class="background"></view>
+<view wx:if="{{otaStatus === 3}}" class="background">
     <view class="content">
-        <view class="progress-bar-container">
-            <view class="progress-bar" style="width: {{progress}}%;"></view>
+        <view class="pro_title">正在升级</view>
+        <view class="progress-container">
+            <progress class="progress" percent="{{progress}}" activeColor="#6546A3" backgroundColor="rgba(101,70,163,0.16)" stroke-width="26" border-radius="13" />
+            <view class="progress-text" style="left: {{progressTextLeft}};">
+                {{progressPercent}}%
+            </view>
         </view>
+        <view class="pro_tips">升级过程中请勿离开当前页面
+建议保持设备电量20%已上进行升级操作</view>
     </view>
 </view>

+ 48 - 22
pages/ota/ota.wxss

@@ -39,37 +39,63 @@
 
 
 .background {
-	position: absolute;
+	position: fixed;
 	top: 0;
 	left: 0;
-	width: 100%;
-	height: 100%;
+	right: 0;
+	bottom: 0;
 	background-color: rgba(0, 0, 0, 0.7);
-	/* 半透明黑色背景 */
+	display: flex;
+	justify-content: center;
+	align-items: center;
+	z-index: 1000;
 }
 
 .content {
-	width: 450rpx;
-	height: 450rpx;
 	background-color: white;
-	border-radius: 20rpx;
-	display: flex;
-	justify-content: center;
-	align-items: center;
-	box-shadow: 0 0 20rpx rgba(0, 0, 0, 0.3);
+	padding-inline: 20px;
+	border-radius: 10px;
+	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
+	width: 558rpx;
+	height: 404rpx;
 }
 
-.progress-bar-container {
-	width: 90%;
-	height: 20rpx;
-	background-color: #e0e0e0;
-	border-radius: 10rpx;
-	overflow: hidden;
+.pro_title {
+	font-weight: 500;
+	font-size: 32rpx;
+	color: #333333;
+	text-align: center;
+	font-style: normal;
+	margin-top: 64rpx;
 }
 
-.progress-bar {
-	height: 100%;
-	background-color: #4caf50;
-	/* 进度条颜色 */
-	transition: width 0.3s ease-in-out;
+.progress-container {
+	position: relative;
+	margin-inline: 32rpx;
+	margin-top: 46rpx;
+	/* 根据需要调整 */
+}
+
+.progress {
+	width: 100%;
+	height: 32rpx;
+}
+
+.progress-text {
+	position: absolute;
+	top: 50%;
+	transform: translateY(-50%);
+	color: white;
+	font-size: 16px;
+	z-index: 1;
+	white-space: nowrap;
+}
+
+.pro_tips {
+	margin-top: 48rpx;
+	margin-inline: 34rpx;
+	font-size: 28rpx;
+	color: #666666;
+	text-align: center;
+	font-style: normal;
 }

+ 38 - 18
pages/piano/wallpaper/wallpaper.js

@@ -28,11 +28,11 @@ Page({
 
     ],
     selectIndex: 0,
-    nvabarData: {
+    navbarData: {
       showCapsule: 1, //是否显示左上角图标   1表示显示    0表示不显示
       title: '壁纸设置', //导航栏 中间的标题
       callback() {
-        if (_imageBuffer) {
+        if (this._imageBuffer) {
           wx.showModal({
             title: '保存图片中,确定要中断退出吗?',
             content: '',
@@ -51,18 +51,22 @@ Page({
             delta: 1,
           })
         }
-
       }
     },
     src: '',
-    showCrop: false,
+    showProgress: false,
     width: 250,//宽度
     height: 250,//高度
     _imageBuffer: null,
-    progressPercent: 60,
-    intervalId: 60,
+    progressPercent: 0,
+    _timer: null,
+
+  },
+  closePage() {
+
 
-  }, footerTap() {
+  },
+  footerTap() {
     const that = this;
 
     wx.chooseMedia({
@@ -189,32 +193,48 @@ Page({
   sendImage(imageBuffer) {
     let chunkSize = 20;
     let _this = this
-    let progress = 0;
 
     _this.setData({
       progress: 0,
       progressPercent: 0
     });
 
+
+
+    for (let i = 0; i < imageBuffer.length; i += chunkSize) {
+      const chunk = imageBuffer.slice(i, i + chunkSize);
+      BtHelper.wallPaperData(chunk)
+    }
+  },
+  endImage() {
+    BtHelper.sendData(BtCmd.wallPaper(0));
+  },
+  startProgress() {
+    let _this = this;
+    this.setData({
+      showProgress: true
+    })
     // 定时器,每100毫秒执行一次
-    _this.intervalId = setInterval(function () {
+    let progress = 0;
+    _this._timer = setInterval(function () {
       if (progress >= 100) {
-        clearInterval(_this.intervalId); // 停止定时器
+        clearInterval(_this._timer); // 停止定时器
+        _this.setData({
+          progress: 0,
+          progressPercent: 0,
+          showProgress: false,
+        });
+        wx.showToast({
+          title: '图片上传成功',
+        })
       } else {
         progress += 1; // 每次增加1%
         _this.setData({
+          progress:progress,
           progressPercent: progress
         });
       }
     }, 100);
-
-    for (let i = 0; i < imageBuffer.length; i += chunkSize) {
-      const chunk = imageBuffer.slice(i, i + chunkSize);
-      BtHelper.wallPaperData(chunk)
-    }
-  },
-  endImage() {
-    BtHelper.sendData(BtCmd.wallPaper(0));
   },
   /**
    * 生命周期函数--监听页面加载

+ 4 - 4
pages/piano/wallpaper/wallpaper.wxml

@@ -1,6 +1,6 @@
 <!-- pages/piano/wallpaper/wallpaper.wxml -->
 <view class="container">
-    <nav-bar bind:goBack="_goBack" nav-bgc-class="ex-nav-bgc-class" nav-title-class="ex-nav-title-class" ex-back-pre="ex-back-pre" navbar-data='{{nvabarData}}'></nav-bar>
+    <nav-bar bind:goBack="_goBack" nav-bgc-class="ex-nav-bgc-class" nav-title-class="ex-nav-title-class" ex-back-pre="ex-back-pre" navbar-data='{{navbarData}}'></nav-bar>
     <view wx:if="{{imageList.length>0}}" class="img_section">
         <image src="{{topImg.pic}}" class="select_img"></image>
         <image src="../../../images/common/icon_sel.png" class="select_icon"></image>
@@ -19,9 +19,9 @@
         <button catchtap='updateImage'>更换照片</button>
         <button type="primary" bindtap='submit'>确定裁剪</button>
     </view> -->
-    <image-cropper bind:close="hideCut" cutRatio="1" wx:if="{{showCrop}}" imageSrc="{{imageSrc}}" />
-    <view class="progress-container">
-        <progress class="progress" percent="{{progress}}" duration="100" activeColor="#6546A3" backgroundColor="rgba(0,0,0,0.4)" stroke-width="26" border-radius="13" />
+    <!-- <image-cropper bind:close="hideCut" cutRatio="1" wx:if="{{showCrop}}" imageSrc="{{imageSrc}}" /> -->
+    <view wx:if="{{showProgress}}" class="progress-container">
+        <progress class="progress"  percent="{{progress}}" activeColor="#6546A3" backgroundColor="rgba(0,0,0,0.4)" stroke-width="26" border-radius="13" />
         <view class="progress-text">保存壁纸中…{{progressPercent}}%</view>
     </view>
 </view>