Browse Source

feature: 添加没有的数据

332777428@qq.com 6 months ago
parent
commit
9af4727f3f
28 changed files with 1537 additions and 1 deletions
  1. 213 0
      pages/packageA/connectBle/connectBle.js
  2. 3 1
      pages/packageA/connectBle/connectBle.json
  3. 10 0
      pages/packageA/connectBle/connectBle.wxml
  4. 39 0
      pages/packageA/connectBle/connectBle.wxss
  5. 0 0
      pages/packageA/deviceConMode/deviceConMode.js
  6. 0 0
      pages/packageA/deviceConMode/deviceConMode.json
  7. 0 0
      pages/packageA/deviceConMode/deviceConMode.wxml
  8. 0 0
      pages/packageA/deviceConMode/deviceConMode.wxss
  9. 148 0
      pages/packageA/deviceConMode/index.js
  10. 5 0
      pages/packageA/deviceConMode/index.json
  11. 22 0
      pages/packageA/deviceConMode/index.wxml
  12. 119 0
      pages/packageA/deviceConMode/index.wxss
  13. 155 0
      pages/packageA/deviceConnect0/deviceConnect0.js
  14. 5 0
      pages/packageA/deviceConnect0/deviceConnect0.json
  15. 29 0
      pages/packageA/deviceConnect0/deviceConnect0.wxml
  16. 1 0
      pages/packageA/deviceConnect0/deviceConnect0.wxss
  17. 143 0
      pages/packageA/deviceConnect1/deviceConnect1.js
  18. 5 0
      pages/packageA/deviceConnect1/deviceConnect1.json
  19. 32 0
      pages/packageA/deviceConnect1/deviceConnect1.wxml
  20. 62 0
      pages/packageA/deviceConnect1/deviceConnect1.wxss
  21. 223 0
      pages/packageA/deviceConnect2/deviceConnect2.js
  22. 5 0
      pages/packageA/deviceConnect2/deviceConnect2.json
  23. 18 0
      pages/packageA/deviceConnect2/deviceConnect2.wxml
  24. 1 0
      pages/packageA/deviceConnect2/deviceConnect2.wxss
  25. 221 0
      pages/packageA/deviceConnect3/deviceConnect3.js
  26. 5 0
      pages/packageA/deviceConnect3/deviceConnect3.json
  27. 36 0
      pages/packageA/deviceConnect3/deviceConnect3.wxml
  28. 37 0
      pages/packageA/deviceConnect3/deviceConnect3.wxss

File diff suppressed because it is too large
+ 213 - 0
pages/packageA/connectBle/connectBle.js


+ 3 - 1
pages/packageA/connectBle/connectBle.json

@@ -1,3 +1,5 @@
 {
-  "usingComponents": {}
+  "usingComponents": {
+    "nav-bar": "../../../components/navbar/navbar"
+  }
 }

+ 10 - 0
pages/packageA/connectBle/connectBle.wxml

@@ -0,0 +1,10 @@
+<!-- pages/connectBle/connectBle.wxml -->
+<view class="container">
+  <nav-bar 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="device_pic" src="{{deviceImg}}" mode="aspectFill" />
+  <view class="top_tips main_black">{{searchTips}}</view>
+  <view style="font-size: 28rpx; color: #666666; margin-top: 32rpx; display: flex; justify-content: center; align-items: center;margin-inline: 32rpx;">
+    {{subTips}}
+  </view>
+  <view class="main_color connect_button" bind:tap="connectDeviceTap">{{buttonTips}}</view>
+</view>

+ 39 - 0
pages/packageA/connectBle/connectBle.wxss

@@ -0,0 +1,39 @@
+/* pages/connectBle/connectBle.wxss */
+.container {
+	position: relative;
+	height: 100vh;
+}
+
+.device_pic {
+	margin-top: 128rpx;
+	margin-left: 140rpx;
+	/* margin-right: 140rpx; */
+	width: 470rpx;
+	height: 432rpx;
+	background: #F2F5F7;
+	border-radius: 24rpx;
+}
+
+.top_tips {
+	margin-top: 128rpx;
+	margin-inline: 20rpx;
+	font-size: 28rpx;
+	text-align: center;
+	justify-content: center;
+	align-items: center;
+
+}
+
+.connect_button {
+	margin-top: 456rpx;
+	display: flex;
+	justify-content: center;
+	align-items: center;
+	margin-inline: 64rpx;
+	font-size: 32rpx;
+	font-weight: Medium;
+	color: white;
+	text-align: center;
+	border-radius: 44rpx;
+	height: 88rpx;
+}

+ 0 - 0
pages/packageA/deviceConMode/deviceConMode.js


+ 0 - 0
pages/packageA/deviceConMode/deviceConMode.json


+ 0 - 0
pages/packageA/deviceConMode/deviceConMode.wxml


+ 0 - 0
pages/packageA/deviceConMode/deviceConMode.wxss


+ 148 - 0
pages/packageA/deviceConMode/index.js

