程志平 3 years ago
parent
commit
5ad26409b7

+ 12 - 0
pages/index/index.vue

@@ -52,6 +52,7 @@
 		},
 		onLoad(options) {
 			// console.log(options)
+			// 测试环境
 			if (typeof(options.from) != 'undefined') {
 				this.from = options.from
 			}
@@ -90,8 +91,19 @@
 					// value为0 测试环境, 为1 部署环境;amount限制启动金额
 					this.$store.state.amount = res.data.data[0].amount
 					if (res.data.data[0].value == 0) {
+						// 测试模式
 						this.$store.state.test = true
+					} else if (res.data.data[0].value == 2) {
+						// 系统正在维护...
+						this.$store.state.test = 'weihuzhong'
+						
+						uni.showModal({
+							title: '提示信息',
+							content:'系统维护中...\r\n暂时请不要使用!\r\n避免造成不必要的损失!',
+							showCancel:false
+						});
 					} else {
+						// 正式模式
 						this.$store.state.test = false
 					}
 				} else {

+ 12 - 1
pages/recharge/recharge.vue

@@ -46,6 +46,15 @@
 			};
 		},
 		onLoad() {
+			// 系统正在维护...
+			if (this.test == 'weihuzhong') {
+				uni.redirectTo({
+					url: '../index/index'
+				})
+				
+				return;
+			}
+			// 测试环境
 			if (this.test) {
 				this.amount = 0.01
 			}
@@ -133,13 +142,15 @@
 						signType: res.data.pay.signType,
 						paySign: res.data.pay.paySign,
 						success: (res) => {
+							// console.log(res);
 							if (res.errMsg == 'requestPayment:ok') {
 								this.$store.state.payInfo.from = 'reshui_pay'
 								this.$store.state.payInfo.resultMsg = '支付成功'
 								this.$store.state.reshui_amount = this.amount
+								
 								uni.navigateBack({
 									delta: 1
-								})
+								});
 							}
 						},
 						fail: (res) => {

+ 83 - 58
pages/reshui/reshui.vue

@@ -132,11 +132,21 @@
 				// compus: '', // 校区
 				ceshi: 'code',
 				changeDate: false, // 是否是手动选择日期
-				get_Bluetooth_Bevice: false // 自动获取蓝牙设备,并列表
+				get_Bluetooth_Bevice: false, // 自动获取蓝牙设备,并列表
+				timer: -1,
+				test: this.$store.state.test
 			}
 		},
 		onLoad(options) {
 			// console.log(options);
+			// 系统正在维护...
+			if (this.test == 'weihuzhong') {
+				uni.redirectTo({
+					url: '../../pages/index/index'
+				})
+
+				return;
+			}
 			// 向用户发起授权请求
 			uni.authorize({
 				scope: 'scope.userLocation',
@@ -187,6 +197,7 @@
 			}
 		},
 		onShow() {
+			let _this = this;
 			// 充值后更新金额
 			this.amount = this.$store.state.reshui_amount
 
@@ -194,6 +205,55 @@
 				// 获取基本信息
 				this.get_base_info('options', 'onShow')
 			}
+
+			if (this.timer > -1) {
+				clearInterval(this.timer)
+			}
+			this.timer = setInterval(() => {
+				uni.openBluetoothAdapter({
+					success: (res) => { // 已打开
+						uni.getBluetoothAdapterState({ // 蓝牙的匹配状态
+							success: (res1) => {
+								// console.log(res1);
+							},
+							fail: (error) => {
+								// console.log(error)
+								uni.showToast({
+									title: '请开启手机蓝牙!',
+									icon: 'none',
+									duration: 2000
+								});
+							}
+						});
+					},
+					fail: (err) => { // 未打开
+						// console.log(err)
+						if (err.errCode == 10001) {
+							uni.showToast({
+								title: '请开启手机蓝牙 或 授权蓝牙权限!',
+								icon: 'none',
+								duration: 2000
+							});
+
+							setTimeout(() => {
+								_this.setInit();
+							}, 100);
+						} else {
+							uni.showToast({
+								icon: 'none',
+								title: err.errMsg,
+								duration: 2000
+							});
+						}
+					}
+				});
+			}, 3000);
+		},
+		onHide() {
+			clearInterval(this.timer)
+		},
+		onUnload() {
+			clearInterval(this.timer)
 		},
 		methods: {
 			/**
@@ -286,7 +346,7 @@
 								duration: 3000
 							});
 
-							return
+							return;
 						}
 					}
 				} catch (e) {
@@ -307,7 +367,7 @@
 				}
 
 				// 获取code
-				this.getCode(options, param)
+				this.getCode(options, param);
 			},
 			/**
 			 * 获得code
@@ -495,6 +555,7 @@
 			 * 开始或停止用水
 			 */
 			switchChange(e) {
+				let _this = this;
 				this.isChecked = e.target.value
 				if (this.isChecked) {
 					if (this.deviceId && this.serviceId && this.devices.length != 0) {
@@ -503,17 +564,17 @@
 							content: '确定要启动设备?',
 							success: (res) => {
 								if (res.confirm) {
-									this.isChecked = true
+									this.isChecked = true;
 
 									// 开始连接匹配的蓝牙设备
 									setTimeout(async () => {
 										// 请求获取设备启动码
-										this.request_device_start_code()
-									}, 300)
+										_this.request_device_start_code()
+									}, 200);
 								} else if (res.cancel) {
 									setTimeout(() => {
-										this.isChecked = false
-									}, 300)
+										_this.isChecked = false;
+									}, 100);
 								}
 							}
 						})
