Prechádzať zdrojové kódy

feature:优化选择配网界面的UI

zeng.chen 8 mesiacov pred
rodič
commit
a7b0335627

+ 60 - 6
pages/deviceConMode/index.js

@@ -1,4 +1,8 @@
 // pages/deviceConMode/index.js
+// const btHelper = require('../../devices/bt_helper');
+// const toastUtil = require('../../utils/toast_util');
+import routeUtil from '../../utils/route_util'
+import route_constant from '../../utils/route_constant.js'
 Page({
 
   /**
@@ -18,20 +22,24 @@ Page({
     },
     isNotruter: false,
     model: 0,
+    connectDevice: {},
     typeList: [
       {
         "icon": "../../images/device/mode_wifi.png",
         "text": "WiFi模式",
+        "type": 3,
       },
       {
         "icon": "../../images/device/mode_ble.png",
         "text": "蓝牙模式",
+        "type": 1,
       },
       {
         "icon": "../../images/device/mode_g4.png",
         "text": "4G模式",
+        "type": 2,
       },
-    ]
+    ],
   },
   getModeName(curItem) {
     // 设备类型:1-蓝牙,2-Wifi,3-传统蓝牙,4-4G
@@ -45,12 +53,58 @@ Page({
     }
     return str;
   },
-  clickNextTap(){},
-  /**
-   * 生命周期函数--监听页面加载
-   */
-  onLoad(options) {
+  nextTap(e) {
+    let device = this.data.typeList[0];
+    // console.log(e)
+    let type = device.type ?? 0;
+    if (type == 1) {
+      let device = e.currentTarget.dataset.data
+      routeUtil.jumpParam(route_constant.connectBle, this.data.connectDevice)
+    } else if (type == 2) {
+
+    } else if (type == 3) {
+      // btHelper.stopSearch()
+    } else {
 
+    }
+  },
+  async selectDeviceModelTap(e) {
+    let device = e.currentTarget.dataset.device;
+    // console.log(e)
+    let type = device.type;
+    if (type == 1) {
+      // this.getConnectedDevices()
+    } else if (type == 2) {
+
+    } else if (type == 3) {
+      // btHelper.stopSearch()
+    } else {
+
+    }
+    var list = []
+    list.push(device)
+    this.data.typeList.forEach(element => {
+      if (element.type != type) {
+        list.push(element)
+      }
+    });
+    this.setData({
+      typeList: list,
+    })
+
+  },
+
+  onLoad: function (options) {
+    console.log(options)
+    let device = options.param;
+    this.setData({
+      connectDevice: device
+    })
+
+    if (getApp().globalData.isIOS) {
+
+    } else {
+    }
   },
 
   /**

+ 4 - 3
pages/deviceConMode/index.wxml

@@ -1,14 +1,15 @@
 <!-- pages/deviceConMode/index.wxml -->
 <!-- pages/deviceRoter0/deviceRoter0.wxml -->
-<nav-bar class="nav_bar_c" bind:goBack="_goBack" nav-bgc-class="ex-nav-bgc-class" nav-title-class="ex-nav-title-class" ex-back-pre="ex-back-pre" navbar-data='{{nvabarData}}'></nav-bar>
+
 <view class="main">
+  <nav-bar class="nav_bar_c" bind:goBack="_goBack" nav-bgc-class="ex-nav-bgc-class" nav-title-class="ex-nav-title-class" ex-back-pre="ex-back-pre" navbar-data='{{nvabarData}}'></nav-bar>
   <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">
       <block wx:for="{{typeList}}" wx:key="item">
-        <view class="devicePicItem devicePicItem_{{index}}" bindtap="selectDeviceModel" data-type="{{item.type}}">
+        <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>
           <view class="device_text">
             <image class="model_icon" src="{{item.icon}}"></image>
@@ -19,5 +20,5 @@
     </view>
   </view>
   <view class="setDeviceModelTips">开启后点击“下一步”</view>
-<view class="clickNext" bind:tap="clickNextTap">下一步</view>
+  <view class="main_bg_green connect_button" bind:tap="nextTap">正在搜索设备</view>
 </view>

+ 13 - 0
pages/deviceConMode/index.wxss

@@ -102,4 +102,17 @@
 .devicePicItem_2 {
 	margin-left: 96rpx;
 	margin-right: 96rpx;
+}
+
+.connect_button {
+	position: fixed;
+	bottom: 100rpx;
+	left: 60rpx;
+	right: 60rpx;
+	/* margin-inline: 60rpx; */
+	color: white;
+	text-align: center;
+	padding: 10px 0;
+	box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
+	/* 添加阴影效果 */
 }

+ 20 - 22
pages/deviceConnect0/deviceConnect0.js

@@ -28,13 +28,13 @@ Page({
     wx.offAppShow(this.getSetting);
     wx.onAppShow(this.getSetting);
     this.getSetting();
-    if(options.isLognlink) {
+    if (options.isLognlink) {
       this.setData({
         isNotruter: true,
         nvabarData: {
           showCapsule: 1,
           title: '连接配网',
-          callback: ()=> {
+          callback: () => {
             wx.switchTab({
               url: "./../index/index"
             })
@@ -51,34 +51,32 @@ Page({
   getSetting() {
     const _this = this;
     wx.getSetting({
-      success (res) {
-        if(res.authSetting["scope.userFuzzyLocation"]) {
+      success(res) {
+        if (res.authSetting["scope.userFuzzyLocation"]) {
           // 成功
           app.getBluetoothStatus();
           _this.setData({
             userFuzzyLocation: true,
           });
-        } else if(res.authSetting["scope.userFuzzyLocation"] === undefined) {
-          _this.setData({
-            userFuzzyLocation: false,
-          });
-          wx.authorize({ 
+        } else if (res.authSetting["scope.userFuzzyLocation"] === undefined) {
+
+          wx.authorize({
             scope: "scope.userFuzzyLocation",
-            success () {
+            success() {
               _this.getSetting();
             }
           });
-        }else {
+        } else {
           _this.setData({
             userFuzzyLocation: false,
           });
           wx.showModal({
             title: '请打开系统位置获取',
-            success (res) {
+            success(res) {
               if (res.confirm) {
                 console.log('用户点击确定')
                 wx.openSetting({
-                  complete () {
+                  complete() {
                     // _this.getSetting();
                   }
                 })
@@ -91,18 +89,18 @@ Page({
       }
     })
   },
-  next(){
+  next() {
     const _this = this;
     wx.openBluetoothAdapter({
-      success (res) {
-        if(_this.data.scopeBluetooth && _this.data.userFuzzyLocation){
+      success(res) {
+        if (_this.data.scopeBluetooth && _this.data.userFuzzyLocation) {
           wx.navigateTo({
             url: './../deviceConnect1/deviceConnect1',
           });
         }
       },
       fail(res) {
-        if(res.errCode === 10001) {
+        if (res.errCode === 10001) {
           wx.showToast({
             title: '蓝牙未打开',
             icon: "none",
@@ -112,22 +110,22 @@ Page({
       }
     });
   },
-  setBluetooth(){
+  setBluetooth() {
     wx.openSetting({
-      complete () {
+      complete() {
         // app.getBluetoothStatus();
       }
     })
   },
-  setUserFuzzyLocation(){
+  setUserFuzzyLocation() {
     const _this = this;
     wx.openSetting({
-      complete () {
+      complete() {
         // _this.getSetting();
       }
     })
   },
-  notRoter(){
+  notRoter() {
     getCurrentPages()[0].onLoad();
     wx.switchTab({
       url: "./../index/index"