Browse Source

【说明】基本完成,测试反馈也已修复!

程志平 4 years ago
parent
commit
2a44474d10

+ 45 - 38
pages/index/index.vue

@@ -21,6 +21,9 @@
 				</navigator>
 			</view>
 		</view>
+		<view class="qr_code" v-if="showQR_code">
+			<image src="https://jtishfw.ncjti.edu.cn/jxch-smartmp/HotWaters/image/1.jpg" mode="aspectFit"></image>
+		</view>
 		<view v-if="showLogin">
 			<login :ocode="ocode" :appkey="appkey" scope="snsapi_userinfo" :visible="visible"
 				@success="login_success_callback()" @cancel="login_cancel_callback()" @fail="login_fail_callback()" />
@@ -42,15 +45,13 @@
 				app_secret: '58D34C81D82B35179ED896C4362B0FC0', // 获取用户信息
 				my_display: false,
 				userinfo: '',
-				wxcode: '',
-				access_token: '',
-				code: '',
+				showQR_code: false,
 				from: 0
 			}
 		},
 		onLoad(options) {
-			console.log(options)
-			if (options && JSON.stringify(options) != '{}' && typeof(options.from) != 'undefined') {
+			// console.log(options)
+			if (typeof(options.from) != 'undefined') {
 				this.from = options.from
 			}
 			// 是否是测试环境,查询数据接口中参数的值决定,方便以后测试
@@ -146,7 +147,7 @@
 				this.userinfo = {};
 				uni.showToast({
 					icon: 'none',
-					title: '需要先授权,请点击右下角【重新授权】按钮'
+					title: '请先授权,点击右下角【重新授权】按钮'
 				});
 			},
 			/**
@@ -156,32 +157,33 @@
 				this.userinfo = {};
 				uni.showToast({
 					icon: 'none',
-					title: '授权失败,请先领取校园卡、激活',
+					title: '授权失败,请先领取校园卡、激活',
 					duration: 3000,
 					success: (res) => {
 						uni.showModal({
 							title: '提示',
 							content: '是否将校园卡二维码,保存到相册?',
-							showCancel: false,
-							success: res => {
-								if (res.confirm) {
+							cancelText: '手动截图',
+							confirmText: '自动保存',
+							success: (res1) => {
+								if (res1.confirm) {
 									// 出现二维码,用户扫描二维码添加校园卡、激活
 									uni.downloadFile({
-										url: 'https://www.ecjtuit.edu.cn/img/zs.jpg',
-										success: (res) => {
-											console.log(res);
-											if (res.statusCode === 200) {
+										url: 'https://jtishfw.ncjti.edu.cn/jxch-smartmp/HotWaters/image/1.jpg',
+										success: (res2) => {
+											// console.log(res2);
+											if (res2.statusCode == 200) {
 												uni.saveImageToPhotosAlbum({
-													filePath: res.tempFilePath,
+													filePath: res2.tempFilePath,
 													success: function() {
 														uni.showToast({
-															title: "保存成功",
+															title: "保存成功!请用微信扫码添加校园卡!",
 															icon: "none"
 														});
 													},
 													fail: function() {
 														uni.showToast({
-															title: "保存失败,请稍后重试",
+															title: "保存失败,请手动截图保存,再用微信扫二维码!",
 															icon: "none"
 														});
 													}
@@ -189,8 +191,9 @@
 											}
 										}
 									})
-								} else if (res.cancel) {
-									console.log('用户点击取消');
+								} else if (res1.cancel) {
+									// console.log('用户点击取消');
+									this.showQR_code = true;
 								}
 							}
 						});
@@ -207,16 +210,13 @@
 					wxcode = ""
 				} = detail
 
-				// 获取wxcode
-				this.wxcode = wxcode
-
 				// 通过wxcode换取access_token
-				this.get_access_token()
+				this.get_access_token(wxcode)
 			},
 			/**
 			 * 通过wxcode换取access_token
 			 */
-			async get_access_token() {
+			async get_access_token(param_wxcode) {
 				const res = await this.$myRequest({
 					host: 'wecard',
 					url: '/connect/oauth2/token',
@@ -225,7 +225,7 @@
 						'content-type': 'application/json'
 					},
 					data: {
-						'wxcode': this.wxcode,
+						'wxcode': param_wxcode,
 						'app_key': this.appkey,
 						'app_secret': this.app_secret,
 						'grant_type': 'authorization_code',
@@ -238,16 +238,14 @@
 						title: '未获得token'
 					});
 				} else {
-					this.access_token = res.data.access_token;
-
 					// 通过access_token换取用户信息
-					this.get_user_info();
+					this.get_user_info(res.data.access_token);
 				}
 			},
 			/**
 			 * 通过access_token换取用户信息
 			 */
-			async get_user_info() {
+			async get_user_info(param_access_token) {
 				const res = await this.$myRequest({
 					host: 'wecard',
 					url: '/connect/oauth/get-user-info',
@@ -256,7 +254,7 @@
 						'content-type': 'application/json'
 					},
 					data: {
-						"access_token": this.access_token
+						"access_token": param_access_token
 					}
 				});
 
@@ -265,7 +263,7 @@
 						this.userinfo = res.data
 						this.$store.state.userInfo = this.userinfo
 
-						// 获code,然后去检查是否存在数据库中
+						// 获code,然后去检查是否存在数据库中
 						this.getCode()
 					} catch (e) {
 						console.log(e)
@@ -285,10 +283,8 @@
 					success: (res) => {
 						// console.log('reshui', res);
 						if (res.code) {
-							this.code = res.code
-
 							// 检查用户是否存在第三方库
-							this.chk_user_is_in_db()
+							this.chk_user_is_in_db(res.code)
 						} else {
 							uni.showToast({
 								title: res.errMsg,
@@ -301,7 +297,7 @@
 			/**
 			 * 检查数据库中是否有该用户信息
 			 */
-			async chk_user_is_in_db() {
+			async chk_user_is_in_db(param_code) {
 				const res = await this.$myRequest({
 					// host: 'local',
 					host: this.ceshi,
@@ -312,7 +308,7 @@
 					},
 					data: {
 						"userinfo": JSON.stringify(this.userinfo),
-						"code": this.code
+						"code": param_code
 					}
 				});
 
@@ -328,7 +324,7 @@
 						success: (res) => {
 							this.my_display = true
 
-							if (this.from != 0) {
+							if (this.from != 0 || this.from != '0') {
 								uni.navigateBack({
 									delta: 1
 								})
@@ -421,6 +417,17 @@
 				}
 			}
 		}
-
+		
+		.qr_code {
+			display: flex;
+			justify-content: center;
+			align-items: center;
+			width: 750rpx;
+			height: 100%;
+			position: fixed;
+			left: 0;
+			top: 0;
+			background-color: #FFFFFF;
+		}
 	}
 </style>

+ 38 - 44
pages/jiaofei/jiaofei.vue

@@ -52,7 +52,7 @@
 			</view>
 		</view>
 		<view class="show-item">
-			<input type="number" class="input-money" maxlength="4" placeholder="请输入金额(1-200)"
+			<input type="number" class="input-money" maxlength="4" placeholder="请输入金额(10-200)"
 				placeholder-class="input-ph-color" v-model:value="amount" @input="onInput" @blur="onBlur" />
 		</view>
 		<view class="submit-item">
@@ -73,8 +73,6 @@
 				add_class: '', //增加class属性
 				amount: '',
 				sub_appid: '', //商户号
-				code: '',
-				IP: '',
 				xiaofei_items: '', // 消费记录
 				dorm_number: '', //栋宿舍号
 				compus: '', //校区
@@ -105,13 +103,14 @@
 						this.dorm_number = this.$store.state.building.dorm_number;
 
 						this.add_class = 1
-						if (this.roomSelect != '') {
+						if (this.roomSelect != '' && typeof(this.roomSelect) != 'undefined') {
 							this.getDianLiang()
 						}
 					}
 				} else {
 					// 初始化参数
 					this.$store.state.building.add_class = 0;
+
 					// 获取code
 					this.getCode('')
 				}
@@ -124,13 +123,12 @@
 					success: (res) => {
 						// console.log('获得code', res);
 						if (res.code) {
-							this.code = res.code
 							// 请求服务器,获得openid
 							if (param == 'comfirm') {
 								// 获取IP
-								this.getIP()
+								this.getIP(res.code)
 							} else
-								this.getOpenId()
+								this.getOpenId(res.code)
 						} else {
 							uni.showToast({
 								title: res.errMsg,
@@ -139,7 +137,7 @@
 
 							// 跳转到首页
 							uni.redirectTo({
-								url: '../index/index'
+								url: '../index/index?from=0'
 							});
 						}
 					}
@@ -148,7 +146,7 @@
 			/**
 			 * 获取IP
 			 */
-			async getIP() {
+			async getIP(param_code) {
 				const res = await this.$myRequest({
 					host: 'ip',
 					url: '?ie=utf-8',
@@ -159,17 +157,16 @@
 					// console.log(res);
 					const reg = /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/;
 					let ip = reg.exec(res.data);
-					this.IP = ip[0]
 
 					// 组合地址,发起支付
-					this.jsapi()
+					this.jsapi(param_code, ip[0])
 				}
 			},
 			/**
 			 * 请求服务器,获得openid
 			 */
-			async getOpenId() {
-				if (this.code != '') {
+			async getOpenId(param_code) {
+				if (param_code != '') {
 					const res = await this.$myRequest({
 						host: this.ceshi,
 						url: '/HotWaters/wpget_stu.action',
@@ -178,7 +175,7 @@
 							'content-type': 'application/x-www-form-urlencoded'
 						},
 						data: {
-							code: this.code
+							code: param_code
 						}
 					})
 
@@ -195,39 +192,36 @@
 						// 样式
 						this.add_class = 1
 
-						// if (this.stu_number == '' || this.roomSelect == '' || typeof(this.stu_number) == 'undefined' ||
-						if (this.roomSelect == '' || typeof(this.roomSelect) == 'undefined') {
-							const userinfo = uni.getStorageSync('userinfo_storage_key')
-							if (userinfo) {
-								this.stu_number = userinfo.card_number
-								this.roomSelect = userinfo.campus + userinfo.dorm_number
-							} else {
-								if (options && JSON.stringify(options) != '{}' && typeof(options.from) !=
-									'undefined') {
-									uni.navigateTo({
-										url: '../index/index?from=' + options.from
-									})
-								} else {
-									uni.redirectTo({
-										url: '../index/index?from=0'
-									})
-								}
-
-								uni.showToast({
-									icon: 'none',
-									title: '未获得学号或宿舍号,请进行授权',
-									duration: 3000
-								});
-							}
-						}
 						// 请求选定的月份消费记录
 						this.getDianLiang()
 					} else if (res.data.mess == '未查询到用户信息') {
 						// 跳转到首页
 						uni.redirectTo({
-							url: '../index/index'
+							url: '../index/index?from=0'
 						});
 					}
+
+					if (this.roomSelect == '' || typeof(this.roomSelect) == 'undefined') {
+						const userinfo = uni.getStorageSync('userinfo_storage_key')
+						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
+							})
+
+							uni.showToast({
+								icon: 'none',
+								title: '未获得宿舍号,请进行授权',
+								duration: 3000
+							});
+						}
+					}
 				} else {
 					uni.showToast({
 						title: 'code为空!',
@@ -357,8 +351,8 @@
 			/**
 			 * 请求服务器,获取支付参数,并支付
 			 */
-			async jsapi() {
-				if (this.code == '' || this.amount == '' || this.IP == '') {
+			async jsapi(param_code, param_ip) {
+				if (param_code == '' || this.amount == '' || param_ip == '') {
 					uni.showToast({
 						title: 'code、充值金额或IP为空'
 					});
@@ -372,9 +366,9 @@
 						'content-type': 'application/x-www-form-urlencoded'
 					},
 					data: {
-						code: this.code,
+						code: param_code,
 						num: this.amount,
-						ip: this.IP
+						ip: param_ip
 					}
 				})
 

+ 17 - 17
pages/recharge/recharge.vue

@@ -9,7 +9,7 @@
 			<view class="amount_inp">
 				<text></text>
 				<input class="inp" type="number" maxlength="4" v-model="amount" @input="onInput" @blur="onBlur"
-					placeholder="请输入大于10,小于100元" placeholder-class="ph_class" />
+					placeholder="请输入大于10,小于100元" placeholder-class="ph_class" />
 			</view>
 			<text>最多可输入金额100元</text>
 		</view>
@@ -52,14 +52,13 @@
 			/**
 			 * 获得code
 			 */
-			getCode() {
+			getCode(param_ip) {
 				uni.login({
 					success: (res) => {
 						// console.log('recharge', res);
 						if (res.code) {
-							this.code = res.code
-							// 获取IP
-							this.getIP()
+							// 组合地址,发起支付
+							this.jsapi(param_ip, res.code)
 						} else {
 							uni.showToast({
 								title: res.errMsg,
@@ -83,22 +82,23 @@
 					// console.log(res);
 					const reg = /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/;
 					let ip = reg.exec(res.data);
-					this.IP = ip[0]
-
-					// 组合地址,发起支付
-					this.jsapi()
+					
+					// 获取code
+					this.getCode(ip[0])
 				}
 			},
 			/**
 			 * 请求服务器,获取支付参数,并支付
 			 */
-			async jsapi() {
-				if (this.code == '' || this.amount == '' || this.IP == '') {
+			async jsapi(param_ip, param_code) {
+				if (param_code == '' || this.amount == '' || param_ip == '') {
 					uni.showToast({
+						icon: 'none',
 						title: 'code、充值金额或IP为空'
 					});
 					return
 				}
+				
 				const res = await this.$myRequest({
 					host: this.ceshi,
 					url: '/HotWaters/wpPay.action',
@@ -107,9 +107,9 @@
 						'content-type': 'application/x-www-form-urlencoded'
 					},
 					data: {
-						code: this.code,
+						code: param_code,
 						num: this.amount,
-						ip: this.IP
+						ip: param_ip
 					}
 				})
 				
@@ -224,8 +224,8 @@
 						confirmText: '充值',
 						success: (res) => {
 							if (res.confirm) {
-								// 获取code
-								this.getCode()
+								// 获取IP
+								this.getIP()
 							} else if (res.cancel) {
 								return
 							}
@@ -251,8 +251,8 @@
 					confirmText: '充值',
 					success: (res) => {
 						if (res.confirm) {
-							// 获取code
-							this.getCode()
+							// 获取IP
+							this.getIP()
 						} else if (res.cancel) {
 							return
 						}

+ 10 - 28
pages/reshui/reshui.vue

@@ -114,7 +114,6 @@
 				dorm_number: '', // 宿舍号
 				stu_number: '', // 学号
 				// compus: '', // 校区
-				code: '',
 				ceshi: 'code',
 				changeDate: false // 是否是手动选择日期
 			}
@@ -125,13 +124,14 @@
 		},
 		onShow() {
 			// 获取基本信息
-			this.get_base_info('options', 'onShow')
+			this.get_base_info('', 'onShow')
 		},
 		methods: {
 			/**
 			 * 获取基本信息
 			 */
 			get_base_info(options, param) {
+				// console.log(options);
 				try {
 					// 获取学号
 					this.stu_number = this.$store.state.userInfo.card_number
@@ -140,17 +140,10 @@
 						const userinfo = uni.getStorageSync('userinfo_storage_key')
 						if (userinfo) {
 							this.stu_number = userinfo.card_number
-							this.roomSelect = userinfo.campus + userinfo.dorm_number
 						} else {
-							if (options && JSON.stringify(options) != '{}' && typeof(options.from) != 'undefined') {
-								uni.navigateTo({
-									url: '../index/index?from=' + options.from
-								})
-							} else {
-								uni.redirectTo({
-									url: '../index/index?from=0'
-								})
-							}
+							uni.navigateTo({
+								url: '../index/index?from=' + options.from
+							})
 
 							uni.showToast({
 								icon: 'none',
@@ -159,14 +152,11 @@
 							});
 						}
 					} else {
-						// 初始化参数
-						this.$store.state.building.add_class = 0;
-						
 						const value = uni.getStorageSync('instruction_noshow');
 						if (!value) {
 							this.flag = true
 						}
-						// 获code
+						// 获code
 						this.getCode()
 					}
 				} catch (e) {
@@ -198,9 +188,8 @@
 					success: (res) => {
 						// console.log('reshui', res);
 						if (res.code) {
-							this.code = res.code
 							// 请求服务器,获得openid
-							this.getOpenId()
+							this.getOpenId(res.code)
 						} else {
 							uni.showToast({
 								title: res.errMsg,
@@ -213,14 +202,7 @@
 			/**
 			 * 请求服务器,获得openid
 			 */
-			async getOpenId() {
-				if (this.code == '') {
-					uni.showToast({
-						title: 'code未获得!',
-						icon: 'success'
-					});
-					return
-				}
+			async getOpenId(param_code) {
 				const res = await this.$myRequest({
 					host: this.ceshi,
 					url: '/HotWaters/wpget_stu.action',
@@ -229,7 +211,7 @@
 						'content-type': 'application/x-www-form-urlencoded'
 					},
 					data: {
-						code: this.code
+						code: param_code
 					}
 				})
 
@@ -259,7 +241,7 @@
 					}
 				} else if (res.data.mess == '未查询到用户信息') {
 					uni.redirectTo({
-						url: '../index/index'
+						url: '../index/index?from=0'
 					});
 				}
 			},

+ 1 - 3
pages/show/show.vue

@@ -8,7 +8,7 @@
 				<view class="show-item-label">能耗走势图</view>
 			</view>
 			<view class="charts-box">
-				<qiun-data-charts type="demotype" :chartData="chartData" />
+				<qiun-data-charts type="demotype" :chartData="chartData" tooltipFormat="tooltipDemo1" />
 			</view>
 			<view class="select-show">
 				<button class="first-button">月</button>
@@ -110,8 +110,6 @@
 			bindDateChange: function(e) {
 				this.date = e.detail.value
 				this.changeDate = true
-				// 能耗记录
-				this.get_nenghaojilu()
 				// 缴费记录
 				this.get_jiaofeijilu()
 			},

BIN
static/images/gou.png


+ 3 - 0
uni_modules/qiun-data-charts/js_sdk/u-charts/config-ucharts.js

@@ -93,6 +93,9 @@ module.exports = {
 				return series[index].name + ':' + series[index].data + '元'
 			}
 		},
+		tooltipDemo1: function(item, category, index, opts) {
+			return item.data + '度'
+		},
 	},
 	//这里演示了自定义您的图表类型的option,可以随意命名,之后在组件上 type="demotype" 后,组件会调用这个花括号里的option,如果组件上还存在opts参数,会将demotype与opts中option合并后渲染图表。
 	"demotype": {