程志平 3 years ago
parent
commit
e80f0f6cdb
2 changed files with 57 additions and 30 deletions
  1. 53 29
      pagesAir/shareAir/shareAir.vue
  2. 4 1
      pagesAir/stdBookMgr/stdBookMgr.vue

+ 53 - 29
pagesAir/shareAir/shareAir.vue

@@ -69,7 +69,8 @@
 								<text>启动时间:</text><text>{{item.time}}</text>
 							</view>
 						</view>
-						<view class="item-right" @tap="btn_click(index, item.air_ip, item.name, item.info, item.order_num)">
+						<view class="item-right"
+							@tap="btn_click(index, item.air_ip, item.name, item.info, item.order_num)">
 							<view class="item-btn">
 								<image src="../static/images/power-off.png" mode="aspectFit"></image>
 								<view class="item-txt-off">
@@ -92,8 +93,8 @@
 								<text>未启动</text>
 							</view>
 						</view>
-						<view class="item-right" @tap="btn_click(index, item.air_ip, item.name, item.info, item.order_num)"
-							:ref="index">
+						<view class="item-right"
+							@tap="btn_click(index, item.air_ip, item.name, item.info, item.order_num)" :ref="index">
 							<view class="item-btn">
 								<image src="../static/images/power-on.png" mode="aspectFit"></image>
 								<view class="item-txt-on">
@@ -143,14 +144,14 @@
 		},
 		onLoad(options) {
 			this.options = options
-			try{
+			try {
 				// 选择绑定了的空调
 				let airs_selected = uni.getStorageSync('airs_selected')
 				if (airs_selected.length > 0) {
 					// 使用存储的列表
 					this.selectAirs = airs_selected
 				}
-			}catch(e){
+			} catch (e) {
 				console.log('读取空调相关信息:' + e.message);
 			}
 		},
@@ -199,6 +200,10 @@
 
 			// 获取基本信息
 			this.get_base_info(this.options, 'onLoad')
+
+			setTimeout(() => {
+				uni.hideLoading();
+			}, 3000)
 		},
 		methods: {
 			/**
@@ -242,7 +247,7 @@
 								(function(t, tmpAirs) { // 注意这里是形参
 									setTimeout(function() {
 										_this.readAirsStatus(tmpAirs, t);
-									}, 100 * t); // 还是秒执行一次,不是累加的
+									}, 100 * t); // 还是0.1秒执行一次,不是累加的
 								})(i, tmpAirs) // 注意这里是实参,这里把要用的参数传进去
 							}
 
@@ -290,18 +295,31 @@
 					}
 				})
 
-				// console.log(res.data);
+				console.log(res.data, tmpAirs[index].air_ip);
 				if (res.data.code == 200) {
 					let data = res.data;
-					if (data.is_on == 1) {
-						for (var i = 0; i < tmpAirs.length; i++) {
-							if (tmpAirs[i].air_ip == tmpAirs[index].air_ip) {
-								tmpAirs[i].on = true
-								tmpAirs[i].time = data.start_time
-							}
+					if (data.is_on === '1') {
+						if (typeof data.order_num === 'undefined') {
+							// 提示返回信息
+							uni.showToast({
+								icon: 'none',
+								title: '订单号为空,却是开启状态!',
+								duration: 3000
+							})
 						}
+						tmpAirs[index].on = true
+						tmpAirs[index].time = data.start_time
+						tmpAirs[index].order_num = data.order_num
 					}
+					// 更新自己绑定的空调列表
 					this.airs.push(tmpAirs[index])
+				} else {
+					// uni.showToast({
+					// 	icon: 'none',
+					// 	title: tmpAirs[index].air_ip + ' ' + res.data.message,
+					// 	duration: 3000
+					// })
+					// console.log(tmpAirs[index].air_ip + ' ' + res.data.message);
 				}
 			},
 			/**
@@ -346,10 +364,10 @@
 				// 获取code
 				this.getCode(options, param)
 
-				if (this.id_card !== '') {
-					// 查询绑定的空调
-					this.select_banding_airs()
-				}
+				// if (this.id_card !== '') {
+				// 	// 查询绑定的空调
+				// 	this.select_banding_airs()
+				// }
 			},
 			/**
 			 * 获得code
@@ -610,20 +628,24 @@
 					}
 				})
 
-				console.log(res.data);
+				// console.log(res.data)
 				if (res.data.code == 200) {
-					// 等待1s
+					// 等待12s
 					uni.showLoading({
 						title: '关闭中...',
 						mask: true
 					});
-					// 延时1s看开启状态
+					// 延时12s看关闭状态
 					let _this = this;
 					setTimeout(() => {
-						// 查询是否开启成功
+						// 查询是否关闭成功
 						_this.selectAirCloseState(index, air_ip, order_num)
-					}, 1000);
+					}, 12000);
 				} else {
+					if (res.data.message == '该订单已结算,请勿重复结算') {
+						// 显示已经关闭图标
+						this.airs[index].on = false
+					}
 					uni.showToast({
 						icon: 'none',
 						title: res.data.message,
@@ -651,9 +673,9 @@
 					}
 				})
 
-				console.log(res.data);
+				// console.log(res.data);
 				if (res.data.code == 200) {
-					if (res.data.is_on == 0) {
+					if (res.data.is_on === '0') {
 						// 显示已经关闭图标
 						this.airs[index].on = false
 						uni.showToast({
@@ -705,15 +727,17 @@
 					}
 				})
 
-				console.log(res.data);
+				// console.log(res.data);
 				if (res.data.code == 200) {
 					// 等待12s
 					uni.showLoading({
 						title: '开启中...',
 						mask: true
 					});
-					// 延时12s看开启状态
 					let _this = this;
+					// 获取订单号
+					this.airs[index].order_num = res.data.order_num
+					// 延时12s看开启状态
 					setTimeout(() => {
 						// 查询是否开启成功
 						_this.selectAirOpenState(index, air_ip)
@@ -742,13 +766,13 @@
 					},
 					data: {
 						air_ip: air_ip,
-						order_num: this.order_num
+						order_num: this.airs[index].order_num
 					}
 				})
 
-				console.log(res.data);
+				// console.log(res.data);
 				if (res.data.code == 200) {
-					if (res.data.is_on == 1) {
+					if (res.data.is_on === '1') {
 						let _this = this
 						uni.showToast({
 							title: '开启成功!',

+ 4 - 1
pagesAir/stdBookMgr/stdBookMgr.vue

@@ -164,7 +164,6 @@
 						page: 1,
 						rows: 90,
 						sfzh: this.id_card,
-						// sfzh: '360313110',
 						con_month: this.selYearMonth
 					}
 				})
@@ -176,6 +175,8 @@
 						title: '暂无消费数据',
 						duration: 1500
 					})
+					// 清空列表
+					this.consumeRecords = []
 					return
 				}
 				if (data.code === 200) {
@@ -184,6 +185,8 @@
 							title: '暂无消费数据',
 							duration: 1500
 						})
+						// 清空列表
+						this.consumeRecords = []
 						return
 					}
 					let tmpRecord = []