程志平 3 years ago
parent
commit
0441478080
3 changed files with 74 additions and 58 deletions
  1. 2 2
      pages/index/index.vue
  2. 66 51
      pages/reshui/reshui.vue
  3. 6 5
      pagesElectric/show/show.vue

+ 2 - 2
pages/index/index.vue

@@ -13,14 +13,14 @@
 					<image src="../../static/images/recharge2x.png" mode=""></image>
 					<text>水电充值</text>
 				</navigator>
-				<navigator :url="'/pagesAir/shareAir/shareAir'" open-type="navigate" class="menu_item">
+				<!-- <navigator :url="'/pagesAir/shareAir/shareAir'" open-type="navigate" class="menu_item">
 					<image src="../../static/images/air.png" mode=""></image>
 					<text>共享空调</text>
 				</navigator>
 				<navigator :url="'/pagesClockIn/index/index'" open-type="navigate" class="menu_item">
 					<image src="../../static/images/clockIn.png" mode=""></image>
 					<text>校园打卡</text>
-				</navigator>
+				</navigator> -->
 			</view>
 		</view>
 		<view class="qr_code" v-if="showQR_code">

+ 66 - 51
pages/reshui/reshui.vue

@@ -9,7 +9,8 @@
 				</view>
 				<view class="qinshihao">
 					<!-- <text class="iconfont icon-zhuye"></text> -->
-					<image :src="require('./images/icon-zhuye.png')" style="width: 28rpx; margin-right: 8rpx;" mode="aspectFit"></image>
+					<image :src="require('./images/icon-zhuye.png')" style="width: 28rpx; margin-right: 8rpx;"
+						mode="aspectFit"></image>
 					<text class="dormtxt">{{dorm_number || '宿舍未知'}}</text>
 				</view>
 			</view>
@@ -66,8 +67,8 @@
 						<view class="uni-input">
 							<text>{{date}}</text>
 							<!-- <text class="iconfont icon-arrow-down"></text> -->
-							<image :src="require('./images/icon-arrow-down.png')"
-								style="width: 26rpx;" mode="aspectFit">
+							<image :src="require('./images/icon-arrow-down.png')" style="width: 26rpx;"
+								mode="aspectFit">
 							</image>
 						</view>
 					</picker>
@@ -243,7 +244,7 @@
 							});
 
 							setTimeout(() => {
-								_this.setInit();
+								_this.myInit();
 							}, 100);
 						} else {
 							uni.showToast({
@@ -1029,7 +1030,7 @@
 							this.connect_BLE()
 						} else {
 							uni.showToast({
-								title: '错误:' + err.errMsg,
+								title: '水表蓝牙连接被占用!',
 								icon: 'none',
 								duration: 3000,
 								success: (res1) => {
@@ -1075,8 +1076,11 @@
 							title: '获取服务失败',
 							icon: 'none',
 							duration: 3000
-						})
-						return
+						});
+
+						this.setInit();
+
+						return;
 					}
 				});
 			},