@@ -0,0 +1,148 @@
+import routeUtil from '../../utils/route_util'
+import route_constant from '../../utils/route_constant.js'
+Page({
+
+  data: {
+    scopeBluetooth: false,
+    userFuzzyLocation: true,
+    nvabarData: {
+      showCapsule: 1, //是否显示左上角图标   1表示显示    0表示不显示
+      title: '配网模式选择', //导航栏 中间的标题
+    },
+    isNotruter: false,
+    model: "",
+    connectDevice: {},
+    typeList: [{
+        "icon": "../../images/device/mode_2.png",
+        "text": "WiFi模式",
+        "type": 2,
+      },
+      {
+        "icon": "../../images/device/mode_1.png",
+        "text": "蓝牙模式",
+        "type": 1,
+      },
+      {
+        "icon": "../../images/device/mode_4.png",
+        "text": "4G模式",
+        "type": 4,
+      },
+    ],
+  },
+
+  getModeName(curItem) {
+    // 设备类型:1-蓝牙,2-Wifi,3-传统蓝牙,4-4G
+    var str = "";
+    if (curItem.type == 4) {
+      str = "移动数据模式";
+    } else if (curItem.type == 2) {
+      str = "WiFi模式";
+    } else if (curItem.type == 1) {
+      str = "蓝牙模式";
+    }
+    return str;
+  },
+
+  nextTap(e) {
+    if (this.nullTips()) {
+      return
+    }
+    let device = this.data.typeList[0];
+    let type = device.type ?? 0;
+    console.log("选择模式", type)
+    ///蓝牙模式
+    if (type == 1) {
+      // let device = e.currentTarget.dataset.data
+      let json = JSON.stringify(this.data.connectDevice)
+      routeUtil.jumpParam(route_constant.connectBle, json)
+      // wx.navigateTo({
+      //   url: './../deviceDetail/detail',
+      // });
+    }
+    ///Wifi模式
+    else if (type == 2) {
+      wx.navigateTo({
+        url: './../deviceConnect0/deviceConnect0',
+      });
+    } else if (type == 3) {
+      // btHelper.stopSearch()
+    }
+    ///4G模式
+    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,
+      model: this.getModeName(device)
+    })
+
+  },
+  nullTips() {
+    if (this.data.typeList.length === 0) {
+      wx.showToast({
+        title: '暂不支持该设备配网',
+        icon: 'none',
+      })
+      return true
+    }
+    return false
+  },
+  onLoad: function (options) {
+    let device = JSON.parse(options.param) || {}
+    console.log("配网配对的设备:", device)
+    if (Object.keys(device).length === 0) {
+      wx.showToast({
+        title: '设备数据为空,返回刷新列表试试看',
+      })
+      return;
+    }
+    let _this = this
+    let isWifi = device.clientType != "MW-S2";
+    let isS2 = device.clientType === "MW-S2";
+
+    let _typeList = device.typeList
+      .filter(e => (isWifi && e.type == 2) || isS2)
+      .map(e => ({
+        icon: "../../images/device/mode_" + e.type + ".png",
+        text: _this.getModeName(e),
+        type: e.type
+      }));
+
+    var list = []
+
+    this.data.typeList.forEach(element => {
+      if (_typeList.find(_type => _type.type === element.type)) {
+        list.push(element)
+      }
+    });
+    this.setData({
+      typeList: list,
+      connectDevice: device
+    })
+    this.nullTips()
+
+  },
+
+})

+ 5 - 0
pages/packageA/deviceConMode/index.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+    "nav-bar": "../../../components/navbar/navbar"
+  }
+}

+ 22 - 0
pages/packageA/deviceConMode/index.wxml

@@ -0,0 +1,22 @@
+<!-- pages/deviceConMode/index.wxml -->
+<!-- pages/deviceRoter0/deviceRoter0.wxml -->
+<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 wx:if="{{typeList.length > 0}}" class="deviceList">
+      <block wx:for="{{typeList}}" wx:key="item">
+        <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>
+            <text class="model_text">{{item.text}}</text>
+          </view>
+        </view>
+      </block>
+    </view>
+  </view>
+  <view wx:if="{{typeList.length > 0}}" class="setDeviceModelTips">开启后点击“下一步”</view>
+  <view class="main_color connect_button" bind:tap="nextTap">连接设备</view>
+</view>

+ 119 - 0
pages/packageA/deviceConMode/index.wxss

