Explorar o código

【修改】授权方式

程志平 %!s(int64=4) %!d(string=hai) anos
pai
achega
292f3bbc81

+ 2 - 2
components/instructions.vue

@@ -7,10 +7,10 @@
 				</view>
 				</view>
 				<view class="item">
 				<view class="item">
 					<view class="text">
 					<view class="text">
-						1.点【扫码连接】,扫水表中的二维码;
+						1.点【扫码连接】,扫水表中的二维码;
 					</view>
 					</view>
 					<view class="text">
 					<view class="text">
-						2.待进度显示“数据通讯”后,点【开启设备】启动水表;
+						2.待进度显示“数据通讯”后,点【开启设备】启动水表;
 					</view>
 					</view>
 					<view class="text">
 					<view class="text">
 						3.在水表上手动滑动,可启动、暂停、停止用水;手机APP也可直接停止用水。
 						3.在水表上手动滑动,可启动、暂停、停止用水;手机APP也可直接停止用水。

+ 40 - 50
pages/index/index.vue

@@ -4,7 +4,7 @@
 			<image src="../../static/images/banner2x.png" mode=""></image>
 			<image src="../../static/images/banner2x.png" mode=""></image>
 		</view>
 		</view>
 		<view class="nav">
 		<view class="nav">
-			<view class="menu" v-show="my_display">
+			<view class="menu">
 				<navigator :url="'/pages/reshui/reshui'" open-type="redirect" class="menu_item">
 				<navigator :url="'/pages/reshui/reshui'" open-type="redirect" class="menu_item">
 					<image src="../../static/images/shower2x.png" mode=""></image>
 					<image src="../../static/images/shower2x.png" mode=""></image>
 					<text>洗 浴</text>
 					<text>洗 浴</text>
@@ -14,12 +14,6 @@
 					<text>电费充值</text>
 					<text>电费充值</text>
 				</navigator>
 				</navigator>
 			</view>
 			</view>
-			<view class="reset">
-				<navigator url="" open-type="redirect" @click="reauthorization()" class="menu_item">
-					<text class="iconfont icon-zhongzhi"></text>
-					<text>重新授权</text>
-				</navigator>
-			</view>
 		</view>
 		</view>
 		<view class="qr_code" v-if="showQR_code">
 		<view class="qr_code" v-if="showQR_code">
 			<image src="https://jtishfw.ncjti.edu.cn/jxch-smartmp/HotWaters/image/1.jpg" mode="aspectFit"></image>
 			<image src="https://jtishfw.ncjti.edu.cn/jxch-smartmp/HotWaters/image/1.jpg" mode="aspectFit"></image>
@@ -37,17 +31,17 @@
 			return {
 			return {
 				ceshi: 'code',
 				ceshi: 'code',
 				huanjing: '部署环境', // 部署环境是key,用来获取环境
 				huanjing: '部署环境', // 部署环境是key,用来获取环境
-				visible: false,
-				showLogin: true,
-				appkey: '5AA49F3E4CACA380',
+				visible: false,  // 是否授权可见
+				showLogin: true,  // 是否启动授权
+				appkey: '5AA49F3E4CACA380',  // 商户appkey
 				appid: 'wx2fc3f45732fae5d3', // 获取用户信息
 				appid: 'wx2fc3f45732fae5d3', // 获取用户信息
 				ocode: '1015730314', // 获取用户信息
 				ocode: '1015730314', // 获取用户信息
 				app_secret: '58D34C81D82B35179ED896C4362B0FC0', // 获取用户信息
 				app_secret: '58D34C81D82B35179ED896C4362B0FC0', // 获取用户信息
-				my_display: false,
-				userinfo: '',
-				// showQR_code: false,
-				validation_failed: false,
-				from: 0
+				userinfo: '',  // 用户信息
+				showQR_code: false,  // 显示校园卡二维码
+				validation_failed: false,  // 验证失败
+				validation_times: 0,  // 授权次数
+				from: 0,  // 跳转参数
 			}
 			}
 		},
 		},
 		onLoad(options) {
 		onLoad(options) {
@@ -105,13 +99,11 @@
 							this.visible = true
 							this.visible = true
 						} else {
 						} else {
 							this.showLogin = false
 							this.showLogin = false
-							this.my_display = true
 						}
 						}
 					} else {
 					} else {
 						this.showLogin = false
 						this.showLogin = false
 						this.userinfo = value
 						this.userinfo = value
 						this.$store.state.userInfo = this.userinfo
 						this.$store.state.userInfo = this.userinfo
-						this.my_display = true
 					}
 					}
 				} catch (e) {
 				} catch (e) {
 					// console.log(e)
 					// console.log(e)
@@ -122,48 +114,49 @@
 				}
 				}
 			},
 			},
 			/**
 			/**
-			 * 重新授权
+			 * 授权登陆取消回调
 			 */
 			 */