@@ -1246,31 +1250,36 @@
 			 * 关闭连接
 			 */
 			closeBLEConnection() {
-				uni.closeBLEConnection({
-					deviceId: this.deviceId,
-					success: () => {
-						// 关闭蓝牙模块
-						this.closeBluetoothAdapter()
-					},
-					fail: () => {
-						this.setInit()
-						// uni.showToast({
-						// 	icon: 'none',
-						// 	title: '蓝牙连接断开失败',
-						// 	duration: 3000,
-						// 	success: (res1) => {
-						// 		this.setInit()
-						// 	}
-						// })
-					}
-				})
+				if (this.deviceId) {
+					uni.closeBLEConnection({
+						deviceId: this.deviceId,
+						success: () => {
+							// 关闭蓝牙模块
+							this.closeBluetoothAdapter()
+						},
+						fail: (err) => {
+							// this.setInit()
+							// uni.showToast({
+							// 	icon: 'none',
+							// 	title: err.errMsg,
+							// 	duration: 3000,
+							// 	success: (res1) => {
+							// 		this.setInit()
+							// 	}
+							// })
+						}
+					});
+				} else {
+					// 关闭蓝牙模块
+					this.closeBluetoothAdapter()
+				}
 			},
 
 			closeBluetoothAdapter() {
 				// 关闭蓝牙模块
 				uni.closeBluetoothAdapter({
 					success: () => {
-						this.setInit()
+						this.myInit();
 
 						if (this.isUserClose == false) { // 设备端结束用水
 							if (this.isChecked) {
@@ -1279,14 +1288,14 @@
 									icon: 'none',
 									title: '设备端已结束用水,蓝牙断开成功',
 									duration: 3000
-								})
+								});
 							} else {
 								// console.log('用户重启扫描,蓝牙断开成功')
 								uni.showToast({
 									icon: 'none',
 									title: '用户重启扫描,蓝牙断开成功',
 									duration: 3000
-								})
+								});
 							}
 						} else { // 手机移动端结束用水
 							// console.log('APP端已结束用水,蓝牙断开成功')
@@ -1294,34 +1303,40 @@
 								icon: 'none',
 								title: 'APP端已结束用水,蓝牙断开成功',
 								duration: 3000
-							})
+							});
 						}
 					}
 				})
 			},
 
 			setInit() {
+				this.closeBLEConnection();
+
+				this.myInit();
+			},
+
+			myInit() {
 				setTimeout(() => {
-					this.isUserClose = false
-					this.isChecked = false
-					this.isConnected = false
-					this.isScan = false
-					this.active = -1
-					this.device_code = '' // 设备编号
-					this.devices = [] // 保存设备, 加了【空中连接】,不需要置为空。
-					this.deviceId = '' // 加了【空中连接】,不需要置为空。
-					this.serviceId = ''
-					this.characteristicIdForWrite = ''
-					this.characteristicIdForNotity = ''
-					this.deviceIsNotify = false
-					this.deviceIsWrite = false
-					this.byte35 = '' // 70 个字符
-					this.byte35_tmp = '' // 70 个字符 临时变量
-
-					this.get_Bluetooth_Bevice = false
-					this.rooms = [] // 宿舍号,蓝牙连接具有时效性,断开连接后清空
-					this.start_code = ''
-				}, 200)
+					this.isUserClose = false;
+					this.isChecked = false;
+					this.isConnected = false;
+					this.isScan = false;
+					this.active = -1;
+					this.device_code = ''; // 设备编号
+					this.devices = []; // 保存设备, 加了【空中连接】,不需要置为空。
+					this.deviceId = ''; // 加了【空中连接】,不需要置为空。
+					this.serviceId = '';
+					this.characteristicIdForWrite = '';
+					this.characteristicIdForNotity = '';
+					this.deviceIsNotify = false;
+					this.deviceIsWrite = false;
+					this.byte35 = ''; // 70 个字符
+					this.byte35_tmp = ''; // 70 个字符 临时变量
+
+					this.get_Bluetooth_Bevice = false;
+					this.rooms = []; // 宿舍号,蓝牙连接具有时效性,断开连接后清空
+					this.start_code = '';
+				}, 300);
 			},
 
 			/**
@@ -1457,7 +1472,7 @@
 					if (typeof this.byte35 == 'undefined' || this.byte35 == '') {
 						uni.showToast({
 							icon: 'none',
-							title: '字节码空!'
+							title: '获取字节码空!'
 						});
 					}
 
@@ -1512,7 +1527,7 @@
 				} else {
 					uni.showToast({
 						icon: 'success',
-						title: '字节码空!'
+						title: '结算字节码空!'
 					});
 					// 初始化
 					this.setInit()

+ 6 - 5
pagesElectric/show/show.vue

@@ -252,9 +252,10 @@
 						let data = []
 						for (var i = 0; i < res.data.rows.length; i++) {
 							dt = res.data.rows[i].dataTime
+							// chrt_data.categories.push(dt.substr(dt.indexOf('-') + 1, dt.length) + '月')
 							chrt_data.categories.push(parseInt(dt.substr(dt.indexOf('-') + 1, dt.length)) + '月')
-							temp = res.data.rows[i].totalMoney
-							temp = temp.toFixed(2)
+							temp = (res.data.rows[i].totalMoney).toFixed(2)
+							// temp = temp
 							data.push(temp)
 							if (parseFloat(temp) > parseFloat(elc_max)) {
 								elc_max = temp
@@ -271,12 +272,12 @@
 							setTimeout(() => {
 								this.chartOpts.yAxis.data[0].max = parseInt(10)
 								this.chartData = chrt_data;
-							}, 1000);
+							}, 500);
 						} else {
 							setTimeout(() => {
-								this.chartOpts.yAxis.data[0].max = parseInt(m + 5)
+								this.chartOpts.yAxis.data[0].max = parseInt(m + 10)
 								this.chartData = chrt_data;
-							}, 1000);
+							}, 500);
 						}
 					} else {
 						this.btn = false