@@ -0,0 +1,119 @@
+/* pages/deviceConMode/index.wxss */
+
+.main {
+  position: relative;
+  height: 100vh;
+}
+
+.model_bg {
+  top: 80;
+  left: 0;
+  position: absolute;
+  width: 100%;
+  height: 100%;
+  z-index: -1;
+  background-size: cover;
+
+}
+
+.select_tips {
+  position: relative;
+  z-index: 1;
+  padding: 20px;
+}
+
+.devicePicItem {
+  display: flex;
+  align-items: center;
+  padding: 10px;
+
+}
+
+.setDeviceModel {
+  padding: 10px;
+  text-align: center;
+  left: 0;
+  font-size: 32rpx;
+}
+
+.setDeviceModelTips {
+  color: #FFFFFFB3;
+  text-align: center;
+  font-size: 24rpx;
+}
+
+.deviceList {
+  margin-top: 60px;
+}
+
+.devicePicItem {
+  position: relative;
+
+  display: flex;
+  flex-direction: row;
+  align-items: center;
+  justify-content: center;
+
+  border-radius: 5px;
+  height: 100rpx;
+  margin-top: 32rpx;
+  background-color: #ffffff0d;
+}
+
+.select_icon {
+  width: 32rpx;
+  height: 32rpx;
+  position: absolute;
+  z-index: 1;
+  top: 16rpx;
+  right: 16rpx;
+}
+
+.device_text {
+  display: flex;
+  flex-direction: row;
+  align-items: center;
+  justify-content: center;
+}
+
+.model_icon {
+  width: 48rpx;
+  height: 48rpx;
+  margin-right: 10rpx;
+}
+
+.model_text {
+  font-size: 32rpx;
+  color: white;
+}
+
+.devicePicItem_0 {
+  margin-left: 32rpx;
+  margin-right: 32rpx;
+}
+
+.devicePicItem_1 {
+  margin-left: 64rpx;
+  margin-right: 64rpx;
+}
+
+.devicePicItem_2 {
+  margin-left: 96rpx;
+  margin-right: 96rpx;
+}
+
+.connect_button {
+  position: fixed;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  bottom: 100rpx;
+  left: 60rpx;
+  right: 60rpx;
+  font-size: 32rpx;
+  font-weight: Medium;
+  color: white;
+  text-align: center;
+  border-radius: 44rpx;
+  height: 88rpx;
+}

File diff suppressed because it is too large
+ 155 - 0
pages/packageA/deviceConnect0/deviceConnect0.js


+ 5 - 0
pages/packageA/deviceConnect0/deviceConnect0.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+    "nav-bar": "../../../components/navbar/navbar"
+  }
+}

+ 29 - 0
pages/packageA/deviceConnect0/deviceConnect0.wxml

@@ -0,0 +1,29 @@
+<!--pages/deviceRoter0/deviceRoter0.wxml-->
+<view class="deviceRoter deviceRoter0">
+  <nav-bar 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="roterps">
+    <view class="devicePic">
+      <image mode="widthFix" src="{{imageUrl}}"></image>
+    </view>
+    <text>开启设备并将开关打至WiFi模式,指示灯亮
+      起后,即可进入下一步</text>
+    <view wx:if="{{!scopeBluetooth && userFuzzyLocation}}" class="qx">
+      <text bindtap="setBluetooth">开启蓝牙权限</text>
+      <image mode="heightFix" src="../../../img/a.png"></image>
+    </view>
+    <view wx:if="{{!userFuzzyLocation}}" class="qx">
+      <text bindtap="setUserFuzzyLocation">开启定位权限</text>
+      <image mode="heightFix" src="../../../img/a.png"></image>
+    </view>
+  </view>
+  <view class="subBtn">
+    <view class="btn" style="opacity: {{scopeBluetooth && userFuzzyLocation ? '1' : '0.6'}};" bindtap="next">
+      {{scopeBluetooth && userFuzzyLocation ? '下一步' : (!userFuzzyLocation ? '请开启定位权限' : '请开启蓝牙权限') }}
+    </view>
+    <view class="notRoter" wx:if="{{isNotruter}}">
+      <text bindtap="notRoter">暂不链接</text>
+      <image mode="heightFix" src="../../../img/b.png"></image>
+    </view>
+  </view>
+</view>

+ 1 - 0
pages/packageA/deviceConnect0/deviceConnect0.wxss

@@ -0,0 +1 @@
+/* pages/deviceRoter0/deviceRoter0.wxss */

+ 143 - 0
pages/packageA/deviceConnect1/deviceConnect1.js

