Prechádzať zdrojové kódy

feature:增加OTA的进度条

zeng.chen 8 mesiacov pred
rodič
commit
ec18e0a58d

+ 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

@@ -155,18 +155,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;
@@ -174,12 +174,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) {
@@ -188,14 +188,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;
@@ -203,14 +203,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 ?? "";
@@ -243,7 +243,7 @@ class BtHelper {
         // }
         break;
 
-        ///云小微授权
+      ///云小微授权
       case EnumCmdEvent.auth:
         var authInfo = event.authInfo;
         mDevice.authInfo = authInfo;
@@ -259,17 +259,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;
@@ -278,13 +278,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) {
@@ -300,7 +300,7 @@ class BtHelper {
 
         break;
 
-        ///解绑设备
+      ///解绑设备
       case EnumCmdEvent.ctrlStatus:
         // List < int > ctrlList = event.ctrlStatus;
         // if (ctrlList.length == 3) {
@@ -322,7 +322,7 @@ class BtHelper {
         notifyListeners();
         break;
 
-        ///设备信息
+      ///设备信息
       case EnumCmdEvent.getDeviceInfo:
         //   List list = [];
         //   String userId = ProviderUtil.user.userModel.uid ?? "";
@@ -430,7 +430,6 @@ class BtHelper {
         console.log('订阅数据:', charc.uuid);
         // 订阅的
         this.bleManager.notifyCharacteristicValueChange(charc.uuid, (res) => {
-          console.log("dfadsfqweerqewrq====" + JSON.stringify(res));
           BtParse.parseTLV(res);
         })
       }

+ 11 - 6
pages/deviceDetail/detail.js

@@ -24,7 +24,7 @@ Page({
   },
   checkOtaVersion(device) {
     let _this = this;
-          console.log("OTA:", device);
+    console.log("OTA:", device);
     deviceVersion(device.clientType, device.connectType, device.version).then(res => {
       console.log("OTA:", res);
       let updateData = res.data ?? {};
@@ -103,6 +103,8 @@ Page({
     }
     this.setData({
       device: device,
+      powerOpen: (device.pauseSleep ?? -1) > 0
+
     })
 
     const btHelper = BtHelper.getInstance();
@@ -116,13 +118,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)

+ 6 - 2
pages/ota/ota.wxml

@@ -19,8 +19,12 @@
 <view wx:if="{{otaStatus === 3}}" class="container">
     <view class="background"></view>
     <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}}" duration="100" activeColor="#6546A3" backgroundColor="rgba(0,0,0,0.4)" stroke-width="26" border-radius="13" />
+            <view class="progress-text">保存壁纸中…{{progressPercent}}%</view>
         </view>
+        <view class="pro_tips">升级过程中请勿离开当前页面
+建议保持设备电量20%已上进行升级操作</view>
     </view>
 </view>

+ 36 - 14
pages/ota/ota.wxss

@@ -49,27 +49,49 @@
 }
 
 .content {
-	width: 450rpx;
-	height: 450rpx;
+	width: 558rpx;
+	height: 404rpx;
 	background-color: white;
-	border-radius: 20rpx;
+	border-radius: 24rpx;
 	display: flex;
 	justify-content: center;
 	align-items: center;
 	box-shadow: 0 0 20rpx rgba(0, 0, 0, 0.3);
 }
 
-.progress-bar-container {
-	width: 90%;
-	height: 20rpx;
-	background-color: #e0e0e0;
-	border-radius: 10rpx;
-	overflow: hidden;
+.progress-container {
+	position: relative;
+	margin-inline: 56rpx;
+	margin-top: 615rpx;
 }
 
-.progress-bar {
-	height: 100%;
-	background-color: #4caf50;
-	/* 进度条颜色 */
-	transition: width 0.3s ease-in-out;
+.pro_title {
+	font-weight: 500;
+	font-size: 32rpx;
+	color: #333333;
+	text-align: center;
+	font-style: normal;
+}
+
+.pro_tips {
+	margin-inline: 34rpx;
+	font-size: 28rpx;
+	color: #666666;
+	text-align: center;
+	font-style: normal;
+}
+
+.progress {
+	width: 100%;
+}
+
+.progress-text {
+	position: absolute;
+	top: 50%;
+	left: 50%;
+	transform: translate(-50%, -50%);
+	color: white;
+	font-size: 24rpx;
+	z-index: 1;
+	font-weight: 500;
 }

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

@@ -32,37 +32,41 @@ Page({
       showCapsule: 1, //是否显示左上角图标   1表示显示    0表示不显示
       title: '壁纸设置', //导航栏 中间的标题
       callback() {
-        if (_imageBuffer) {
-          wx.showModal({
-            title: '保存图片中,确定要中断退出吗?',
-            content: '',
-            complete: (res) => {
-              if (res.cancel) {
-
-              }
-
-              if (res.confirm) {
-                BtHelper.getInstance().endImage(0)
-              }
-            }
-          })
-        } else {
-          wx.navigateBack({
-            delta: 1,
-          })
-        }
-
+        this.closePage()
       }
     },
     src: '',
-    showCrop: false,
+    showProgress: false,
     width: 250,//宽度
     height: 250,//高度
     _imageBuffer: null,
-    progressPercent: 60,
-    intervalId: 60,
+    progressPercent: 0,
+    _timer: null,
+
+  }, 
+  closePage(){
+    if (_imageBuffer) {
+      wx.showModal({
+        title: '保存图片中,确定要中断退出吗?',
+        content: '',
+        complete: (res) => {
+          if (res.cancel) {
+
+          }
+
+          if (res.confirm) {
+            BtHelper.getInstance().endImage(0)
+          }
+        }
+      })
+    } else {
+      wx.navigateBack({
+        delta: 1,
+      })
+    }
 
-  }, footerTap() {
+  },
+  footerTap() {
     const that = this;
 
     wx.chooseMedia({
@@ -197,9 +201,17 @@ Page({
     });
 
     // 定时器,每100毫秒执行一次
-    _this.intervalId = setInterval(function () {
+    _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({

+ 3 - 3
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,8 +19,8 @@
         <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">
+    <!-- <image-cropper bind:close="hideCut" cutRatio="1" wx:if="{{showCrop}}" imageSrc="{{imageSrc}}" /> -->
+    <view wx:if="{{showProgress}}" 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" />
         <view class="progress-text">保存壁纸中…{{progressPercent}}%</view>
     </view>