Selaa lähdekoodia

feature:动态配置连接模式

zeng.chen 8 kuukautta sitten
vanhempi
commit
b809b09e27
4 muutettua tiedostoa jossa 20 lisäystä ja 23 poistoa
  1. 0 0
      images/device/mode_1.png
  2. 0 0
      images/device/mode_2.png
  3. 0 0
      images/device/mode_4.png
  4. 20 23
      pages/deviceConMode/index.js

images/device/mode_ble.png → images/device/mode_1.png


images/device/mode_wifi.png → images/device/mode_2.png


images/device/mode_g4.png → images/device/mode_4.png


+ 20 - 23
pages/deviceConMode/index.js

@@ -16,41 +16,27 @@ Page({
       title: '连接配网', //导航栏 中间的标题
     },
     isNotruter: false,
-    model: 0,
+    model: "",
     connectDevice: {},
     typeList: [
-      {
-        "icon": "../../images/device/mode_wifi.png",
-        "text": "WiFi模式",
-        "type": 2,
-      },
-      {
-        "icon": "../../images/device/mode_ble.png",
-        "text": "蓝牙模式",
-        "type": 1,
-      },
-      {
-        "icon": "../../images/device/mode_g4.png",
-        "text": "4G模式",
-        "type": 4,
-      },
+
     ],
   },
   getModeName(curItem) {
     // 设备类型:1-蓝牙,2-Wifi,3-传统蓝牙,4-4G
     var str = "";
-    if (curItem.deviceMode == 4) {
+    if (curItem.type == 4) {
       str = "移动数据模式";
-    } else if (curItem.deviceMode == 2) {
+    } else if (curItem.type == 2) {
       str = "WiFi模式";
-    } else if (curItem.deviceMode == 1) {
+    } else if (curItem.type == 1) {
       str = "蓝牙模式";
     }
     return str;
   },
   nextTap(e) {
     let device = this.data.typeList[0];
-    let type = device.type ?? 0;
+    let type = device.connectType ?? 0;
     console.log("选择模式", type)
     if (type == 1) {
       // let device = e.currentTarget.dataset.data
@@ -69,7 +55,7 @@ Page({
   async selectDeviceModelTap(e) {
     let device = e.currentTarget.dataset.device;
     // console.log(e)
-    let type = device.type;
+    let type = device.connectType;
     if (type == 1) {
       // this.getConnectedDevices()
     } else if (type == 2) {
@@ -82,12 +68,13 @@ Page({
     var list = []
     list.push(device)
     this.data.typeList.forEach(element => {
-      if (element.type != type) {
+      if (element.connectType != type) {
         list.push(element)
       }
     });
     this.setData({
       typeList: list,
+      model: this.getModeName(device.typeList)
     })
 
   },
@@ -96,8 +83,18 @@ Page({
     let json = JSON.parse(options.param)
     console.log(json)
     let device = json
+
+    let typeList = json.typeList.map(e => {
+      return {
+        icon: "../../images/device/mode_" + e.connectType + ".png",
+        text: this.getModeName(e),
+        connectType: e.connectType
+      }
+    })
+
     this.setData({
-      connectDevice: device
+      connectDevice: device,
+      typeList: typeList
     })
 
     if (getApp().globalData.isIOS) {