@@ -0,0 +1,143 @@
+const app = getApp();
+import route_util from '../../utils/route_util.js';
+import route_constant from '../../utils/route_constant.js'
+
+Page({
+  data: {
+    nvabarData: {
+      showCapsule: 1, //是否显示左上角图标   1表示显示    0表示不显示
+      title: '设置网络', //导航栏 中间的标题
+    },
+    scopeBluetooth: app.globalData.scopeBluetooth,
+    isShowPwd: false,
+    is5GWifi: false,
+    ssid: "",
+    pwdData: "",
+    pwdData1: "",
+    connectDevice: "",
+  },
+
+  onLoad(options) {
+    var that = this;
+    var param = options.param;
+    that.data.connectDevice = param;
+  },
+
+  onShow() {
+    var that = this;
+    that.getWifiStatus();
+  },
+
+  getBluetoothStatus() {
+    app.getBluetoothStatus();
+  },
+
+  ///Wifi名称
+  setSsid: function (e) {
+    var that = this;
+    let str = false;
+    if (e.detail.value.indexOf("5G") !== -1) {
+      str = true;
+    };
+    that.setData({
+      ssid: e.detail.value,
+      is5GWifi: str
+    });
+  },
+
+  ///Wifi名称
+  setPwd: function (e) {
+    var that = this;
+    app.globalData.pwdData = e.detail.value;
+    that.setData({
+      pwdData: e.detail.value,
+    });
+  },
+
+  ///获取网络状态
+  getWifiStatus() {
+    var that = this;
+    wx.getNetworkType({
+      success(res) {
+        if (res.networkType === "wifi") {
+          wx.startWifi({
+            success(res) {
+              //获取当前已连接wifi名
+              wx.getConnectedWifi({
+                success: function (res) {
+                  var ssid = res.wifi.SSID;
+                  // 5Gwifi
+                  if (res.wifi.SSID.indexOf("5G") !== -1) {
+                    that.setData({
+                      is5GWifi: true,
+                      ssid: ssid,
+                    });
+                  } else {
+                    that.setData({
+                      is5GWifi: false,
+                      ssid: ssid,
+                    });
+                  };
+
+                  app.globalData.ssid = ssid;
+                  wx.getStorage({
+                    key: 'wifiInfo',
+                    success(wifiInfo) {
+                      const resData = JSON.parse(wifiInfo.data);
+                      if (resData.ssid === res.wifi.SSID) {
+                        that.setData({
+                          pwdData: resData.password,
+                        });
+                      }
+                    }
+                  })
+                },
+              })
+            }
+          })
+        }
+      }
+    })
+  },
+
+  ///下一步
+  next() {
+    var that = this;
+    if (that.data.ssid === "") {
+      wx.showToast({
+        title: '请输入WIFI名称',
+        icon: 'none',
+        duration: 2000
+      })
+      return;
+    };
+
+    if (that.data.pwdData === "") {
+      wx.showToast({
+        title: '请输入WIFI密码',
+        icon: 'none',
+        duration: 2000
+      })
+      return;
+    };
+
+    app.globalData.ssid = that.data.ssid;
+    app.globalData.pwdData = that.data.pwdData;
+    route_util.jumpParam(route_constant.deviceConnect2, that.data.connectDevice);
+
+  },
+
+  notRoter() {
+    wx.navigateBack({
+      delta: 1
+    });
+  },
+
+  showPwd() {
+    var that = this;
+    that.setData({
+      isShowPwd: !that.data.isShowPwd
+    })
+  },
+
+})

+ 5 - 0
pages/packageA/deviceConnect1/deviceConnect1.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+    "nav-bar": "../../../components/navbar/navbar"
+  }
+}

+ 32 - 0
pages/packageA/deviceConnect1/deviceConnect1.wxml

@@ -0,0 +1,32 @@
+<!--pages/deviceRoter1/deviceRoter1.wxml-->
+<!--pages/deviceRoter0/deviceRoter0.wxml-->
+<view class="deviceRoter deviceRoter1">
+  <nav-bar 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="roterps">
+    <view class="devicePic">
+      <image mode="widthFix" src="../../../img/e.png"></image>
+    </view>
+  </view>
+  <view class="wifiInfo">
+    <view class="ssid">
+      <input placeholder="请输入WIFI名称" bindinput="setSsid" type="text" value="{{ssid}}" maxlength="30" />
+    </view>
+    <view class="ssid pwd" maxlength="30">
+      <input wx:if="{{!isShowPwd}}" class="notShow" bindinput="setPwd" password="true" placeholder="请输入WiFi密码" value="{{pwdData}}" />
+      <input wx:else class="isShow" bindinput="setPwd" placeholder="请输入WiFi密码" value="{{pwdData}}" />
+      <view class="yz" bindtap="showPwd">
+        <image mode="widthFix" src="../../../img/yj{{isShowPwd ? '1' : '0'}}.png"></image>
+      </view>
+    </view>
+    <view class="ps" wx:if="{{is5GWifi}}">
+      <image mode="widthFix" class="" src="../../../img/d.png"></image>
+      <text>该WiFi可能为5GHz WiFi,设备无法连接,请切换其他WiFi</text>
+    </view>
+  </view>
+  <view class="subBtn">
+    <view class="btn" bindtap="next">
+      下一步
+    </view>
+  </view>
+</view>

+ 62 - 0
pages/packageA/deviceConnect1/deviceConnect1.wxss

