Browse Source

Merge branch 'feature/3.2.0' of http://60.205.190.38:9000/wuhao/wxmini into feature/3.2.0

Damon 1 năm trước cách đây
mục cha
commit
92d97b67a4

+ 2 - 2
custom-tab-bar/index.wxml

@@ -2,7 +2,7 @@
 <cover-view class="tab-bar">
   <cover-view class="tab-bar-border"></cover-view>
   <cover-view wx:for="{{list}}" wx:key="index" class="tab-bar-item" data-path="{{item.pagePath}}" data-index="{{index}}" bindtap="switchTab">
-    <cover-image src="{{selected === index ? item.selectedIconPath : item.iconPath}}"></cover-image>
-    <cover-view style="color: {{selected === index ? selectedColor : color}}">{{item.text}}</cover-view>
+    <cover-image class="item-image" src="{{selected === index ? item.selectedIconPath : item.iconPath}}"></cover-image>
+    <cover-view class="item-view" style="color: {{selected === index ? selectedColor : color}}">{{item.text}}</cover-view>
   </cover-view>
 </cover-view>

+ 3 - 2
custom-tab-bar/index.wxss

@@ -29,11 +29,12 @@
   flex-direction: column;
 }
 
-.tab-bar-item cover-image {
+.item-image {
   width: 27px;
   height: 27px;
 }
 
-.tab-bar-item cover-view {
+
+.item-view {
   font-size: 10px;
 }

+ 1 - 0
custom-tab-bar/tabbar.js

@@ -48,6 +48,7 @@ function eventOn(curPage) {
       curPage.setData({
         rightId: data
       })
+      console.log("页面:"+curPage.data.rightId);
       if (curPage.data.rightId === 2) {
         let num = curPage.data.rightId === 1 ? 2 : 1
         if (typeof curPage.getTabBar === 'function' &&

+ 12 - 19
pages/bluConnect/bleconnect.js

@@ -32,7 +32,8 @@ Page(
       }
     }, getBluetoothStatusCallck(v) {
       this.setData({
-        scopeBluetooth: v
+        scopeBluetooth: v,
+        isScaning:v
       })
     },
     setBluetooth() {
@@ -42,21 +43,13 @@ Page(
         }
       })
     }, connectDeviceTap() {
-var _this = this;
-      // var curPage = getCurrentPages();
-      // var homePage = curPage[curPage.length - 1];
-      var key = 'home_device_list'+wx.getUserInfo().userId;
-      var saveStr = wx.getStorageSync(key) ?? "[]";
-      console.log("返回数据: "+saveStr);
+      var _this = this;
+      const eventChannel = this.getOpenerEventChannel();
+      eventChannel.emit('getBackData', {  
+       backData:  _this.deviceItem});
 
-      var oldList = JSON.parse(saveStr);
+      wx.navigateBack();
 
-      oldList.push(_this.deviceItem);
-      console.log("返回数据:2\n"+JSON.stringify(oldList));
-
-wx.setStorageSync(key, JSON.stringify(oldList));
-      // homePage.setData({deviceList:[_this.deviceItem]});
-wx.navigateBack();
       if (!_this.isScaning) {
         return;
       }
@@ -73,14 +66,14 @@ wx.navigateBack();
       if (options.isLognlink) {
 
       }
-    
+
       this.buttonTips = this.isScaning ? "正在搜索设备" : "连接";
 
       this.connectStatus = 4;
       switch (this.connectStatus) {
         case 1:
           // 搜索中
-          this.connectTips =  "正在搜索设备,请保持开机状态...";
+          this.connectTips = "正在搜索设备,请保持开机状态...";
           break;
         case 2:
           // 连接中
@@ -102,9 +95,9 @@ wx.navigateBack();
             "devName": "名称1", "state": "online", "power": 40
           };
           break;
-          case 5:
-            // 搜索成功
-            this.connectTips = "搜索到" + this.deviceItem.name;
+        case 5:
+          // 搜索成功
+          this.connectTips = "搜索到" + this.deviceItem.name;
           var curPage = getCurrentPages();
           var homePage = curPage[curPage.length - 1];
 

+ 2 - 2
pages/components/navbar/navbar.wxml

@@ -1,8 +1,8 @@
 <view class='nav-wrap nav-bgc-class' style='height: calc({{navBarHeight}}px - {{MenuButtonTop}}px); padding-top: {{MenuButtonTop}}px;'>
      <view class="nav-info" style="height: {{ MenuButtonheight }}px;">
         <view  bindtap='_navback' style="height: {{ MenuButtonheight }}px;" class="device-pic">
-          <image wx:if='{{navbarData.showCapsule}}' bindtap=""  mode="heightFix"  src="./../../../img/goback.png"></image>
+          <image class="capsule" wx:if='{{navbarData.showCapsule}}' bindtap=""  mode="heightFix"  src="./../../../img/goback.png"></image>
         </view>
-        <text class="nav-title-class" style="height: {{ MenuButtonheight }}px; line-height: {{ MenuButtonheight }}px;">{{navbarData.title}}</text>
+        <text class="nav-title" style="height: {{ MenuButtonheight }}px; line-height: {{ MenuButtonheight }}px;">{{navbarData.title}}</text>
      </view>
   </view>

+ 3 - 3
pages/components/navbar/navbar.wxss

@@ -20,12 +20,12 @@
   width: 40rpx;
 }
 
-.nav-wrap .nav-info .device-pic image {
+.nav-wrap .nav-info .device-pic .capsule {
   height: 36rpx;
 }
 
-.nav-wrap .nav-info text {
-  width: 100%;
+.nav-title {
+  width: 100%; 
   text-align: center;
   font-size: 35rpx;
   color: #000;

+ 26 - 15
pages/home/home.js

@@ -137,21 +137,8 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow(options) {
-    selectIndex( 0);
-
-    // if (typeof this.getTabBar === 'function' &&
-    //   this.getTabBar()) {
-    //   this.getTabBar().setData({
-    //     selected: 0
-    //   })
-    // }
-    // app.eventBus.on('rightChange', data => {
-    //   if (data !== this.data.rightId) {
-    //     this.setData({
-    //       rightId: data
-    //     })
-    //   }
-    // });
+    selectIndex(0);
+
 
     if (this.data.isLoginWx) {
       var key = 'home_device_list' + wx.getUserInfo().userId;
@@ -167,6 +154,30 @@ Page({
   addDeviceTap() {
     wx.navigateTo({
       url: './../bluConnect/bleconnect',
+      events: {
+        getBackData: res => {
+          console.log(res);
+          var key = 'home_device_list' + wx.getUserInfo().userId;
+          var saveStr = wx.getStorageSync(key) ?? "[]";
+
+          var oldList = JSON.parse(saveStr) ?? [];
+          var findElement;
+          for (let index = 0; index < oldList.length; index++) {
+            const element = oldList[index];
+            if (element.address == res.address) {
+              findElement = element;
+              break;
+            }
+          }
+          if (findElement) {
+            oldList.pop(findElement);
+          }
+          oldList.push(res);
+
+          wx.setStorageSync(key, JSON.stringify(oldList));
+          this.setData({ deviceList: oldList });
+        }
+      }
     });
   },
   /**