Procházet zdrojové kódy

Merge branch 'develop/3.2.7' of http://60.205.190.38:9000/zhaoheqing/wxmini into develop/3.2.7

332777428@qq.com před 5 měsíci
rodič
revize
a80ff2ea26

+ 2 - 1
app.json

@@ -21,7 +21,8 @@
     "pages/ota/ota",
     "pages/piano/cropper/cropper",
     "pages/setWifi/setWifi",
-    "pages/deviceConnect4/deviceConnect4"
+    "pages/deviceConnect4/deviceConnect4",
+    "pages/components/webview/webview"
   ],
   "window": {
     "backgroundTextStyle": "light",

+ 18 - 4
devices/ble_manager.js

@@ -110,7 +110,7 @@ class bleManager {
               // }
               console.log("2222:", temp.mac, ":", temp.mac2, ":", temp.deviceId, temp, temp.connectable);
 
-              // if ((temp.deviceId === "07:F6:F4:66:FB:FA")) {
+              // if ((temp.deviceId.indexOf("1f:de") ) > -1) {
               //   that.callBackConnect(temp);
               // }
               that.callBackConnect(temp);
@@ -316,6 +316,14 @@ class bleManager {
 
       ///做搜索蓝牙适配器权限
       const permission_util = require('../utils/permission_util');
+      // var location = await permission_util.getSetting()
+      // if (!location) {
+      //   if (boolean != null) {
+      //     boolean(false);
+      //     console.log("没有定位权限")
+      //   }
+      //   return
+      // }
       var available = await permission_util.openBluetoothAdapter();
       that.isAvailable = available;
       if (!available) {
@@ -397,9 +405,14 @@ class bleManager {
         that.compareList = [];
       },
       fail(err) {
-        console.log("开始搜索设备失败", res);
+        console.log("开始搜索设备失败", err);
         that.doStartScaning = false;
         that.requestBlueTime = time_util.getCurrentMills();
+        if (err.errMsg.indexOf("location") >= 0) {
+          wx.showToast({
+            title: '搜索失败,请检查下手机设置的微信定位权限是否开启',
+          })
+        }
         if (boolean != null) {
           boolean(false);
         }
@@ -491,6 +504,7 @@ class bleManager {
             that.disconnect({ "deviceId": device.deviceId })
           } else {
             that.isConnecting = false;
+            console.log("监听到设备状态变化3:", err);
             that.errorDisconnect({ "deviceId": device.deviceId, "state": "offline" })
             let publicDevice = that.publicDevice ?? {}
             if (device.deviceId == publicDevice.deviceId) {
@@ -542,7 +556,7 @@ class bleManager {
           if (callback) {
             callback(false)
           }
-          console.log('数据发送失败:', err);
+          console.log('监听到设备状态变化4:', err);
           that.errorDisconnect({ "deviceId": that.publicDevice.deviceId, "state": "offline" })
           resolve(false);
         }
@@ -749,7 +763,7 @@ class bleManager {
   }
   errorDisconnect(result) {
     // this.disconnect();
-    console.log("监听到设备状态变化1:", result.deviceId, result.connected, this.stateChangeCallback);
+    console.log("监听到设备状态变化1:", result.deviceId, result.state, this.stateChangeCallback);
     if (this.stateChangeCallback && result.deviceId) {
       this.stateChangeCallback(result);
     }

+ 1 - 1
devices/bt_helper.js

@@ -93,7 +93,7 @@ class BtHelper {
     that.bleManager.initBluetoothAdapter();
     that.bleManager.onBLEConnectionStateChange();
     that.bleManager.setStateChangeCallback(function (e) {
-      event_bus.fire(CmdEvent.onoffline({ deviceId: e.deviceId, state: e.connected ? "online" : "offline" }));
+      event_bus.fire(CmdEvent.onoffline({ deviceId: e.deviceId, state: e.state == "online" ? "online" : "offline" }));
     });
   }
 

+ 5 - 0
pages/components/image-cropper/image-cropper.js

@@ -318,6 +318,11 @@ Component({
                             width: this.data.width * this.data.export_scale,
                             height: this.data.height * this.data.export_scale
                         });
+                    },
+                    fail:(err) => {
+                        wx.showToast({
+                          title: '壁纸裁剪失败'+err,
+                        })
                     }
                 }, this)
             });

+ 18 - 0
pages/components/webview/webview.js

@@ -0,0 +1,18 @@
+// pages/webview/webview.js
+Page({
+  data: {
+    url: ''
+  },
+
+  onLoad: function (options) {
+    // 从 options 中获取传入的 url 参数
+    const url = options.param;
+    if (url) {
+      this.setData({
+        url: url
+      });
+    } else {
+      console.error('URL 参数未提供');
+    }
+  }
+});

+ 4 - 0
pages/components/webview/webview.json

@@ -0,0 +1,4 @@
+{
+  "usingComponents": {},
+  "navigationStyle": "default"
+}

+ 2 - 0
pages/components/webview/webview.wxml

@@ -0,0 +1,2 @@
+<!-- pages/webview/webview.wxml -->
+<web-view class="web-view" src="{{url}}"></web-view>

+ 5 - 0
pages/components/webview/webview.wxss

@@ -0,0 +1,5 @@
+/* pages/components/webview/webview.wxss */
+web-view {
+    width: 100%;
+    height: 100%;
+}

+ 40 - 22
pages/index/index.js

@@ -1,7 +1,8 @@
 const app = getApp();
 const {
   login,
-  listByDevice
+  listByDevice,
+  getBanner
 } = require('../../utils/api.js');
 
 import time_util from '../../utils/time_util.js';
@@ -78,13 +79,14 @@ Page({
 
     deviceMacId: null,
     deviceListSelect: null,
-    deviceList: [{
-      "connectType": 3,
-      // "mac": "AIrSMArT_861210052356337",
-      // "deviceId": "D0:31:10:86:AC:9A"
-      "name": "MW-X4(BZK)",
-      "deviceId": "AIrSMArT_861210052356337"
-    }],
+    deviceList:[],
+    // deviceList: [{
+    //   "connectType": 3,
+    //   // "mac": "AIrSMArT_861210052356337",
+    //   // "deviceId": "D0:31:10:86:AC:9A"
+    //   "name": "MW-X4(BZK)",
+    //   "deviceId": "AIrSMArT_861210052356337"
+    // }],
     _willConnectBle: null,
     _hasShowModal: null,
     // deviceList: [{
@@ -896,11 +898,11 @@ Page({
           console.log("有蓝牙设备上线")
           that.stopIntervalId1();
         } else {
-          let onLineBle = deviceList.find(item => {
-            return item.state == "online" && item.connectType === 1
+          // 有wifi设备在线
+          let wifiDevice = deviceList.find(item => {
+            return item.state == "online" && item.connectType === 3
           })
-          if (!onLineBle) {
-            // 没有在线的蓝牙
+          if (!wifiDevice) {
             that.startBleTimer(isFirst);
           }
         }
@@ -917,15 +919,16 @@ Page({
           console.log("没有找到在线的对应的蓝牙设备")
           return;
         }
-        that.disconnectDev(event, disDevice)
+
         disDevice.state = event.commonValue;
         console.log("首页设备状态变化", disDevice.state, disDevice.deviceId)
 
         if (event.commonValue == "online") {
           // BtHelper.getInstance().connect()
-          console.log("首页上线连接", disDevice)
+          console.log("首页连接上线", disDevice)
         } else {
-          console.log("首页断开连接", disDevice)
+          that.disconnectDev(event, disDevice)
+          console.log("首页连接断开", disDevice)
           that.updateDeviceList(deviceList, false, false);
         }
       }
@@ -991,8 +994,22 @@ Page({
 
   ///点击banner事件
   onTapBanner(e) {
-    var that = this;
     var item = e.currentTarget.dataset.item;
+    try {
+      if (strings.isEmpty(item.forwardUrl)) {
+        return
+      }
+      if (item.forwardType == 0) {
+        // 内链,暂时不支持
+        route_util.jump(item.forwardUrl, item.forwardUrl);
+      } else if (item.forwardType == 1) {
+        // 外链
+        route_util.jumpParam(route_constant.webview, item.forwardUrl);
+      }
+    } catch (err) {
+      console.log("跳转失败", err)
+    }
+
   },
 
   ///添加设备
@@ -1158,12 +1175,13 @@ Page({
 
   onBannerShow() {
     var that = this;
-    // getBanner({}).then((res) => {
-    //   that.setData({
-    //     bannerList: res
-    //   });
-    // store.setStore("homeBanner", res);
-    // })
+    getBanner({}).then((res) => {
+      console.log("banner:", res)
+      that.setData({
+        bannerList: res
+      });
+      store.setStore("homeBanner", res);
+    })
   },
 
   stopIntervalId1: function () {

+ 0 - 11
pages/index/index.wxml

@@ -7,7 +7,6 @@
     <view wx:if="{{indexPage==0}}" class="mair" style="flex-direction: column; display: flex; height: calc(100vh - 105rpx - {{safeBottomHeight}}rpx - 22rpx - {{navBarHeight}}px);">
       <view style="font-size: 32rpx; color: #333333; margin-top: 14rpx;">{{greeting}}</view>
 
-      <!-- banner -->
       <view wx:if="{{bannerList.length>0}}" class="banner_container">
         <swiper class="swiper" indicator-dots="{{bannerList.length>1}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" circular="{{circular}}" indicator-active-color="#FFFFFF" indicator-color="#999999">
           <block wx:for="{{bannerList}}" wx:key="index">
@@ -17,16 +16,6 @@
           </block>
         </swiper>
       </view>
-      <!-- banner -->
-      <!-- <view wx:if="{{bannerList.length>0}}" class="banner_container" style="width: calc(100vw - 64rpx);   border-radius: 16rpx;">
-        <swiper style="width: calc(100vw - 64rpx);   border-radius: 16rpx;" indicator-dots="{{bannerList.length>1}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" circular="{{circular}}" indicator-active-color="#FFFFFF" indicator-color="#999999">
-          <block wx:for="{{bannerList}}" wx:key="index">
-            <swiper-item style="width: calc(100vw - 64rpx); border-radius: 16rpx;">
-              <image class="banner_item" style="width: calc(100vw - 64rpx); border-radius: 16px;" src="{{item.pic}}" mode="aspectFill" bindtap="onTapBanner" data-item="{{item}}" lazy-load="true"></image>
-            </swiper-item>
-          </block>
-        </swiper>
-      </view> -->
 
       <view class="add_device_public" bind:tap="jumpToAddDevice">
         <image mode="heightFix" src="./../../img/add_device.png" style="width: 48rpx;height: 48rpx;"></image>

+ 4 - 0
utils/route_constant.js

@@ -18,6 +18,9 @@ const deviceList = "../deviceList/deviceList";
 const connectMode = "../deviceConMode/index";
 const connectBle = "../connectBle/connectBle";
 
+
+const webview = "../components/webview/webview";
+
 module.exports = {
   ///路由
   indexRoot: indexRoot,
@@ -35,4 +38,5 @@ module.exports = {
   connectMode: connectMode,
   connectBle: connectBle,
   setWifi: setWifi,
+  webview: webview,
 }