@@ -0,0 +1,62 @@
+/* pages/deviceRoter1/deviceRoter1.wxss */
+.deviceRoter1 .wifiInfo {
+  padding: 0 66rpx;
+}
+
+.deviceRoter1 .wifiInfo > view.ssid {
+  width: calc(100vw - 136rpx);
+  height: 96rpx;
+  border-radius: 48rpx;
+  border: 2rpx solid #999999;
+  margin-bottom: 40rpx;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+
+.deviceRoter1 .wifiInfo > view.ssid input {
+  width: calc(100% - 104rpx);
+  height: 98rpx;
+  line-height: 98rpx;
+  font-weight: bold;
+  font-size: 32rpx;
+  color: #353535;
+}
+
+.deviceRoter1 .wifiInfo .pwd {
+  position: relative;
+}
+
+.deviceRoter1 .wifiInfo .pwd input {
+  width: calc(100% - 154rpx) !important;
+}
+
+.deviceRoter1 .wifiInfo .pwd .yz {
+  width: 48rpx;
+  height: 98rpx;
+  display: flex;
+  align-items: center;
+}
+
+.deviceRoter1 .wifiInfo .pwd .yz image {
+  width: 48rpx;
+}
+
+.deviceRoter1 .wifiInfo .ps {
+  overflow: hidden;
+}
+
+.deviceRoter1 .wifiInfo .ps image {
+  width: 48rpx;
+  margin-right: 20rpx;
+  line-height: 48rpx;
+  float: left;
+}
+
+.deviceRoter1 .wifiInfo .ps text {
+  float: left;
+  font-size: 28rpx;
+  line-height: 48rpx;
+  color: #FA5151;
+  width: calc(100% - 68rpx);
+}

+ 223 - 0
pages/packageA/deviceConnect2/deviceConnect2.js

@@ -0,0 +1,223 @@
+const app = getApp();
+let xBlufi = require("../../utils/blufi/xBlufi.js");
+import strings from '../../utils/strings.js';
+import lexin_devices from '../../utils/lexin/devices';
+Page({
+
+  data: {
+    nvabarData: {
+      showCapsule: 1, //是否显示左上角图标   1表示显示    0表示不显示
+      title: '连接配网', //导航栏 中间的标题
+    },
+    devicesList: [],
+    searching: false,
+    version: '2.0',
+    name: '',
+    connectedDeviceId: '',
+    connected: true,
+    deviceInfo: null,
+    isInitOK: false,
+    customData: '',
+    isOne: true,
+    isSubmit: false,
+    islanya: false,
+    isOnBluetooth: false,
+    imageUrl: "./../../img/f.png",
+    connectDevice: {},
+  },
+
+  onLoad(options) {
+    const that = this;
+    var param = options.param;
+    if (!strings.isEmpty(param)) {
+      param = JSON.parse(options.param);
+      that.data.connectDevice = param;
+      if (!strings.isEmpty(param.typeList)) {
+        var typeList = param.typeList;
+        typeList = typeList.filter((v) => v.connectType == 3);
+        if (!strings.isEmpty(typeList)) {
+          that.setData({
+            imageUrl: typeList[0].deviceLinkResp.icon2,
+          });
+        }
+      }
+    }
+
+    const isOne = setTimeout(() => {
+      clearTimeout(isOne);
+      if (that.data.isOne) {
+        that.setData({
+          isOne: false,
+        });
+      }
+    }, 2000);
+
+    if (app.globalData.oneInitBluetooth) {
+      app.globalData.oneInitBluetooth = false;
+      xBlufi.initXBlufi(1);
+    };
+
+    xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent);
+    that.Search();
+  },
+
+  onShow() {
+    var that = this;
+    if (!that.data.isOne) {
+      that.Search();
+    }
+  },
+
+  ///开始或结束,也可以过滤名称
+  Search: function () {
+    xBlufi.notifyStartDiscoverBle({
+      'isStart': true,
+    });
+  },
+
+  //   {"type":" 41","result":true,"data":{"errno":0,"errCode":0,"isDiscovering":true,"errMsg":"startBluetoothDevicesDiscovery:ok"}}
+  // {"type":"1","result":true,"data":[{"deviceId":"57:F6:7D:62:D6:C0","name":"","RSSI":-97,"connectable":true,"advertisData":"4c0010072a1fbee24315680100100000000000000000000000000000","advertisServiceUUIDs":[],"localName":"","serviceData":{}}]}
+  // {"type":"1","result":true,"data":[{"deviceId":"57:F6:7D:62:D6:C0","name":"","RSSI":-97,"connectable":true,"advertisData":"4c0010072a1fbee24315680100100000000000000000000000000000","advertisServiceUUIDs":[],"localName":"","serviceData":{}},{"deviceId":"42:E0:22:C2:6E:25","name":"","RSSI":-92,"connectable":true,"advertisData":"4c001007221fa8d7a84ba8","advertisServiceUUIDs":[],"localName":"","serviceData":{}}]}
+  funListenDeviceMsgEvent: function (options) {
+    const that = this;
+    switch (options.type) {
+      //发现设备列表回调开始
+      case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
+        if (!options.result) {
+          console.log("蓝牙未开启 fail =》", options)
+          wx.showToast({
+            title: '蓝牙未开启',
+            icon: 'none'
+          })
+        } else {
+          //蓝牙搜索开始
+          that.setData({
+            searching: true
+          });
+        }
+        break;
+
+        // [{"deviceId":"7C:DF:A1:FD:3A:F2","name":"BLUFI_7cdfa1fd3af0","RSSI":-62,"connectable":true,"advertisData":"","advertisServiceUUIDs":["0000FFFF-0000-1000-8000-00805F9B34FB"],"localName":"BLUFI_7cdfa1fd3af0","serviceData":{}}]
+        ///发现设备列表回调
+      case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
+        // 搜索到蓝牙
+        if (options.result) {
+          var devicesList = options.data.filter((v) => {
+            return v.name.indexOf(lexin_devices.leXin) !== -1;
+          });
+
+          if (!strings.isEmpty(devicesList)) {
+            ///过滤乐鑫设备
+            that.setData({
+              islanya: true,
+              devicesList: devicesList,
+            });
+          }
+        }
+        break;
+
+        // {"type":"0","result":true,"data":{"deviceId":"7C:DF:A1:FD:3A:F2","name":"BLUFI_7cdfa1fd3af0"}}
+        // {"type":"0","result":true,"data":{"deviceId":"7C:DF:A1:FC:BB:26","name":"BLUFI_7cdfa1fcbb24"}}
+        ///主动去连接连接
+      case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
+        wx.hideLoading();
+        if (options.result) {
+          if (that.data.isOnBluetooth) {
+            return;
+          };
+
+          that.setData({
+            isOnBluetooth: true,
+          });
+
+          setTimeout(() => {
+            that.setData({
+              isSubmit: false,
+              islanya: false,
+              devicesList: [],
+              isOnBluetooth: false,
+            });
+            var param = JSON.stringify(that.data.connectDevice);
+            wx.navigateTo({
+              url: '../deviceConnect3/deviceConnect3?deviceId=' + options.data.deviceId + '&name=' + options.data.name + "&param=" + param,
+            });
+          }, 200);
+        } else {
+          wx.showModal({
+            title: '提示',
+            content: '连接失败',
+            showCancel: false
+          });
+        }
+        break;
+
+        ///停止发现设备列表回调
+      case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP:
+        if (options.result) {
+          //蓝牙停止搜索ok
+          console.log('蓝牙停止搜索ok')
+        } else {
+          //蓝牙停止搜索失败
+          console.log('蓝牙停止搜索失败')
+        }
+        that.setData({
+          searching: false
+        });
+        break;
+    }
+  },
+
+  // [{"deviceId":"7C:DF:A1:FC:BB:26","name":"BLUFI_7cdfa1fcbb24","RSSI":-51,"connectable":true,"advertisData":"","advertisServiceUUIDs":["0000FFFF-0000-1000-8000-00805F9B34FB"],"localName":"BLUFI_7cdfa1fcbb24","serviceData":{}}]
+  async Connect(e) {
+    var that = this;
+    const devicesList = that.data.devicesList;
+    if (devicesList.length < 1) {
+      wx.showToast({
+        title: '请短按设备配对键',
+        icon: 'none',
+        duration: 2000
+      });
+      return;
+    };
+
+    if (that.data.isSubmit) {
+      return;
+    };
+
+    that.setData({
+      isSubmit: true
+    });
+
+    // 停止搜索
+    xBlufi.notifyStartDiscoverBle({
+      'isStart': false,
+    });
+
+    //开始连接
+    let name = devicesList[0].name;
+    // console.log('点击了,蓝牙准备连接的deviceId:' + devicesList[0].deviceId)
+    xBlufi.notifyConnectBle({
+      isStart: true,
+      deviceId: devicesList[0].deviceId,
+      name
+    });
+    wx.showLoading({
+      title: '请稍后',
+    });
+  },
+
+  getBluetoothStatus() {
+    app.getBluetoothStatus();
+  },
+
+  notRoter() {
+    wx.navigateBack({
+      delta: 1
+    });
+  },
+
+  onUnload: function () {
+    var that = this;
+    xBlufi.listenDeviceMsgEvent(false, that.funListenDeviceMsgEvent);
+  },
+})

