Browse Source

feature:修改多次弹框的问题

zeng.chen 6 months ago
parent
commit
5870c80e5d
3 changed files with 34 additions and 5 deletions
  1. 20 0
      pages/ota/ota.js
  2. 6 4
      pages/piano/cropper/cropper.js
  3. 8 1
      pages/piano/wallpaper/wallpaper.js

+ 20 - 0
pages/ota/ota.js

@@ -439,6 +439,16 @@ Page({
             // _this.sendOtaCmd(0)
             _this.otaSuccess()
             // BtHelper.getInstance().otaUrl(BtCmd.stringToUint8Array(_this.data._otaData.url))
+          } else if (otaCmd === 0 && kind == 3) {
+            wx.showModal({
+              title: 'OTA升级失败,请重启设备再试试吧',
+              showCancel: false,
+              success: function (res) {
+                if (res.confirm) {
+                  console.log('用户点击确定')
+                }
+              }
+            })
           } else {
             _this.otaFailure()
           }
@@ -453,6 +463,16 @@ Page({
               mask: true
             });
             _this.sendUrlData()
+          } else if (otaCmd === 0 && kind == 3) {
+            wx.showModal({
+              title: 'OTA升级失败,请重启设备再试试吧',
+              showCancel: false,
+              success: function (res) {
+                if (res.confirm) {
+                  console.log('用户点击确定')
+                }
+              }
+            })
           } else {
             // wifi失败
             _this.otaFailure()

+ 6 - 4
pages/piano/cropper/cropper.js

@@ -5,6 +5,7 @@ import EventManager from '../../../utils/event_bus'
 import { EnumCmdEvent, CmdEvent } from '../../../devices/cmd_key_event';
 import js_md5 from '../../../utils/js_md5';
 import store from '../../../utils/store';
+import route_util from '../../../utils/route_util';
 const { BtHelper } = require('../../../devices/bt_helper');
 
 Page({
@@ -34,6 +35,7 @@ Page({
     _imgNext: 0,
     max_scale: 2,
     _hasPermission: false,
+    _hasShowModal: false,
     wallpaper: {},
   },
   cropper: null,
@@ -518,16 +520,16 @@ Page({
   disconnect(event) {
     let _this = this;
     console.log("断开连接", event.commonValue, event.deviceId);
-    if (event.commonValue === "offline") {
+    if (event.commonValue === "offline" && !_this.data._hasShowModal) {
+      _this.data._hasShowModal = true
       wx.showModal({
         title: '提示',
         content: '设备断开连接,请重新连接设备',
         showCancel: false,
         success: function (res) {
+          _this.data._hasShowModal = false;
           if (res.confirm) {
-            wx.navigateBack({
-              delta: 1
-            })
+            route_util.goBackHomePage()
           }
         }
       })

+ 8 - 1
pages/piano/wallpaper/wallpaper.js

@@ -109,6 +109,13 @@ Page({
     let newImg = {
       "pic": topUrl, "id": "0"
     }
+    let myImgList = store.getStore(_this.data._localImgPicKey)
+    myImgList = myImgList ?? []
+    let myIndex = myImgList.findIndex(img => img.pic === findImg.pic);
+    if (myIndex < 0) {
+      myImgList.unshift(newImg)
+    }
+
     let imgList = _this.data._locImageList
     console.log("updateTopImg1", imgList)
     let findImg = imgList.find(function (img) { return img.pic === topUrl })
@@ -131,7 +138,7 @@ Page({
       image4List: _this.data._locImageList.slice(0, 4),
       topImg: newImg
     })
-    store.setStore(_this.data._localImgPicKey, imgList)
+    store.setStore(_this.data._localImgPicKey, myImgList)
     // }
   },
   hideCut(e) {