Browse Source

【修复】电费缴费页面,进入时无宿舍号显示undefined问题。从不同连接进入不同页面时,未授权时,进入首页面授权完,自动回退到指定页面。
【增加】扫水表二维码,进入自动连蓝牙。

程志平 4 years ago
parent
commit
d56d9b8b43
2 changed files with 48 additions and 26 deletions
  1. 23 15
      pages/jiaofei/jiaofei.vue
  2. 25 11
      pages/reshui/reshui.vue

+ 23 - 15
pages/jiaofei/jiaofei.vue

@@ -112,23 +112,23 @@
 					this.$store.state.building.add_class = 0;
 
 					// 获取code
-					this.getCode('')
+					this.getCode(options, param)
 				}
 			},
 			/**
 			 * 获取code
 			 */
-			getCode(param) {
+			getCode(options, param) {
+				// console.log(options, param)
 				uni.login({
 					success: (res) => {
-						// console.log('获得code', res);
 						if (res.code) {
 							// 请求服务器,获得openid
 							if (param == 'comfirm') {
 								// 获取IP
 								this.getIP(res.code)
 							} else
-								this.getOpenId(res.code)
+								this.getOpenId(options, res.code)
 						} else {
 							uni.showToast({
 								title: res.errMsg,
@@ -147,6 +147,7 @@
 			 * 获取IP
 			 */
 			async getIP(param_code) {
+				// console.log(param_code)
 				const res = await this.$myRequest({
 					host: 'ip',
 					url: '?ie=utf-8',
@@ -165,7 +166,8 @@
 			/**
 			 * 请求服务器,获得openid
 			 */
-			async getOpenId(param_code) {
+			async getOpenId(options, param_code) {
+				// console.log(options, param_code)
 				if (param_code != '') {
 					const res = await this.$myRequest({
 						host: this.ceshi,
@@ -196,9 +198,15 @@
 						this.getDianLiang()
 					} else if (res.data.mess == '未查询到用户信息') {
 						// 跳转到首页
-						uni.redirectTo({
-							url: '../index/index?from=0'
-						});
+						if (options && typeof(options.from) != 'undefined' && typeof(options.from) != '') {
+							uni.navigateTo({
+								url: '../index/index?from=' + options.from
+							})
+						} else {
+							uni.redirectTo({
+								url: '../index/index?from=0'
+							});
+						}
 					}
 
 					if (this.roomSelect == '' || typeof(this.roomSelect) == 'undefined') {
@@ -206,10 +214,6 @@
 						if (typeof(userinfo) != 'undefined' && typeof(userinfo.campus) != 'undefined' && typeof(
 								userinfo.dorm_number) != 'undefined') {
 							this.roomSelect = userinfo.campus + userinfo.dorm_number
-							
-							if (this.roomSelect == '' || typeof(this.roomSelect) == 'undefined') {
-								this.roomSelect = '请选择宿舍号'
-							}
 						} else {
 							uni.navigateTo({
 								url: '../index/index?from=' + options.from
@@ -222,6 +226,10 @@
 							});
 						}
 					}
+					
+					if (this.roomSelect == '' || typeof(this.roomSelect) == 'undefined') {
+						this.roomSelect = '请选择宿舍号'
+					}
 				} else {
 					uni.showToast({
 						title: 'code为空!',
@@ -233,7 +241,7 @@
 			 * 取得电费额度
 			 */
 			async getDianLiang() {
-				if (this.roomSelect != '') {
+				if (this.roomSelect != '' && typeof(this.roomSelect) != 'undefined') {
 					const res = await this.$myRequest({
 						host: this.ceshi,
 						url: '/HotWaters/buildoverElec.action',
@@ -256,7 +264,7 @@
 					}
 				} else {
 					uni.showToast({
-						title: '宿舍号为空',
+						title: '未获得宿舍号',
 						icon: 'success'
 					});
 				}
@@ -336,7 +344,7 @@
 					success: (res) => {
 						if (res.confirm) {
 							// 获取code
-							this.getCode('comfirm')
+							this.getCode('options', 'comfirm')
 						} else if (res.cancel) {
 							// console.log('用户点击取消');
 						}

+ 25 - 11
pages/reshui/reshui.vue

@@ -119,12 +119,20 @@
 			}
 		},
 		onLoad(options) {
-			// 获取基本信息
-			this.get_base_info(options, 'onLoad')
+			if (typeof(options.from) != 'undefined' && options.from == 3 && typeof(options.wxminicode) != 'undefined' &&
+				typeof(options.wxminicode) != '') {
+				// wxminicode=KB580002652
+				this.start_code = options.wxminicode
+				// 初始化蓝牙
+				this.openBluetoothAdapter()
+			} else {
+				// 获取基本信息
+				this.get_base_info(options, 'onLoad')
+			}
 		},
 		onShow() {
 			// 获取基本信息
-			this.get_base_info('', 'onShow')
+			this.get_base_info('options', 'onShow')
 		},
 		methods: {
 			/**
@@ -157,7 +165,7 @@
 							this.flag = true
 						}
 						// 获取code
-						this.getCode()
+						this.getCode(options, param)
 					}
 				} catch (e) {
 					console.log(e);
@@ -176,20 +184,20 @@
 
 						// this.amount = this.$store.state.reshui_amount + this.amount
 						// 重新调用一次,刷新金额
-						this.getCode()
+						this.getCode(options, param)
 					}
 				}
 			},
 			/**
 			 * 获得code
 			 */
-			getCode() {
+			getCode(options, param) {
 				uni.login({
 					success: (res) => {
 						// console.log('reshui', res);
 						if (res.code) {
 							// 请求服务器,获得openid
-							this.getOpenId(res.code)
+							this.getOpenId(options, res.code)
 						} else {
 							uni.showToast({
 								title: res.errMsg,
@@ -202,7 +210,7 @@
 			/**
 			 * 请求服务器,获得openid
 			 */
-			async getOpenId(param_code) {
+			async getOpenId(options, param_code) {
 				const res = await this.$myRequest({
 					host: this.ceshi,
 					url: '/HotWaters/wpget_stu.action',
@@ -240,9 +248,15 @@
 						});
 					}
 				} else if (res.data.mess == '未查询到用户信息') {
-					uni.redirectTo({
-						url: '../index/index?from=0'
-					});
+					if (options && typeof(options.from) != 'undefined' && typeof(options.from) != '') {
+						uni.navigateTo({
+							url: '../index/index?from=' + options.from
+						})
+					} else {
+						uni.redirectTo({
+							url: '../index/index?from=0'
+						});
+					}
 				}
 			},
 			/**