+ 5 - 0
pages/packageA/deviceConnect2/deviceConnect2.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+    "nav-bar": "../../../components/navbar/navbar"
+  }
+}

+ 18 - 0
pages/packageA/deviceConnect2/deviceConnect2.wxml

@@ -0,0 +1,18 @@
+<!--pages/deviceRoter1/deviceRoter1.wxml-->
+<!--pages/deviceRoter0/deviceRoter0.wxml-->
+<view class="deviceRoter deviceRoter0">
+  <nav-bar 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="roterps">
+    <view class="devicePic">
+      <image mode="widthFix" src="{{imageUrl}}"></image>
+    </view>
+    <text>短按设备背面“配对”键,
+      当听见语音提示“进入WiFi配对模式”时,即可进入下一步</text>
+  </view>
+  <view class="subBtn">
+    <view class="btn" style="opacity: {{islanya ? '1' : '0.6'}};" bindtap="Connect">
+      {{'下一步'}}
+    </view>
+  </view>
+</view>

+ 1 - 0
pages/packageA/deviceConnect2/deviceConnect2.wxss

@@ -0,0 +1 @@
+/* pages/deviceRoter2/deviceRoter2.wxss */

+ 221 - 0
pages/packageA/deviceConnect3/deviceConnect3.js

@@ -0,0 +1,221 @@
+// pages/deviceConnect3/deviceConnect3.ts
+const app = getApp();
+let xBlufi = require("../../utils/blufi/xBlufi.js");
+import strings from '../../utils/strings.js';
+import route_util from '../../utils/route_util.js';
+import route_constant from '../../utils/route_constant.js'
+let percentIn = null;
+let errTi = null;
+
+Page({
+  data: {
+    nvabarData: {
+      showCapsule: 1, //是否显示左上角图标   1表示显示    0表示不显示
+      title: '连接配网', //导航栏 中间的标题
+    },
+    scopeBluetooth: app.globalData.scopeBluetooth,
+    ssid: app.globalData.ssid,
+    password: app.globalData.pwdData,
+    version: '2.0',
+    name: '',
+    connectedDeviceId: '',
+    connected: true,
+    deviceInfo: null,
+    isInitOK: false,
+    customData: '',
+    percent: 0,
+    ruterStatus: 0, // 0 连接中 // 1 成功 // 2失败
+    imageUrl: "./../../img/g.png",
+  },
+
+  onLoad: function (options) {
+    var that = this;
+    var param = options.param;
+    if (!strings.isEmpty(param)) {
+      param = JSON.parse(param);
+      that.setData({
+        imageUrl: param.img,
+      });
+    }
+
+    that.setData({
+      name: options.name,
+      connectedDeviceId: options.deviceId,
+    })
+
+    xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent);
+    ///通知初始化获取设备的服务列表等信息
+    xBlufi.notifyInitBleEsp32({
+      deviceId: options.deviceId,
+    });
+
+    percentIn = setInterval(() => {
+      if (that.data.percent === 100) {
+        clearInterval(percentIn);
+        ///失败
+        that.setData({
+          ruterStatus: 2
+        });
+        return;
+      };
+      that.data.percent++;
+      that.setData({
+        percent: that.data.percent
+      });
+    }, 600);
+  },
+
+  // {"type":"2","result":true,"data":{"deviceId":"7C:DF:A1:FD:3A:F2","serviceId":"0000FFFF-0000-1000-8000-00805F9B34FB","characteristicId":"0000FF01-0000-1000-8000-00805F9B34FB"}}
+  // {"type":"4","result":false,"data":{"progress":0,"ssid":""}}
+  // {"type":"4","result":true,"data":{"progress":100,"ssid":"muzen\u0000"}}
+  funListenDeviceMsgEvent: function (options) {
+    var that = this;
+    switch (options.type) {
+      // {"type":"2","result":true,"data":{"deviceId":"7C:DF:A1:FD:3A:F2","serviceId":"0000FFFF-0000-1000-8000-00805F9B34FB",
+      // "characteristicId":"0000FF01-0000-1000-8000-00805F9B34FB"}}
+      case xBlufi.XBLUFI_TYPE.TYPE_INIT_ESP32_RESULT:
+        if (options.result) {
+          console.log('初始化成功');
+          that.OnClickStart();
+        } else {
+          console.log('初始化失败')
+          that.setData({
+            connected: false
+          })
+          that.setData({
+            ruterStatus: 2
+          });
+        }
+        break;
+
+        // {"type":"4","result":false,"data":{"progress":0,"ssid":""}}
+        // {"type":"4","result":true,"data":{"progress":100,"ssid":"muzen\u0000"}}
+        ///连接结果
+      case xBlufi.XBLUFI_TYPE.TYPE_CONNECT_ROUTER_RESULT:
+        if (!options.result) {
+          errTi = setTimeout(() => {
+            that.setData({
+              ruterStatus: 2
+            });
+            clearTimeout(errTi);
+            clearInterval(percentIn);
+          }, 5000);
+        } else {
+          // 配网成功
+          if (options.data.progress == 100) {
+            var deviceId = that.data.name;
+            var device = {
+              connectType: 3,
+              devName: "",
+              state: "online",
+              name: deviceId,
+              deviceId: deviceId,
+              mac: deviceId,
+              imageUrl: that.data.imageUrl,
+              // imageUrl: "./../../img/min.png",
+            }
+            getCurrentPages()[0].addWifiDevice(device);
+            // [{"deviceId":"BLUFI_7cdfa1fcbb24","name":"BLUFI_7cdfa1fcbb24","state":"online"}]
+            // 记住密码
+            wx.setStorage({
+              key: "wifiInfo",
+              data: JSON.stringify({
+                "password": app.globalData.pwdData,
+                "ssid": app.globalData.ssid
+              }),
+            });
+
+            setTimeout(() => {
+              clearTimeout(errTi);
+              clearInterval(percentIn);
+              that.setData({
+                percent: 100,
+                ruterStatus: 1,
+              });
+            }, 500);
+          }
+        }
+        break;
+
+        ///设备连接状态回调
+      case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED:
+        that.setData({
+          connected: options.result
+        });
+        if (!options.result) {
+          wx.showModal({
+            title: '很抱歉提醒你!',
+            content: '小程序与设备异常断开',
+            showCancel: false, //是否显示取消按钮
+            success: function (res) {
+              wx.navigateBack({
+                delta: 1
+              });
+            },
+          });
+        }
+        break;
+    }
+  },
+
+  ///校验wifi账号密码
+  OnClickStart: function () {
+    if (!app.globalData.ssid) {
+      wx.showToast({
+        title: 'SSID不能为空',
+        icon: 'none'
+      })
+      return
+    }
+
+    if (!app.globalData.pwdData) {
+      wx.showToast({
+        title: '密码不能为空',
+        icon: 'none'
+      })
+      return;
+    }
+
+    xBlufi.notifySendRouterSsidAndPassword({
+      ssid: app.globalData.ssid,
+      password: app.globalData.pwdData
+    });
+  },
+
+  bindPasswordInput: function (e) {
+    var that = this;
+    that.setData({
+      password: e.detail.value
+    })
+  },
+
+  bindCustomDataInput: function (e) {
+    var that = this;
+    that.setData({
+      customData: e.detail.value
+    })
+  },
+  egen() {
+    wx.navigateBack({
+      delta: 1
+    })
+  },
+
+  goIndex() {
+    route_util.goBackRoute(route_constant.indexRoot);
+  },
+
+  onUnload: function () {
+    // 关闭蓝牙连接
+    var that = this
+    xBlufi.notifyConnectBle({
+      isStart: false,
+      deviceId: that.data.connectedDeviceId,
+      name: that.data.name,
+    });
+
+    xBlufi.listenDeviceMsgEvent(false, that.funListenDeviceMsgEvent);
+    clearTimeout(errTi);
+    clearInterval(percentIn);
+  },
+})

