柒零 1 жил өмнө
parent
commit
8ff618d824

+ 36 - 38
subpages/addMattresses/addMattresses.js

@@ -11,14 +11,14 @@ Page({
    * 页面的初始数据
    */
   data: {
-    isEdit:false,
+    isEdit: false,
     showBluetoothList: false,
     showBluetoothConnected: false,//连接中
     isBluetoothConnected: false,//连接成功
     bluetoothConnectedStep: 0,
     placeOfUse: "",
     usingHuman: "",
-    pid:"",
+    pid: "",
     sn: "",
     ssid: "",
     password: "",
@@ -61,22 +61,26 @@ Page({
   onClose() {
     this.setData({ showBluetoothList: false, showBluetoothConnected: false });
   },
+  closeEndDialog() {
+    this.onClose()
+    wx.navigateBack()
+  },
   checkBluetoothSelectIndex(e) {
     const index = e.currentTarget.dataset.index;
     this.setData({ bluetoothSelectIndex: index });
 
   },
-  commitData() { 
+  commitData() {
     console.log(this.data.placeOfUse);
     console.log(this.data.usingHuman);
     console.log(this.data.sn);
     console.log(this.data.ssid);
     console.log(this.data.password);
     this.checkSn(this.data.sn);
-   
-    
+
+
   },
-  commitUserData() { 
+  commitUserData() {
     const that = this;
     if (that.data.isEdit) {
       wx.request({
@@ -96,9 +100,6 @@ Page({
               icon: 'none',
               title: "添加成功"
             });
-            setTimeout(() => {
-              wx.navigateBack()
-            }, 800);
           } else {
             wx.showToast({
               icon: 'none',
@@ -132,9 +133,6 @@ Page({
             icon: 'none',
             title: "添加成功"
           });
-          setTimeout(() => {
-            wx.navigateBack()
-          }, 800);
         } else {
           wx.showToast({
             icon: 'none',
@@ -162,14 +160,14 @@ Page({
       fail(res) {
         console.log(res);
         wx.showToast({
-          icon:'none',
+          icon: 'none',
           title: "请打开系统蓝牙"
         });
       }
     })
   },
-// 获取蓝牙设备列表
-  getBluDevice () {
+  // 获取蓝牙设备列表
+  getBluDevice() {
     var self = this;
     //第一步检查蓝牙适配器是否可用
     wx.onBluetoothAdapterStateChange(function (res) {
@@ -189,7 +187,7 @@ Page({
                   success: function (res) {
                     wx.onBluetoothDeviceFound(function (res) {
                       console.log(res);
-                      
+
                       var list = util.filterDevice(res.devices, "name");
                       if (list.length > 0) {
                         console.log('==========onBluetoothDeviceFound===========');
@@ -239,7 +237,7 @@ Page({
                                 deviceList.push(item);
                                 self.setData({
                                   deviceList: deviceList,
-                                  showBluetoothList:true
+                                  showBluetoothList: true
                                 });
                                 wx.setStorageSync('deviceList', deviceList);
                               },
@@ -281,7 +279,7 @@ Page({
     })
     wx.offBluetoothDeviceFound()
   },
-// 开始配网
+  // 开始配网
   bindViewConnect() {
     const that = this;
     if (that.data.bluetoothSelectIndex < 0) {
@@ -297,7 +295,7 @@ Page({
 
     that.gotoProvision()
   },
-// 获取Wifi
+  // 获取Wifi
   getWifiInfo: function () {
     wx.startWifi({
       success(res) {
@@ -339,7 +337,7 @@ Page({
           },
           fail: function (err) {
             util.showToast("获取Wi-Fi信息失败");
-           
+
           }
         })
         wx.onWifiConnected(function (res) {
@@ -379,7 +377,7 @@ Page({
       }
     }
   },
-// 蓝牙链接
+  // 蓝牙链接
   blueConnect: function (event) {
     //console.log(' =============== blueConnect start ===============')
     var self = this;
@@ -388,9 +386,9 @@ Page({
       flagEnd: false,
       serviceId: "",
       uuid: "",
-      showBluetoothConnected:true
+      showBluetoothConnected: true
     });
-    self.setProcess(0, util.descSucList[0],1);
+    self.setProcess(0, util.descSucList[0], 1);
     //第一步检查蓝牙适配器是否可用
     wx.onBluetoothAdapterStateChange(function (res) {
       if (!res.available) {
@@ -440,7 +438,7 @@ Page({
       // 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接 
       deviceId: deviceId,
       success: function (res) {
-        self.setProcess(10, util.descSucList[1],2);
+        self.setProcess(10, util.descSucList[1], 2);
         var services = res.services;
         if (services.length > 0) {
           for (var i = 0; i < services.length; i++) {
@@ -466,7 +464,7 @@ Page({
       deviceId: deviceId,
       serviceId: serviceId,
       success: function (res) {
-        self.setProcess(40, util.descSucList[2],3);
+        self.setProcess(40, util.descSucList[2], 3);
         var list = res.characteristics;
         if (list.length > 0) {
           for (var i = 0; i < list.length; i++) {
@@ -541,7 +539,7 @@ Page({
     //console.log("===== writeDevice =====");
     var self = this,
       obj = {};
-    self.setProcess(60, util.descSucList[4],3);
+    self.setProcess(60, util.descSucList[4], 3);
     sequenceControl = parseInt(sequenceControl) + 1;
     if (!util._isEmpty(data)) {
       obj = util.isSubcontractor(data, true, sequenceControl);
@@ -560,7 +558,7 @@ Page({
         if (obj.flag) {
           self.writeDevice(deviceId, serviceId, characteristicId, obj.laveData);
         } else {
-          self.setProcess(80, util.descSucList[5],4);
+          self.setProcess(80, util.descSucList[5], 4);
         }
       },
       fail: function (res) {
@@ -614,7 +612,7 @@ Page({
         self.blueConnect();
       } else {
         self.setProcess(90, 'SN:' + deviceSn + ' 连接成功', 5);
-        self.setProcess(100, util.descSucList[6],7);
+        self.setProcess(100, util.descSucList[6], 7);
         self.setData({
           result: [],
         })
@@ -623,7 +621,7 @@ Page({
       self.setFailProcess(true, res.errCode + "::" + util.descFailList[4])
     }
   },
-  setProcess: function (value, desc,step = 0) {
+  setProcess: function (value, desc, step = 0) {
     var self = this,
       list = [];
     list = self.data.processList;
@@ -633,7 +631,7 @@ Page({
     if (self.data.value <= value) {
       self.setData({
         value: value,
-        bluetoothConnectedStep:step
+        bluetoothConnectedStep: step
       });
     }
     self.setData({
@@ -646,7 +644,7 @@ Page({
       self.closeConnect();
       wx.closeBluetoothAdapter();
       self.setData({
-        isBluetoothConnected:true,
+        isBluetoothConnected: true,
         desc: util.descSucList[6]
       });
       clearInterval(timeId);
@@ -679,7 +677,7 @@ Page({
     this.getWifiInfo();
     if (options.type && options.type == "edit") {
       wx.setNavigationBarTitle({
-        title:"编辑床垫"
+        title: "编辑床垫"
       })
       const item = wx.getStorageSync("item");
       if (item) {
@@ -698,12 +696,12 @@ Page({
     }
 
   },
-//   实验室
-// 测试
-//  332016850591
-//  sleep
-// sleep1234
-  checkSn(sntram) { 
+  //   实验室
+  // 测试
+  //  332016850591
+  //  sleep
+  // sleep1234
+  checkSn(sntram) {
     const that = this;
     wx.request({
       url: 'https://aipush.aidsleep.cn/wxchecksn',

+ 1 - 1
subpages/addMattresses/addMattresses.wxml

@@ -74,7 +74,7 @@
                 </view>
             </view>
             <view wx:if="{{!isBluetoothConnected}}" style="height: 50rpx;"></view>
-            <text wx:else class="bluetoothConnectedView-btn" bindtap="onClose">确定</text>
+            <text wx:else class="bluetoothConnectedView-btn" bindtap="closeEndDialog">确定</text>
         </view>
     </van-popup>