瀏覽代碼

feature: 加入设备设置ota数据分包

332777428@qq.com 4 月之前
父節點
當前提交
af4649e942

+ 1 - 1
app.json

@@ -3,7 +3,6 @@
     "pages/pageA/index/index",
     "pages/pageA/login/login",
     "pages/pageA/deviceList/deviceList",
-    "pages/setWifi/setWifi",
     "pages/vipPurchase/vipPurchase",
     "pages/vipRecord/vipRecord",
     "pages/vipDetail/vipDetail"
@@ -36,6 +35,7 @@
       "root": "pages/pageD/",
       "pages": [
         "ota/ota",
+        "setWifi/setWifi",
         "webview/webview",
         "download/download"
       ]

+ 20 - 13
pages/pageD/ota/ota.js

@@ -1,9 +1,17 @@
-const { BtHelper } = require("../../../devices/bt_helper");
-import { EnumCmdEvent, CmdEvent } from '../../../devices/cmd_key_event';
+const {
+  BtHelper
+} = require("../../../devices/bt_helper");
+import {
+  EnumCmdEvent,
+  CmdEvent
+} from '../../../devices/cmd_key_event';
 import eventBus from '../../../utils/eventBus'
 import routeUtil from '../../../utils/routeUtil';
 import routePath from '../../../utils/routePath.js';