@@ -521,7 +582,7 @@
 						setTimeout(() => {
 							this.isChecked = false
 						}, 200)
-						
+
 						uni.showToast({
 							icon: 'none',
 							title: '先【扫码连接】,后【开启设备】',
@@ -535,14 +596,14 @@
 							title: '与设备连接中断!请在设备上手动停止即可!',
 							duration: 3000
 						})
-					
+
 						setTimeout(() => {
 							this.setInit()
 						}, 300)
-						
+
 						return
 					}
-					
+
 					uni.showModal({
 						title: '提示',
 						content: '确定要关闭设备?',
@@ -654,17 +715,19 @@
 					return false
 				}
 			},
+
 			/**
 			 * 111111111111111111111111111111
 			 * 扫码连接设备
 			 */
 			scan() {
 				if (this.judgeBalance('scan') == false) {
-					return
+					return;
 				}
 
-				this.scan_qr()
+				this.scan_qr();
 			},
+
 			/**
 			 * 启动摄像头,扫描二维码
 			 */
@@ -683,14 +746,14 @@
 						// scanType: "QR_CODE"
 						this.device_code = res.result.split('=')[1]
 
+						this.isScan = false;
+
 						if (this.device_code === '') {
 							uni.showToast({
 								icon: 'success',
 								title: '获取设备码失败',
 								duration: 3000
-							})
-
-							this.isScan = false
+							});
 						} else {
 							// 初始化蓝牙
 							this.openBluetoothAdapter()
@@ -719,13 +782,10 @@
 								// console.log(error)
 								uni.showModal({
 									content: '请开启手机蓝牙!',
-									showCancel: false,
-									success() {
-										// _this.myOpenBluetoothAdapter();
-									}
+									showCancel: false
 								});
 
-								this.isScan = false
+								this.isScan = false;
 							}
 						});
 					},
@@ -735,10 +795,7 @@
 						if (err.errCode == 10001) {
 							uni.showModal({
 								content: '请授权手机蓝牙!',
-								showCancel: false,
-								success() {
-									// _this.myOpenBluetoothAdapter();
-								}
+								showCancel: false
 							});
 						} else {
 							uni.showToast({
@@ -750,38 +807,6 @@
 					}
 				});
 			},
