소스 검색

feature:修改设备模式的选择功能

zeng.chen 7 달 전
부모
커밋
f610d45c1e
1개의 변경된 파일31개의 추가작업 그리고 18개의 파일을 삭제
  1. 31 18
      pages/deviceConMode/index.js

+ 31 - 18
pages/deviceConMode/index.js

@@ -19,20 +19,20 @@ Page({
     model: 0,
     connectDevice: {},
     typeList: [{
-        "icon": "../../images/device/mode_2.png",
-        "text": "WiFi模式",
-        "type": 2,
-      },
-      {
-        "icon": "../../images/device/mode_1.png",
-        "text": "蓝牙模式",
-        "type": 1,
-      },
-      {
-        "icon": "../../images/device/mode_4.png",
-        "text": "4G模式",
-        "type": 4,
-      },
+      "icon": "../../images/device/mode_2.png",
+      "text": "WiFi模式",
+      "type": 2,
+    },
+    {
+      "icon": "../../images/device/mode_1.png",
+      "text": "蓝牙模式",
+      "type": 1,
+    },
+    {
+      "icon": "../../images/device/mode_4.png",
+      "text": "4G模式",
+      "type": 4,
+    },
     ],
   },
 
@@ -103,16 +103,29 @@ Page({
   },
 
   onLoad: function (options) {
-    let json = JSON.parse(options.param)
+    let json = JSON.parse(options.param) || {}
     console.log(json)
     let device = json
+    if (Object.keys(device).length === 0) {
+      wx.showToast({
+        title: '设备数据为空,返回刷新列表试试看',
+      })
+      return;
+    }
+    var list = []
+    var typeList = device.typeList.map(element => {
+      return element.connectType;
+    });
+    this.data.typeList.forEach(element => {
+      if (typeList.find(type => type === element.type)) {
+        list.push(element)
+      }
+    });
     this.setData({
+      typeList: list,
       connectDevice: device
     })
 
-    if (getApp().globalData.isIOS) {
-
-    } else {}
   },
 
 })