Browse Source

feature:还原设备模式的选择功能

zeng.chen 7 months ago
parent
commit
2392448c47
2 changed files with 19 additions and 10 deletions
  1. 18 8
      pages/deviceConMode/index.js
  2. 1 2
      pages/deviceConMode/index.wxml

+ 18 - 8
pages/deviceConMode/index.js

@@ -16,7 +16,7 @@ Page({
       title: '配网模式选择', //导航栏 中间的标题
     },
     isNotruter: false,
-    model: 0,
+    model: "",
     connectDevice: {},
     typeList: [{
       "icon": "../../images/device/mode_2.png",
@@ -39,11 +39,11 @@ Page({
   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;
@@ -98,6 +98,7 @@ Page({
     });
     this.setData({
       typeList: list,
+      model: this.getModeName(device)
     })
 
   },
@@ -112,12 +113,21 @@ Page({
       })
       return;
     }
+
+    let _typeList = json.typeList.map(e => {
+      return {
+        icon: "../../images/device/mode_" + e.type + ".png",
+        text: this.getModeName(e),
+        type: e.type
+      }
+    })
+
     var list = []
-    var typeList = device.typeList.map(element => {
-      return element.connectType;
-    });
+    console.log(this.data.typeList)
+    console.log(_typeList)
+
     this.data.typeList.forEach(element => {
-      if (typeList.find(type => type === element.type)) {
+      if (_typeList.find(_type => _type.type === element.type)) {
         list.push(element)
       }
     });

+ 1 - 2
pages/deviceConMode/index.wxml

@@ -5,8 +5,7 @@
   <image class="model_bg" src="../../images/device/mode_bg.png" mode="aspectFill" />
   <view class="select_tips">
     <view class="setDeviceModel main_green">开启设备选择{{model}}</view>
-    <view class="setDeviceModelTips">开启后点击“下一步”</view>
-    <view class="deviceList">
+    <view wx:if="{{typeList.length > 0}}" class="deviceList">
       <block wx:for="{{typeList}}" wx:key="item">
         <view class="devicePicItem devicePicItem_{{index}}" bindtap="selectDeviceModelTap" data-device="{{item}}">
           <image class="select_icon" src="{{index === 0 ? '../../images/device/pay_select.png' : '../../images/device/wake_select_no.png'}}"></image>