+ 5 - 0
pages/packageA/deviceConnect3/deviceConnect3.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+    "nav-bar": "../../../components/navbar/navbar"
+  }
+}

+ 36 - 0
pages/packageA/deviceConnect3/deviceConnect3.wxml

@@ -0,0 +1,36 @@
+<!-- pages/deviceRoter1/deviceRoter1.wxml -->
+<!-- pages/deviceRoter0/deviceRoter0.wxml -->
+<view class="deviceRoter deviceRoter3">
+  <nav-bar 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="roterps">
+    <view class="devicePic">
+      <image mode="widthFix" src="{{imageUrl}}"></image>
+    </view>
+    <view class="lodRuter" wx:if="{{ruterStatus === 0}}">
+      <text>正在连接中,请保持设备开机状态…</text>
+      <progress color="#6547A3" percent="{{percent}}" show-info stroke-width="3" />
+    </view>
+    <view class="suRuter" wx:elif="{{ruterStatus === 1}}">
+      <image style="height:48rpx; width:48rpx;" mode="aspectFit" src="../../../img/h.png"></image>
+      <text>连接成功</text>
+    </view>
+    <view class="suRuter" wx:elif="{{ruterStatus === 2}}">
+      <image style="height:48rpx; width:48rpx;" mode="aspectFit" src="../../../img/i.png"></image>
+      <text>连接失败</text>
+    </view>
+    <view class="errorPs" wx:if="{{ruterStatus === 2}}">
+      <text>请尝试:</text>
+      <view>· 部分设备配网需开启GPS定位。</view>
+      <view>· 尝试重启手机蓝牙,如蓝牙已连接其他设备,请先断开。</view>
+      <view>
+        · 连接设备WiFi可能为5GHz WiFi,设备无法连接,请切换至
+        <text style="color: #6547A3">2.4GHz WiFi</text>
+      </view>
+    </view>
+  </view>
+  <view class="subBtn">
+    <view wx:if="{{ruterStatus === 0}}" class="btn" style="opacity: 0.6">连接中...</view>
+    <view wx:elif="{{ruterStatus === 1}}" class="btn" bindtap="goIndex">完成</view>
+    <view wx:else style="background-color: #353535;" class="btn" bindtap="egen">重新连接</view>
+  </view>
+</view>

+ 37 - 0
pages/packageA/deviceConnect3/deviceConnect3.wxss

@@ -0,0 +1,37 @@
+/* pages/deviceRoter3/deviceRoter3.wxss */
+.lodRuter{
+  margin-top: 54rpx;
+}
+.lodRuter text{
+  text-align: center;
+  width: 100%;
+  display: block;
+  margin-bottom: 34rpx;
+}
+.suRuter{
+  margin-top: 54rpx;
+  display: flex;
+  justify-content: center;
+}
+.suRuter image{
+  width: 48rpx;
+}
+.suRuter text{
+  color: #353535;
+  font-size: 36rpx;
+  margin-left: 20rpx;
+}
+.errorPs{
+  margin-top: 150rpx;
+}
+.errorPs >text{
+  color: #353535;
+  font-size: 28rpx;
+  font-weight: bold;
+  line-height: 40rpx;
+}
+.errorPs >view{
+  color: #353535;
+  font-size: 28rpx;
+  line-height: 40rpx;
+}