-import { BtCmd } from '../../../devices/bluetooth/bt_cmd.js';
+import routeRoot from '../../../utils/routeRoot.js';
+import {
+  BtCmd
+} from '../../../devices/bluetooth/bt_cmd.js';
 import strings from '../../../utils/strings.js';
 const {
   deviceVersion
@@ -182,14 +190,14 @@ Page({
         } else {
           _this.downloadOtaFile(urlPath, localPath)
         }
-      }, fail(err) {
+      },
+      fail(err) {
         // 文件不存在或其他错误
         console.log(err)
         // 文件不存在,开始下载
         _this.downloadOtaFile(urlPath, localPath)
       }
-    }
-    );
+    });
   },
   downloadOtaFile(urlPath, localPath) {
     let _this = this;
@@ -302,7 +310,8 @@ Page({
     }
     _this.sendOtaData(this.data._chunks, 0)
     // }
-  }, sendOtaData(imageBuffer, index) {
+  },
+  sendOtaData(imageBuffer, index) {
     let _this = this
 
     if (index >= imageBuffer.length) {
@@ -365,15 +374,14 @@ Page({
     }
   },
   otaSuccess() {
-
     var pages = getCurrentPages();
     var length = pages.length;
     var currentPage = pages[length - 1];
-    console.log("currentPage==", currentPage.route)
-    if (currentPage.route == "pages/setWifi/setWifi") {
-      console.log("currentPage==222", currentPage.route)
+
+    if (currentPage.route == routeRoot.setWifi) {
       currentPage.wifiPageSuccess()
     }
+
     wx.hideLoading();
     // 流程成功
     wx.showModal({
@@ -427,8 +435,7 @@ Page({
             _this.otaFailure()
           } else if (otaCmd === 0 && kind == 1) {
             _this.otaSuccess()
-          }
-          else if (kind == 0) {
+          } else if (kind == 0) {
 
           }
           break;

+ 7 - 8
pages/setWifi/setWifi.js

@@ -1,16 +1,15 @@
-// pages/setWifi/setWifi.js
 const {
   BtHelper
-} = require("../../devices/bt_helper");
-import eventBus from '../../utils/eventBus'
+} = require("../../../devices/bt_helper");
+import eventBus from '../../../utils/eventBus'
 import {
   EnumCmdEvent,
   CmdEvent
-} from '../../devices/cmd_key_event';
-import store from '../../utils/store';
+} from '../../../devices/cmd_key_event';
+import store from '../../../utils/store';
 import {
   BtCmd
-} from '../../devices/bluetooth/bt_cmd';
+} from '../../../devices/bluetooth/bt_cmd';
 Page({
   data: {
     navbarData: {
@@ -21,7 +20,7 @@ Page({
     wifiName: '',
     wifiPassword: '',
     _otaUrl: "",
-    eyeIconSrc: '../../img/yj0.png',
+    eyeIconSrc: '../../../img/yj0.png',
     passwordType: true,
     _onNavigateBack: false,
 
@@ -123,7 +122,7 @@ Page({
   togglePasswordVisibility: function () {
     const passwordType = !this.data.passwordType;
     // const newType = currentType === 'password' ? 'text' : 'password';
-    const newIconSrc = passwordType ? '../../img/yj0.png' : '../../img/yj1.png';
+    const newIconSrc = passwordType ? '../../../img/yj0.png' : '../../../img/yj1.png';
 
     this.setData({
       passwordType: passwordType,

+ 5 - 0
pages/pageD/setWifi/setWifi.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+    "nav-bar": "./../../../components/navbar/navbar"
+  }
+}

+ 23 - 0
pages/pageD/setWifi/setWifi.wxml

@@ -0,0 +1,23 @@
+<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" bind:callback="callback" navbarData='{{navbarData}}'></nav-bar>
+<view class="container">
+  <view class="wifi_icon">
+    <image src="../../../images/common/wifi.png" mode="aspectFit"></image>
+  </view>
+  <view class="title">配置设备Wi-Fi</view>
+  <view class="input-group">
+    <view class="input-with-icon">
+      <image class="icon" src="../../../images/common/wifi_icon.png" mode="aspectFit"></image>
+      <input class="input" type="text" placeholder="请输入Wi-Fi名称" value="{{wifiName}}" bindinput="onWifiNameInput" />
+    </view>
+  </view>
+  <view class="input-group">
+    <view class="input-with-icon">
+      <image class="icon" src="../../../images/common/lock.png" mode="aspectFit"></image>
+      <!-- <input class="input" type="{{passwordType}}" placeholder="请输入密码" value="{{wifiPassword}}" bindinput="onWifiPasswordInput" /> -->
+      <input class="input" password="{{passwordType}}" bindinput="onWifiPasswordInput" bindfocus="onFocus" bindblur="onBlur" placeholder="请输入WiFi密码" value="{{wifiPassword}}" />
+      <image class="eye-icon" src="{{eyeIconSrc}}" mode="aspectFit" bindtap="togglePasswordVisibility"></image>
+    </view>
+  </view>
+  <view class="title_tips">不支持5G、酒店、机场等需要认证的WI-FI网络</view>
+  <view class="confirm-button" bindtap="onConfirm">确认</view>
+</view>

+ 0 - 1
pages/setWifi/setWifi.wxss

@@ -1,4 +1,3 @@
-/* pages/setWifi/setWifi.wxss */
 .container {
     padding-inline: 20rpx;
 }

+ 0 - 5
pages/setWifi/setWifi.json

@@ -1,5 +0,0 @@
-{
-  "usingComponents": {
-    "nav-bar": "./../../components/navbar/navbar"
-  }
-}

+ 0 - 24
pages/setWifi/setWifi.wxml

@@ -1,24 +0,0 @@
-<!-- pages/setWifi/setWifi.wxml -->
-<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" bind:callback="callback" navbarData='{{navbarData}}'></nav-bar>
-<view class="container">
-    <view class="wifi_icon">
-        <image src="../../images/common/wifi.png" mode="aspectFit"></image>
-    </view>
-    <view class="title">配置设备Wi-Fi</view>
-    <view class="input-group">
-        <view class="input-with-icon">
-            <image class="icon" src="../../images/common/wifi_icon.png" mode="aspectFit"></image>
-            <input class="input" type="text" placeholder="请输入Wi-Fi名称" value="{{wifiName}}" bindinput="onWifiNameInput" />
-        </view>
-    </view>
-    <view class="input-group">
-        <view class="input-with-icon">
-            <image class="icon" src="../../images/common/lock.png" mode="aspectFit"></image>
-            <!-- <input class="input" type="{{passwordType}}" placeholder="请输入密码" value="{{wifiPassword}}" bindinput="onWifiPasswordInput" /> -->
-            <input class="input" password="{{passwordType}}" bindinput="onWifiPasswordInput" bindfocus="onFocus" bindblur="onBlur" placeholder="请输入WiFi密码" value="{{wifiPassword}}" />
-            <image class="eye-icon" src="{{eyeIconSrc}}" mode="aspectFit" bindtap="togglePasswordVisibility"></image>
-        </view>
-    </view>
-    <view class="title_tips">不支持5G、酒店、机场等需要认证的WI-FI网络</view>
-    <view class="confirm-button" bindtap="onConfirm">确认</view>
-</view>

+ 2 - 1
utils/routePath.js

@@ -24,6 +24,7 @@ const channelDetail = "../../pageC/channelDetail/channelDetail";
 
 /// pageD
 const ota = "../../pageD/ota/ota";
+const setWifi = "../../pageD/setWifi/setWifi";
 const webview = "../../pageD/webview/webview";
 const download = "../../pageC/download/download";
 
@@ -34,7 +35,6 @@ const deviceDetail = "../../piano/deviceDetail/deviceDetail";
 
 /// 抽奖记录
 const connectMode = "../deviceConMode/index";
-const setWifi = "../setWifi/setWifi";
 
 module.exports = {
   /// A
@@ -58,6 +58,7 @@ module.exports = {
   channelDetail: channelDetail,
   /// D
   ota: ota,
+  setWifi: setWifi,
   webview: webview,
   download: download,
 

+ 5 - 0
utils/routeRoot.js

@@ -8,6 +8,9 @@ const login = "pages/pageA/login/login";
 const deviceWake = "pages/pageB/deviceWake/deviceWake";
 const connectBle = "pages/pageB/connectBle/connectBle";
 
+/// D
+const setWifi = "pages/pageD/setWifi/setWifi";
+
 
 module.exports = {
   /// A
@@ -16,4 +19,6 @@ module.exports = {
   /// B
   deviceWake: deviceWake,
   connectBle: connectBle,
+  /// D
+  setWifi: setWifi,
 }