Ver código fonte

feature: 蓝牙设备和wifi设备用connectType来区分

Damon 8 meses atrás
pai
commit
90eac0fc68
2 arquivos alterados com 13 adições e 17 exclusões
  1. 11 15
      pages/index/index.js
  2. 2 2
      pages/index/index.wxml

+ 11 - 15
pages/index/index.js

@@ -509,8 +509,8 @@ Page({
   onTapItem(e) {
     var that = this;
     var item = e.currentTarget.dataset.item;
-    var ProdModel = item.ProdModel;
-    if (ProdModel == "MW-2AX(WIFI-N)") {
+    var connectType = item.connectType;
+    if (connectType == 3) {
       if (e.currentTarget.dataset.index === that.data.deviceListIndex) {
         that.goWake();
       } else {
@@ -590,7 +590,7 @@ Page({
       title: '确定删除?',
       success: function (res) {
         if (res.confirm) {
-          if (that.data.deviceList[e.currentTarget.dataset.index].ProdModel != "MW-2AX(WIFI-N)") {
+          if (that.data.deviceList[e.currentTarget.dataset.index].connectType != 3) {
             const id = that.data.deviceList[e.currentTarget.dataset.index].deviceId;
             const deviceList = that.data.deviceList.filter((item, i) => {
               return id !== item.deviceId
@@ -738,6 +738,8 @@ Page({
 
     var onLineList = [];
     var onNoLineList = [];
+
+    ///区分在线和离线
     for (var i = 0; i < deviceList.length; i++) {
       if (i > 0) {
         if (deviceList[i].state == "online") {
@@ -748,18 +750,11 @@ Page({
       }
     }
 
-    onLineList.forEach(element => {
-      if (element.ProdModel == "MW-2AX(WIFI-N)") {
-        onLineList.push(element)
-      } else {
-        onNoLineList.push(element)
-      }
-    });
-
+    // 区分在线wifi和蓝牙 wifi在前 离线在后
     var onLineWifiList = [];
     var onLineNoWifiList = [];
-    onNoLineList.forEach(element => {
-      if (element.ProdModel == "MW-2AX(WIFI-N)") {
+    onLineList.forEach(element => {
+      if (element.connectType == 3) {
         onLineWifiList.push(element)
       } else {
         onLineNoWifiList.push(element)
@@ -768,17 +763,18 @@ Page({
     finalList = finalList.concat(onLineWifiList);
     finalList = finalList.concat(onLineNoWifiList);
 
+    ///区分离线wifi和蓝牙 wifi在前 离线在后
     var onNoLineWifiList = [];
     var onNoLineNoWifiList = [];
     onNoLineList.forEach(element => {
-      if (element.ProdModel == "MW-2AX(WIFI-N)") {
+      if (element.connectType == 3) {
         onNoLineWifiList.push(element)
       } else {
         onNoLineNoWifiList.push(element)
       }
     });
     finalList = finalList.concat(onNoLineWifiList);
-    finalList = finalList.concat(onNoLineWifiList);
+    finalList = finalList.concat(onNoLineNoWifiList);
     // 更新缓存
     wx.setStorageSync("devicelist", JSON.stringify(finalList));
     return finalList;

+ 2 - 2
pages/index/index.wxml

@@ -52,7 +52,7 @@
 
   <view wx:else>
     <!-- 连接设备启用以下版本 -->
-    <view wx:if="{{indexPage==1&&deviceListIndex!=null&&deviceList.length>deviceListIndex&&deviceList[deviceListIndex].ProdModel==='MW-2AX(WIFI-N)'}}" class="mair" style="height: calc(100vh - 118rpx - {{navBarHeight}}px);">
+    <view wx:if="{{indexPage==1&&deviceListIndex!=null&&deviceList.length>deviceListIndex&&deviceList[deviceListIndex].connectType===3}}" class="mair" style="height: calc(100vh - 118rpx - {{navBarHeight}}px);">
       <view class="play-info">
         <view class="info">
           <image src="./../../img/blak.png" class="black" mode="scaleToFill"></image>
@@ -167,7 +167,7 @@
         <view style="font-size: 20rpx;color: {{indexPage==0?'#A4D099':'black'}}; padding-top: 0rpx;margin-top: 0rpx;"> 首页</view>
       </view>
 
-      <view wx:if="{{deviceListIndex!=null&&deviceList.length>deviceListIndex&&deviceList[deviceListIndex].ProdModel==='MW-2AX(WIFI-N)'}}" class="bottom_view" data-index="1" bind:tap="onTapIndex">
+      <view wx:if="{{deviceListIndex!=null&&deviceList.length>deviceListIndex&&deviceList[deviceListIndex].connectType===3}}" class="bottom_view" data-index="1" bind:tap="onTapIndex">
         <image class="bottom_image" mode="widthFix" src="{{indexPage==1?'./../../img/channel_action.png':'./../../img/channel_unaction.png'}}"></image>
         <view style="font-size: 20rpx;color: {{indexPage==1?'#A4D099':'black'}};"> 频道</view>
       </view>