Преглед изворни кода

feature: 加入配置君正配网条件模式

332777428@qq.com пре 5 месеци
родитељ
комит
9679a232fa

+ 12 - 3
pages/deviceConnect2/deviceConnect2.js

@@ -143,9 +143,18 @@ Page({
               isOnBluetooth: false,
             });
             var param = JSON.stringify(that.data.connectDevice);
-            wx.navigateTo({
-              url: '../deviceConnect3/deviceConnect3?deviceId=' + options.data.deviceId + '&name=' + options.data.name + "&param=" + param,
-            });
+            var name = devicesList[0].name;
+            var isLexin = name.indexOf(lexin_devices.leXin) !== -1;
+            if (isLexin) {
+              wx.navigateTo({
+                url: '../deviceConnect3/deviceConnect3?deviceId=' + options.data.deviceId + '&name=' + options.data.name + "&param=" + param,
+              });
+            } else {
+              wx.navigateTo({
+                url: '../deviceConnect4/deviceConnect4?deviceId=' + options.data.deviceId + '&name=' + options.data.name + "&param=" + param,
+              });
+            }
+
           }, 200);
         } else {
           wx.showModal({

+ 53 - 0
pages/deviceConnect4/deviceConnect4.js

@@ -0,0 +1,53 @@
+const app = getApp();
+import strings from '../../utils/strings.js';
+const {
+  BleUtil
+} = require('../../utils/blue_ble/util');
+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,
+      });
+    }
+
+    // AIrSMArT_861210052356337===D0:31:10:86:AC:9A
+    var name = options.name;
+    var deviceId = options.deviceId;
+    that.setData({
+      name: name,
+      connectedDeviceId: deviceId,
+    });
+
+    var device = {
+      "deviceId": deviceId
+    };
+    console.log("gadsfasdfadfaf===000==" + JSON.stringify(device));
+    BleUtil.getInstance().startConnect(device, function (changed) {
+      console.log("gadsfasdfadfaf===111==" + changed);
+    });
+  },
+})

+ 5 - 0
pages/deviceConnect4/deviceConnect4.json

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

+ 36 - 0
pages/deviceConnect4/deviceConnect4.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/deviceConnect4/deviceConnect4.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;
+}

+ 22 - 0
utils/junzheng/util.js

@@ -0,0 +1,22 @@
+module.exports = {
+  isJungzheng1: isJungzheng1,
+  isJungzheng2: isJungzheng2,
+}
+
+function isJungzheng1(deviceId) {
+  const lexin_devices = require('../../utils/lexin/devices');
+  var deviceIdJunZheng1 = deviceId.split(lexin_devices.junZheng1);
+  var isJunZheng1 = deviceIdJunZheng1.length == 2;
+  var deviceIdJunZheng3 = deviceId.split(lexin_devices.junZheng13);
+  var isJunZheng3 = deviceIdJunZheng3.length == 2;
+  return isJunZheng1 && !isJunZheng3;
+};
+
+function isJungzheng2(deviceId) {
+  const lexin_devices = require('../../utils/lexin/devices');
+  var deviceIdJunZheng2 = deviceId.split(lexin_devices.junZheng2);
+  var isJunZheng2 = deviceIdJunZheng2.length == 2;
+  var deviceIdJunZheng3 = deviceId.split(lexin_devices.junZheng13);
+  var isJunZheng3 = deviceIdJunZheng3.length == 2;
+  return isJunZheng2 && !isJunZheng3;
+};