Przeglądaj źródła

feature:合并小程序3.2.5的代码到3.2.7

zeng.chen 5 miesięcy temu
rodzic
commit
e248257b6c

+ 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",

+ 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%;
+}

+ 26 - 12
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';
@@ -896,11 +897,11 @@ Page({
           console.log("有蓝牙设备上线")
           that.stopIntervalId1();
         } else {
-          let onLineBle = deviceList.find(item => {
-            return item.state == "online" && item.connectType === 1
+
+          let wifiDevice = deviceList.find(item => {
+            return item.state == "online" && item.connectType === 3
           })
-          if (!onLineBle) {
-            // 没有在线的蓝牙
+          if (!wifiDevice) {
             that.startBleTimer(isFirst);
           }
         }
@@ -917,6 +918,7 @@ Page({
           console.log("没有找到在线的对应的蓝牙设备")
           return;
         }
+
         that.disconnectDev(event, disDevice)
         disDevice.state = event.commonValue;
         console.log("首页设备状态变化", disDevice.state, disDevice.deviceId)
@@ -991,8 +993,19 @@ Page({
 
   ///点击banner事件
   onTapBanner(e) {
-    var that = this;
     var item = e.currentTarget.dataset.item;
+    try {
+      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 +1171,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 () {

+ 4 - 4
pages/index/index.wxml

@@ -8,7 +8,7 @@
       <view style="font-size: 32rpx; color: #333333; margin-top: 14rpx;">{{greeting}}</view>
 
       <!-- banner -->
-      <view wx:if="{{bannerList.length>0}}" class="banner_container">
+      <!-- <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">
             <swiper-item>
@@ -16,9 +16,9 @@
             </swiper-item>
           </block>
         </swiper>
-      </view>
+      </view> -->
       <!-- banner -->
-      <!-- <view wx:if="{{bannerList.length>0}}" class="banner_container" style="width: calc(100vw - 64rpx);   border-radius: 16rpx;">
+      <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;">
@@ -26,7 +26,7 @@
             </swiper-item>
           </block>
         </swiper>
-      </view> -->
+      </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,
 }