-			reauthorization() {
-				try {
-					uni.removeStorageSync('userinfo_storage_key');
-					setTimeout(() => {
-						this.showLogin = false
-						this.userinfo = {}
-						this.my_display = false
-					}, 30)
-
-					setTimeout(() => {
-						this.showLogin = true
-						this.visible = true
-					}, 30)
-				} catch (e) {
-					console.log(e)
-				}
+			login_cancel_callback() {
+				this.reauthorization()
 			},
 			},
 			/**
 			/**
-			 * 授权登陆q取消回调
+			 * 重新授权
 			 */
 			 */
-			login_cancel_callback() {
-				this.userinfo = {};
-				uni.showToast({
-					icon: 'none',
-					title: '请先授权,点击右下角【重新授权】按钮'
-				});
+			reauthorization() {
+				this.validation_times = this.validation_times + 1
+				
+				if (this.validation_times >= 2) {
+					this.login_fail_callback()
+				} else {
+					try {
+						uni.removeStorageSync('userinfo_storage_key');
+						setTimeout(() => {
+							this.showLogin = false
+							this.userinfo = {}
+						}, 30)
+								
+						setTimeout(() => {
+							this.showLogin = true
+							this.visible = true
+						}, 30)
+					} catch (e) {
+						console.log(e)
+					}
+				}
 			},
 			},
 			/**
 			/**
-			 * 授权登陆q取消回调
+			 * 授权登陆取消回调
 			 */
 			 */
 			login_fail_callback() {
 			login_fail_callback() {
 				this.userinfo = {};
 				this.userinfo = {};
-				setTimeout(() => {
-					this.validation_failed = true
-				}, 2000);
-				if (this.validation_failed) {
+				// setTimeout(() => {
+				// 	this.validation_failed = true
+				// }, 3000);
+				if (!this.validation_failed) {
 					this.validation_failed = false
 					this.validation_failed = false
 					uni.showModal({
 					uni.showModal({
 						title: '提示',
 						title: '提示',
-						content: '授权失败,请先领取校园卡激活!',
+						content: '授权还可以领取校园卡、激活!',
 						// cancelText: '取消',
 						// cancelText: '取消',
 						confirmText: '领取',
 						confirmText: '领取',
 						success: (res1) => {
 						success: (res1) => {
@@ -337,8 +330,6 @@
 						title: '授权成功',
 						title: '授权成功',
 						duration: 800,
 						duration: 800,
 						success: (res) => {
 						success: (res) => {
-							this.my_display = true
-
 							if (this.from != 0 || this.from != '0') {
 							if (this.from != 0 || this.from != '0') {
 								uni.navigateBack({
 								uni.navigateBack({
 									delta: 1
 									delta: 1
@@ -351,7 +342,6 @@
 						icon: 'success',
 						icon: 'success',
 						title: '授权失败:' + res.data.mess,
 						title: '授权失败:' + res.data.mess,
 						success: (res) => {
 						success: (res) => {
-							this.my_display = false
 						}
 						}
 					})
 					})
 				}
 				}

+ 33 - 7
pages/jiaofei/jiaofei.vue

@@ -100,6 +100,32 @@
 			 * 获取基本信息
 			 * 获取基本信息
 			 */
 			 */
 			get_base_info(options, param) {
 			get_base_info(options, param) {
+				try {
+					// 获取学号
+					this.stu_number = this.$store.state.userInfo.card_number
+
+					if (this.stu_number == '' || typeof(this.stu_number) == 'undefined') {
+						const userinfo = uni.getStorageSync('userinfo_storage_key')
+						if (userinfo) {
+							this.stu_number = userinfo.card_number
+						} else {
+							uni.navigateTo({
+								url: '../index/index?from=' + options.from
+							})
+
+							uni.showToast({
+								icon: 'none',
+								title: '学号为空,请进行授权',
+								duration: 3000
+							});
+							
+							return
+						}
+					}
+				} catch (e) {
+					console.log(e);
+				}
+
 				if (param == 'onShow') {
 				if (param == 'onShow') {
 					// 获取电量
 					// 获取电量
 					if (this.$store.state.building.roomSelect != '') {
 					if (this.$store.state.building.roomSelect != '') {
@@ -113,13 +139,13 @@
 							this.getDianLiang()
 							this.getDianLiang()
 						}
 						}
 					}
 					}
-				} else {
-					// 初始化参数
-					this.$store.state.building.add_class = 0;
-
-					// 获取code
-					this.getCode(options, param)
 				}
 				}
+				
+				// 初始化参数
+				this.$store.state.building.add_class = 0;
+
+				// 获取code
+				this.getCode(options, param)
 			},
 			},
 			/**
 			/**
 			 * 获取code
 			 * 获取code
@@ -187,7 +213,7 @@
 						}
 						}
 					})
 					})
 
 
-					console.log('获得openid', res);
+					// console.log('获得openid', res);
 					if (res.data.mess == '返回成功') {
 					if (res.data.mess == '返回成功') {
 						// 栋宿舍号
 						// 栋宿舍号
 						this.dorm_number = res.data.info[0].build + res.data.info[0].dom
 						this.dorm_number = res.data.info[0].build + res.data.info[0].dom

+ 1 - 1
pages/qr_code/qr_code.vue

@@ -1,5 +1,5 @@
 <template>
 <template>
-	<web-view src="https://msg.weixiao.qq.com/t/700e3125b237694ec06512a4b35ade59" :progress="false"></web-view>
+	<web-view src="https://msg.weixiao.qq.com/t/700e3125b237694ec06512a4b35ade59" :progress="true"></web-view>
 </template>
 </template>
 
 
 <script>
 <script>

+ 19 - 25
pages/reshui/reshui.vue

@@ -125,30 +125,22 @@
 				// 获取基本信息
 				// 获取基本信息
 				this.get_base_info(options, 'onLoad')
 				this.get_base_info(options, 'onLoad')
 			} else if (typeof(options.from) != 'undefined' && options.from != 0) {
 			} else if (typeof(options.from) != 'undefined' && options.from != 0) {
-			// 	uni.showToast({
-			// 		icon: 'none',
-			// 		title: '跳转首页'
-			// 	})
-			// 	uni.navigateTo({
-			// 		url: '../index/index?from=' + options.from
-			// 	})
-			// } else {
-				uni.showToast({
-					icon: 'none',
-					title: '初始化蓝牙'
-				})
+				// 获取基本信息
+				this.get_base_info(options, 'onLoad')
 				// wxminicode=KB580002652
 				// wxminicode=KB580002652
-				this.start_code = decodeURIComponent(options.q).split('=')[1]
-				// 初始化蓝牙
-				this.openBluetoothAdapter()
+				this.device_code = decodeURIComponent(options.q).split('=')[1]
 			}
 			}
-			
+
 			const value = uni.getStorageSync('instruction_noshow');
 			const value = uni.getStorageSync('instruction_noshow');
 			if (!(value == true)) {
 			if (!(value == true)) {
 				this.flag = true
 				this.flag = true
 			}
 			}
 		},
 		},
 		onShow() {
 		onShow() {
+			// 充值后更新金额
+			if (this.$store.state.reshui_amount > 0.00) {
+				this.amount = this.$store.state.reshui_amount
+			}
 			if (this.stu_number && typeof(this.stu_number) != 'undefined') {
 			if (this.stu_number && typeof(this.stu_number) != 'undefined') {
 				return
 				return
 			} else {
 			} else {
@@ -180,6 +172,8 @@
 								title: '学号为空,请进行授权',
 								title: '学号为空,请进行授权',
 								duration: 3000
 								duration: 3000
 							});
 							});
+							
+							return
 						}
 						}
 					}
 					}
 				} catch (e) {
 				} catch (e) {
@@ -196,8 +190,6 @@
 								this.$store.state.payInfo.from = ''
 								this.$store.state.payInfo.from = ''
 							}
 							}
 						})
 						})
-
-						// this.amount = this.$store.state.reshui_amount + this.amount
 					}
 					}
 				}
 				}
 
 
@@ -256,10 +248,12 @@
 						// 校区
 						// 校区
 						// this.compus = res.data.info[0].campus
 						// this.compus = res.data.info[0].campus
 
 
-						if (param == 'onLoad') {
-							// 请求选定的月份消费记录
-							this.request_consumption_records()
+						if (param == 'onLoad' && typeof(options.from) != 'undefined' && options.from != 0) {
+							// 初始化蓝牙
+							this.openBluetoothAdapter()
 						}
 						}
+						// 请求选定的月份消费记录
+						this.request_consumption_records()
 					} else {
 					} else {
 						uni.showToast({
 						uni.showToast({
 							title: '未获取到学号!',
 							title: '未获取到学号!',
@@ -330,7 +324,7 @@
 						}
 						}
 					});
 					});
 
 
-					console.log(res);
+					// console.log(res);
 					if (res.data.mess == '返回成功') {
 					if (res.data.mess == '返回成功') {
 						this.xiaofei_items = []
 						this.xiaofei_items = []
 						// 消费记录
 						// 消费记录
@@ -450,7 +444,7 @@
 			 */
 			 */
 			scan() {
 			scan() {
 				// 启动最低金额限制
 				// 启动最低金额限制
-				if (this.amount < 10) {
+				if (this.amount < 10.00) {
 					uni.showModal({
 					uni.showModal({
 						title: '提示',
 						title: '提示',
 						content: '当前余额不足¥10元',
 						content: '当前余额不足¥10元',
@@ -458,7 +452,7 @@
 						confirmText: '我要充值',
 						confirmText: '我要充值',
 						success: (res) => {
 						success: (res) => {
 							if (res.confirm) {
 							if (res.confirm) {
-								// 跳转充值页面并传参数
+								// 跳转充值页面
 								this.chongzhi_yemian()
 								this.chongzhi_yemian()
 							} else if (res.cancel) {
 							} else if (res.cancel) {
 								return
 								return
@@ -1084,7 +1078,7 @@
 						setTimeout(() => {
 						setTimeout(() => {
 							this.send('start')
 							this.send('start')
 						}, 100)
 						}, 100)
-						
+
 						// 刷新选定的月份消费记录
 						// 刷新选定的月份消费记录
 						this.request_consumption_records()
 						this.request_consumption_records()
 					} else {
 					} else {

BIN=BIN
static/images/qr-code.png