-			/**
-			 * 让用户去手动授权
-			 */
-			myOpenBluetoothAdapter() {
-				// 可以通过 wx.getSetting 先查询一下用户是否授权了 "scope.bluetooth" 这个 scope
-				uni.getSetting({
-					success(res) {
-						// console.log(res.authSetting)
-						//判断是否有'scope.bluetooth'属性
-						if (res.authSetting.hasOwnProperty('scope.bluetooth')) {
-							//'scope.bluetooth'属性存在,且为false
-							if (!res.authSetting['scope.bluetooth']) {
-								//弹窗授权
-								uni.openSetting({
-									success(res) {
-										console.log(res.authSetting)
-									}
-								})
-							}
-						} else
-							//'scope.bluetooth'属性不存在,需要授权
-							uni.authorize({
-								scope: 'scope.bluetooth',
-								success() {
-									// 用户已经同意小程序使用手机蓝牙功能,后续调用 蓝牙 接口不会弹窗询问
-									console.log(res.authSetting)
-								}
-							})
-
-					}
-				});
-			},
 
 			/**
 			 * 333333333333333333333333333

+ 9 - 0
pagesAir/accountBalance/accountBalance.vue

@@ -58,6 +58,15 @@
 			}
 		},
 		onLoad(options) {
+			// 系统正在维护...
+			if (this.test == 'weihuzhong') {
+				uni.redirectTo({
+					url: '../../pages/index/index'
+				})
+				
+				return;
+			}
+			// 测试环境
 			if (this.test) {
 				this.amount = 0.01
 			}

+ 7 - 4
pagesAir/addAir/addAir.vue

@@ -17,9 +17,10 @@
 				<view class="item-school" v-for="(item0, index0) in treeData" :key="index0">
 					<view class="school" :id="item0.id" @tap="handle_toggle_items">
 						<view>{{item0.label}}</view>
-						<uni-icons type="top" size="22" color="#ffffff"
-							:style="{display: item0.isShow ? '' : 'none'}"></uni-icons>
-						<uni-icons type="bottom" size="22" color="#ffffff" :style="{display: item0.isShow ? 'none' : ''}">
+						<uni-icons type="top" size="22" color="#ffffff" :style="{display: item0.isShow ? '' : 'none'}">
+						</uni-icons>
+						<uni-icons type="bottom" size="22" color="#ffffff"
+							:style="{display: item0.isShow ? 'none' : ''}">
 						</uni-icons>
 					</view>
 					<!-- 楼栋 -->
@@ -315,7 +316,9 @@
 									tmpFloors.push(floor)
 								}
 								// 楼层排序
-								tmpFloors.sort((a, b) => a.label.localeCompare(b.label))
+								tmpFloors.sort((a, b) => {
+									return a - b;
+								})
 								tmpBuilds.id = builds[j].id
 								tmpBuilds.label = builds[j].building
 								tmpBuilds.isShow = false

+ 12 - 2
pagesAir/shareAir/shareAir.vue

@@ -148,10 +148,20 @@
 				dotMode: 'round', // 显示控制点样式
 				isList: false, // 是否显示添加的空调列表
 				screenHeight: '', // 屏幕的高度
-				options: 0
+				options: 0,
+				test: this.$store.state.test
 			};
 		},
 		onLoad(options) {
+			// 系统正在维护...
+			if (this.test == 'weihuzhong') {
+				uni.redirectTo({
+					url: '../../pages/index/index'
+				})
+			
+				return;
+			}
+			
 			this.options = options
 			try {
 				// 选择绑定了的空调
@@ -205,7 +215,7 @@
 				// 存储空调列表
 				uni.setStorageSync('airs_selected', this.selectAirs)
 				// 移除全局自定义事件监听器。
-				uni.$off('selectAirs')
+				// uni.$off('selectAirs')
 			});
 
 			// 获取基本信息

+ 14 - 2
pagesElectric/jiaofei/jiaofei.vue

@@ -103,6 +103,18 @@
 			// 	})
 			// 	return
 			// }
+			// 系统正在维护...
+			if (this.test == 'weihuzhong') {
+				uni.redirectTo({
+					url: '../../pages/index/index'
+				})
+
+				return;
+			}
+			// 测试环境
+			if (this.test) {
+				this.amount = 0.01
+			}
 			// 获取基本信息
 			this.get_base_info(options, 'onLoad');
 			this.get_img();
@@ -154,10 +166,10 @@
 				})
 
 				// console.log(res.data)
-				if (res.data.data.length == 0) {
+				if (typeof res.data.data == 'undefined' || res.data.data.length == 0) {
 					return
 				}
-
+				
 				if (res.data.code == 200) {
 					let tf = false;
 					let tmpData = res.data.data;

+ 9 - 0
pagesElectric/select/select.vue

@@ -96,6 +96,15 @@
 			}
 		},
 		onLoad() {
+			// 系统正在维护...
+			if (this.test == 'weihuzhong') {
+				uni.redirectTo({
+					url: '../../pages/index/index'
+				})
+				
+				return;
+			}
+			
 			// 获取校区
 			this.getCampus()
 		},

+ 16 - 2
static/api.js

@@ -7,9 +7,23 @@ const IP_BASE_URL = 'https://pv.sohu.com/cityjson' // ip
 const myRequest = (options) => {
 	// 域名 或 url 为空,则不执行任何操作
 	if (options.host == '' || options.url == '') {
-		return
+		return;
 	}
 
+
+	let header = options.header;
+	if (typeof header == 'undefined' || header == '' || header == {}) {
+		header = {
+			'token': 'AqwxcdAxs4212pomk231qsxssaz'
+		}
+	} else {
+		header['token'] = 'AqwxcdAxs4212pomk231qsxssaz';
+	}
+	// options.data['token'] = 'AqwxcdAxs4212pomk231qsxssaz';
+	
+	// console.log(header);
+	// console.log(options.data);
+
 	return new Promise((resolve, reject) => {
 		let BASE_URL = '';
 
@@ -34,7 +48,7 @@ const myRequest = (options) => {
 		uni.request({
 			url: BASE_URL + options.url,
 			method: options.method || 'GET',
-			header: options.header || {},
+			header: header || {},
 			data: options.data || {},
 			success: (res) => {
 				// console.log(res)