Parcourir la source

说明:基本完成,等测试再修改优化。不同端过来需要完善。

程志平 il y a 4 ans
Parent
commit
0ff2166ec7

+ 149 - 64
pages/index/index.vue

@@ -22,8 +22,8 @@
 			</view>
 			</view>
 		</view>
 		</view>
 		<view v-if="showLogin">
 		<view v-if="showLogin">
-			<login :ocode="ocode" :appkey="appkey" scope="snsapi_userinfo" :visible="visible" @success="callback()"
-				@cancel="callback()" @fail="callback()" />
+			<login :ocode="ocode" :appkey="appkey" scope="snsapi_userinfo" :visible="visible"
+				@success="login_success_callback()" @cancel="login_cancel_callback()" @fail="login_fail_callback()" />
 		</view>
 		</view>
 	</view>
 	</view>
 </template>
 </template>
@@ -33,24 +33,29 @@
 		data() {
 		data() {
 			return {
 			return {
 				ceshi: 'code',
 				ceshi: 'code',
-				huanjing: '部署环境' ,// 部署环境是key,用来获取环境
+				huanjing: '部署环境', // 部署环境是key,用来获取环境
 				visible: false,
 				visible: false,
 				showLogin: true,
 				showLogin: true,
 				appkey: '5AA49F3E4CACA380',
 				appkey: '5AA49F3E4CACA380',
-				sub_appid: '1015730314_1941301045',
 				appid: 'wx2fc3f45732fae5d3', // 获取用户信息
 				appid: 'wx2fc3f45732fae5d3', // 获取用户信息
 				ocode: '1015730314', // 获取用户信息
 				ocode: '1015730314', // 获取用户信息
 				app_secret: '58D34C81D82B35179ED896C4362B0FC0', // 获取用户信息
 				app_secret: '58D34C81D82B35179ED896C4362B0FC0', // 获取用户信息
 				my_display: false,
 				my_display: false,
-				userinfo: {},
+				userinfo: '',
 				wxcode: '',
 				wxcode: '',
-				access_token: ''
+				access_token: '',
+				code: '',
+				from: 0
 			}
 			}
 		},
 		},
-		onLoad() {
+		onLoad(options) {
+			console.log(options)
+			if (options && JSON.stringify(options) != '{}' && typeof(options.from) != 'undefined') {
+				this.from = options.from
+			}
 			// 是否是测试环境,查询数据接口中参数的值决定,方便以后测试
 			// 是否是测试环境,查询数据接口中参数的值决定,方便以后测试
 			this.isTestEnvironment()
 			this.isTestEnvironment()
-			
+
 			this.has_user_info()
 			this.has_user_info()
 		},
 		},
 		methods: {
 		methods: {
@@ -90,7 +95,7 @@
 			 */
 			 */
 			has_user_info() {
 			has_user_info() {
 				try {
 				try {
-					this.userinfo = this.$store.state.userinfo
+					this.userinfo = this.$store.state.userInfo
 					const value = uni.getStorageSync('userinfo_storage_key');
 					const value = uni.getStorageSync('userinfo_storage_key');
 					if (value == '') {
 					if (value == '') {
 						if (typeof(this.userinfo) == 'undefined' || JSON.stringify(this.userinfo) == '{}') {
 						if (typeof(this.userinfo) == 'undefined' || JSON.stringify(this.userinfo) == '{}') {
@@ -103,6 +108,7 @@
 					} else {
 					} else {
 						this.showLogin = false
 						this.showLogin = false
 						this.userinfo = value
 						this.userinfo = value
+						this.$store.state.userInfo = this.userinfo
 						this.my_display = true
 						this.my_display = true
 					}
 					}
 				} catch (e) {
 				} catch (e) {
@@ -124,7 +130,7 @@
 						this.userinfo = {}
 						this.userinfo = {}
 						this.my_display = false
 						this.my_display = false
 					}, 30)
 					}, 30)
-			
+
 					setTimeout(() => {
 					setTimeout(() => {
 						this.showLogin = true
 						this.showLogin = true
 						this.visible = true
 						this.visible = true
@@ -133,39 +139,79 @@
 					console.log(e)
 					console.log(e)
 				}
 				}
 			},
 			},
-			
 			/**
 			/**
-			 * 授权回调
+			 * 授权登陆q取消回调
+			 */
+			login_cancel_callback() {
+				this.userinfo = {};
+				uni.showToast({
+					icon: 'none',
+					title: '需要先授权,请点击右下角【重新授权】按钮'
+				});
+			},
+			/**
+			 * 授权登陆q取消回调
 			 */
 			 */
-			callback: function({
+			login_fail_callback() {
+				this.userinfo = {};
+				uni.showToast({
+					icon: 'none',
+					title: '授权失败,请先领取校园卡、激活',
+					duration: 3000,
+					success: (res) => {
+						uni.showModal({
+							title: '提示',
+							content: '是否将校园卡二维码,保存到相册?',
+							showCancel: false,
+							success: res => {
+								if (res.confirm) {
+									// 出现二维码,用户扫描二维码添加校园卡、激活
+									uni.downloadFile({
+										url: 'https://www.ecjtuit.edu.cn/img/zs.jpg',
+										success: (res) => {
+											console.log(res);
+											if (res.statusCode === 200) {
+												uni.saveImageToPhotosAlbum({
+													filePath: res.tempFilePath,
+													success: function() {
+														uni.showToast({
+															title: "保存成功",
+															icon: "none"
+														});
+													},
+													fail: function() {
+														uni.showToast({
+															title: "保存失败,请稍后重试",
+															icon: "none"
+														});
+													}
+												});
+											}
+										}
+									})
+								} else if (res.cancel) {
+									console.log('用户点击取消');
+								}
+							}
+						});
+					}
+				});
+			},
+			/**
+			 * 授权登陆成功回调
+			 */
+			login_success_callback: function({
 				detail
 				detail
 			}) {
 			}) {
-				// console.log(detail)
-				// {wxcode: "7f7Qi9rN8zQ1nifQiysTZ3WIeIWlgcGk"}
-				if (detail === undefined) {
-					this.userinfo = {};
-					uni.showToast({
-						icon: 'success',
-						title: '需要先授权'
-					});
-				} else {
-					const {
-						wxcode = ""
-					} = detail
-					
-					if (wxcode.length == 0) {
-						uni.showToast({
-							title: '未获得wxcode',
-							duration: 500
-						})
-					} else {
-						// 获取wxcode
-						this.wxcode = wxcode
-			
-						// 通过wxcode换取access_token
-						this.get_access_token()
-					}
-				}
+				const {
+					wxcode = ""
+				} = detail
+
+				// 获取wxcode
+				this.wxcode = wxcode
+
+				// 通过wxcode换取access_token
+				this.get_access_token()
 			},
 			},
 			/**
 			/**
 			 * 通过wxcode换取access_token
 			 * 通过wxcode换取access_token
@@ -183,17 +229,17 @@
 						'app_key': this.appkey,
 						'app_key': this.appkey,
 						'app_secret': this.app_secret,
 						'app_secret': this.app_secret,
 						'grant_type': 'authorization_code',
 						'grant_type': 'authorization_code',
-						'redirect_uri': 'mnp://wx2fc3f45732fae5d3'
+						'redirect_uri': 'mnp://' + this.appid
 					}
 					}
 				})
 				})
-			
+
 				if (res.data.refresh_token == '' || typeof(res.data.refresh_token) == 'undefined') {
 				if (res.data.refresh_token == '' || typeof(res.data.refresh_token) == 'undefined') {
 					uni.showToast({
 					uni.showToast({
 						title: '未获得token'
 						title: '未获得token'
 					});
 					});
 				} else {
 				} else {
 					this.access_token = res.data.access_token;
 					this.access_token = res.data.access_token;
-			
+
 					// 通过access_token换取用户信息
 					// 通过access_token换取用户信息
 					this.get_user_info();
 					this.get_user_info();
 				}
 				}
@@ -213,22 +259,14 @@
 						"access_token": this.access_token
 						"access_token": this.access_token
 					}
 					}
 				});
 				});
-			
+
 				if (res.data.errcode == 0 && res.data.errmsg == 'OK') {
 				if (res.data.errcode == 0 && res.data.errmsg == 'OK') {
 					try {
 					try {
 						this.userinfo = res.data
 						this.userinfo = res.data
-						this.$store.state.userinfo = this.userinfo
-						// 存储用户信息
-						uni.setStorageSync('userinfo_storage_key', this.userinfo)
-						// 提示授权成功
-						uni.showToast({
-							icon: 'success',
-							title: '授权成功',
-							duration: 800,
-							success: (res) => {
-								this.my_display = true
-							}
-						})
+						this.$store.state.userInfo = this.userinfo
+
+						// 获得code,然后去检查是否存在数据库中
+						this.getCode()
 					} catch (e) {
 					} catch (e) {
 						console.log(e)
 						console.log(e)
 					}
 					}
@@ -240,24 +278,71 @@
 				}
 				}
 			},
 			},
 			/**
 			/**
+			 * 获得code
+			 */
+			getCode() {
+				uni.login({
+					success: (res) => {
+						// console.log('reshui', res);
+						if (res.code) {
+							this.code = res.code
+
+							// 检查用户是否存在第三方库
+							this.chk_user_is_in_db()
+						} else {
+							uni.showToast({
+								title: res.errMsg,
+								icon: 'none'
+							});
+						}
+					}
+				})
+			},
+			/**
 			 * 检查数据库中是否有该用户信息
 			 * 检查数据库中是否有该用户信息
 			 */
 			 */
 			async chk_user_is_in_db() {
 			async chk_user_is_in_db() {
 				const res = await this.$myRequest({
 				const res = await this.$myRequest({
+					// host: 'local',
 					host: this.ceshi,
 					host: this.ceshi,
-					url: '/',
+					url: '/HotWaters/wpopenid.action',
 					method: 'POST',
 					method: 'POST',
 					header: {
 					header: {
-						'content-type': 'application/json'
+						'content-type': 'application/x-www-form-urlencoded'
 					},
 					},
 					data: {
 					data: {
-						"access_token": this.access_token
+						"userinfo": JSON.stringify(this.userinfo),
+						"code": this.code
 					}
 					}
 				});
 				});
-				
-				if (res) {
-					console.log(res);
-					
+
+				// console.log(res);
+				if (res.data.code == 0 || res.data.code == 100) {
+					// 存储用户信息
+					uni.setStorageSync('userinfo_storage_key', this.userinfo)
+					// 提示授权成功
+					uni.showToast({
+						icon: 'success',
+						title: '授权成功',
+						duration: 800,
+						success: (res) => {
+							this.my_display = true
+
+							if (this.from != 0) {
+								uni.navigateBack({
+									delta: 1
+								})
+							}
+						}
+					})
+				} else {
+					uni.showToast({
+						icon: 'success',
+						title: '授权失败:' + res.data.mess,
+						success: (res) => {
+							this.my_display = false
+						}
+					})
 				}
 				}
 			}
 			}
 		}
 		}
@@ -315,7 +400,7 @@
 					color: #333333;
 					color: #333333;
 				}
 				}
 			}
 			}
-			
+
 			.reset {
 			.reset {
 				position: fixed;
 				position: fixed;
 				display: flex;
 				display: flex;
@@ -325,7 +410,7 @@
 				bottom: 55rpx;
 				bottom: 55rpx;
 				font-family: Microsoft YaHei-3970(82674968);
 				font-family: Microsoft YaHei-3970(82674968);
 				color: #333333;
 				color: #333333;
-			
+
 				.icon-zhongzhi {
 				.icon-zhongzhi {
 					margin: 0 auto;
 					margin: 0 auto;
 					padding-top: 20rpx;
 					padding-top: 20rpx;

+ 1 - 0
pages/jiaofei/jiaofei.css

@@ -177,4 +177,5 @@ page {
 	background: url(../../static/images/gou.png) 0upx 0upx no-repeat;
 	background: url(../../static/images/gou.png) 0upx 0upx no-repeat;
 	background-size: 20%;
 	background-size: 20%;
 	background-position: right bottom;
 	background-position: right bottom;
+	background-color: rgba(18,150,219,0.1);
 }
 }

+ 63 - 31
pages/jiaofei/jiaofei.vue

@@ -68,11 +68,9 @@
 	export default {
 	export default {
 		data() {
 		data() {
 			return {
 			return {
-				// index: 0,
 				roomSelect: '', //校区宿舍号
 				roomSelect: '', //校区宿舍号
 				remainElec: 0.00.toFixed(2), //剩余电量
 				remainElec: 0.00.toFixed(2), //剩余电量
 				add_class: '', //增加class属性
 				add_class: '', //增加class属性
-				// add_class1: '',
 				amount: '',
 				amount: '',
 				sub_appid: '', //商户号
 				sub_appid: '', //商户号
 				code: '',
 				code: '',
@@ -84,31 +82,42 @@
 				test: this.$store.state.test
 				test: this.$store.state.test
 			}
 			}
 		},
 		},
-		onLoad: function() {
-			// 初始化参数
-			this.$store.state.building.roomSelect = '';
-			this.$store.state.building.add_class = 0;
-			this.$store.state.building.dorm_number = '';
-
-			// 获得code
-			this.getCode()
+		onLoad(options) {
+			// console.log(options);
+			// 获取基本信息
+			this.get_base_info(options, 'onLoad')
 		},
 		},
 		onShow() {
 		onShow() {
-			if (this.$store.state.building.roomSelect != '') {
-				// 如果是选择宿舍号返回
-				this.roomSelect = this.$store.state.building.roomSelect;
-				this.add_class = this.$store.state.building.add_class;
-				this.dorm_number = this.$store.state.building.dorm_number;
-
-				this.add_class = 1
-				if (this.roomSelect != '') {
-					this.getDianLiang()
-				}
-			}
+			// 获取基本信息
+			this.get_base_info('options', 'onShow')
 		},
 		},
 		methods: {
 		methods: {
 			/**
 			/**
-			 * 获得code
+			 * 获取基本信息
+			 */
+			get_base_info(options, param) {
+				if (param == 'onShow') {
+					// 获取电量
+					if (this.$store.state.building.roomSelect != '') {
+						// 如果是选择宿舍号返回
+						this.roomSelect = this.$store.state.building.roomSelect;
+						this.add_class = this.$store.state.building.add_class;
+						this.dorm_number = this.$store.state.building.dorm_number;
+
+						this.add_class = 1
+						if (this.roomSelect != '') {
+							this.getDianLiang()
+						}
+					}
+				} else {
+					// 初始化参数
+					this.$store.state.building.add_class = 0;
+					// 获取code
+					this.getCode('')
+				}
+			},
+			/**
+			 * 获取code
 			 */
 			 */
 			getCode(param) {
 			getCode(param) {
 				uni.login({
 				uni.login({
@@ -118,7 +127,7 @@
 							this.code = res.code
 							this.code = res.code
 							// 请求服务器,获得openid
 							// 请求服务器,获得openid
 							if (param == 'comfirm') {
 							if (param == 'comfirm') {
-								// // 获取IP
+								// 获取IP
 								this.getIP()
 								this.getIP()
 							} else
 							} else
 								this.getOpenId()
 								this.getOpenId()
@@ -127,6 +136,11 @@
 								title: res.errMsg,
 								title: res.errMsg,
 								icon: 'none'
 								icon: 'none'
 							});
 							});
+
+							// 跳转到首页
+							uni.redirectTo({
+								url: '../index/index'
+							});
 						}
 						}
 					}
 					}
 				})
 				})
@@ -170,8 +184,6 @@
 
 
 					// console.log('获得openid', res);
 					// console.log('获得openid', res);
 					if (res.data.mess == '返回成功') {
 					if (res.data.mess == '返回成功') {
-						// 学号
-						this.$store.state.stu_number = res.data.info[0].stu_number
 						// 栋宿舍号
 						// 栋宿舍号
 						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
 						// 校区
 						// 校区
@@ -183,10 +195,35 @@
 						// 样式
 						// 样式
 						this.add_class = 1
 						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()
 						this.getDianLiang()
-
 					} else if (res.data.mess == '未查询到用户信息') {
 					} else if (res.data.mess == '未查询到用户信息') {
+						// 跳转到首页
 						uni.redirectTo({
 						uni.redirectTo({
 							url: '../index/index'
 							url: '../index/index'
 						});
 						});
@@ -341,10 +378,6 @@
 					}
 					}
 				})
 				})
 
 
-				uni.showToast({
-					title: res.data.pay,
-					duration: 10000
-				});
 				// console.log(res);
 				// console.log(res);
 				if (res.data.pay == 'error') {
 				if (res.data.pay == 'error') {
 					uni.showToast({
 					uni.showToast({
@@ -391,7 +424,6 @@
 				}
 				}
 
 
 				const v = e.detail.value
 				const v = e.detail.value
-				this.amount = 10
 
 
 				const zero = /^(0{1,})|[^0-9]/g
 				const zero = /^(0{1,})|[^0-9]/g
 				let final = 0
 				let final = 0

+ 10 - 13
pages/recharge/recharge.vue

@@ -8,7 +8,7 @@
 			<view class="amount_tip">充值金额(元)</view>
 			<view class="amount_tip">充值金额(元)</view>
 			<view class="amount_inp">
 			<view class="amount_inp">
 				<text></text>
 				<text></text>
-				<input type="number" maxlength="4" v-model="amount" @input="onInput" @blur="onBlur"
+				<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>
 			</view>
 			<text>最多可输入金额100元</text>
 			<text>最多可输入金额100元</text>
@@ -35,7 +35,7 @@
 	export default {
 	export default {
 		data() {
 		data() {
 			return {
 			return {
-				amount: 10, // 金额
+				amount: '', // 金额
 				phone_number: '13645689854', // 客户热线电话
 				phone_number: '13645689854', // 客户热线电话
 				IP: '',
 				IP: '',
 				code: '',
 				code: '',
@@ -46,8 +46,6 @@
 		onLoad() {
 		onLoad() {
 			if (this.test) {
 			if (this.test) {
 				this.amount = 0.01
 				this.amount = 0.01
-			} else {
-				this.amount = ''
 			}
 			}
 		},
 		},
 		methods: {
 		methods: {
@@ -114,6 +112,7 @@
 						ip: this.IP
 						ip: this.IP
 					}
 					}
 				})
 				})
+				
 				// console.log(res);
 				// console.log(res);
 				if (res.data.pay == 'error') {
 				if (res.data.pay == 'error') {
 					uni.showToast({
 					uni.showToast({
@@ -162,7 +161,6 @@
 				}
 				}
 
 
 				const v = e.detail.value
 				const v = e.detail.value
-				this.amount = 10
 
 
 				const zero = /^(0{1,})|[^0-9]/g
 				const zero = /^(0{1,})|[^0-9]/g
 				let final = 0
 				let final = 0
@@ -273,14 +271,12 @@
 	}
 	}
 </script>
 </script>
 
 
-<style lang="scss" scoped>
+<style scoped lang="scss">
 	.content {
 	.content {
 		display: flex;
 		display: flex;
 		flex-direction: column;
 		flex-direction: column;
 		background-color: #F5F5F5;
 		background-color: #F5F5F5;
 		width: 750rpx;
 		width: 750rpx;
-		// height: 100%;
-		// align-items: stretch;
 
 
 		.title {
 		.title {
 			display: flex;
 			display: flex;
@@ -304,8 +300,8 @@
 			background-color: #FFFFFF;
 			background-color: #FFFFFF;
 			width: 670rpx;
 			width: 670rpx;
 			height: 210rpx;
 			height: 210rpx;
-			padding: 40rpx 40rpx 0 40rpx;
-			border-radius: 40rpx 40rpx 0 0;
+			padding: 40rpx 40rpx 0rpx 40rpx;
+			border-radius: 40rpx 40rpx 0rpx 0rpx;
 
 
 			.amount_tip {
 			.amount_tip {
 				font-size: 32rpx;
 				font-size: 32rpx;
@@ -332,7 +328,7 @@
 					content: '¥';
 					content: '¥';
 				}
 				}
 
 
-				input {
+				.inp {
 					width: 620rpx;
 					width: 620rpx;
 					height: 80rpx;
 					height: 80rpx;
 					font-size: 50rpx;
 					font-size: 50rpx;
@@ -341,8 +337,9 @@
 				}
 				}
 
 
 				/deep/.ph_class {
 				/deep/.ph_class {
-					font-size: 28rpx;
+					font-size: 32rpx;
 					font-weight: normal;
 					font-weight: normal;
+					color: #B2B2B2;
 				}
 				}
 			}
 			}
 
 
@@ -354,7 +351,7 @@
 		}
 		}
 
 
 		.amount_select {
 		.amount_select {
-			padding: 40rpx;
+			padding: 0rpx 40rpx 40rpx 40rpx;
 
 
 			.amount_btn {
 			.amount_btn {
 				display: flex;
 				display: flex;

+ 98 - 48
pages/reshui/reshui.vue

@@ -81,7 +81,7 @@
 				}),
 				}),
 				startDate: this.$getDate('start_date'),
 				startDate: this.$getDate('start_date'),
 				endDate: this.$getDate('end_date'),
 				endDate: this.$getDate('end_date'),
-				flag: true,
+				flag: false,
 				isUserClose: false, // 是否是用户自己关闭
 				isUserClose: false, // 是否是用户自己关闭
 				isChecked: false,
 				isChecked: false,
 				isConnected: false, // 是否连接上
 				isConnected: false, // 是否连接上
@@ -112,42 +112,85 @@
 				use_amount: 0.0.toFixed(2), // 结算金额
 				use_amount: 0.0.toFixed(2), // 结算金额
 				amount: 0.0.toFixed(2), // 余额
 				amount: 0.0.toFixed(2), // 余额
 				dorm_number: '', // 宿舍号
 				dorm_number: '', // 宿舍号
+				stu_number: '', // 学号
 				// compus: '', // 校区
 				// compus: '', // 校区
 				code: '',
 				code: '',
 				ceshi: 'code',
 				ceshi: 'code',
-				changeDate: false
+				changeDate: false // 是否是手动选择日期
 			}
 			}
 		},
 		},
-		onLoad() {
-			try {
-				const value = uni.getStorageSync('instruction_noshow');
-				if (value) {
-					this.flag = false
-				}
-			} catch (e) {
-				console.log(e);
-			}
-			// 获得code
-			this.getCode()
+		onLoad(options) {
+			// 获取基本信息
+			this.get_base_info(options, 'onLoad')
 		},
 		},
 		onShow() {
 		onShow() {
-			if (this.$store.state.payInfo.from == 'reshui_pay') {
-				uni.showToast({
-					title: this.$store.state.payInfo.resultMsg,
-					icon: 'success',
-					success: () => {
-						this.$store.state.payInfo.resultMsg = ''
-						this.$store.state.payInfo.from = ''
-					}
-				})
-
-				// this.amount = this.$store.state.reshui_amount + this.amount
-				// 重新调用一次,刷新金额
-				this.getCode()
-			}
+			// 获取基本信息
+			this.get_base_info('options', 'onShow')
 		},
 		},
 		methods: {
 		methods: {
 			/**
 			/**
+			 * 获取基本信息
+			 */
+			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
+							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
+							});
+						}
+					} else {
+						// 初始化参数
+						this.$store.state.building.add_class = 0;
+						
+						const value = uni.getStorageSync('instruction_noshow');
+						if (!value) {
+							this.flag = true
+						}
+						// 获得code
+						this.getCode()
+					}
+				} catch (e) {
+					console.log(e);
+				}
+
+				if (param == 'onShow') {
+					if (this.$store.state.payInfo.from == 'reshui_pay') {
+						uni.showToast({
+							title: this.$store.state.payInfo.resultMsg,
+							icon: 'success',
+							success: () => {
+								this.$store.state.payInfo.resultMsg = ''
+								this.$store.state.payInfo.from = ''
+							}
+						})
+
+						// this.amount = this.$store.state.reshui_amount + this.amount
+						// 重新调用一次,刷新金额
+						this.getCode()
+					}
+				}
+			},
+			/**
 			 * 获得code
 			 * 获得code
 			 */
 			 */
 			getCode() {
 			getCode() {
@@ -173,7 +216,7 @@
 			async getOpenId() {
 			async getOpenId() {
 				if (this.code == '') {
 				if (this.code == '') {
 					uni.showToast({
 					uni.showToast({
-						title: 'code未获取到!',
+						title: 'code未获!',
 						icon: 'success'
 						icon: 'success'
 					});
 					});
 					return
 					return
@@ -192,21 +235,28 @@
 
 
 				// console.log(res);
 				// console.log(res);
 				if (res.data.mess == '返回成功') {
 				if (res.data.mess == '返回成功') {
-					// 学号
-					this.$store.state.stu_number = res.data.info[0].stu_number
-					// 剩余金额
-					if (res.data.info[0].balance > 0)
-						this.$store.state.reshui_amount = res.data.info[0].balance
-					// 剩余金额
-					this.amount = this.$store.state.reshui_amount
-					// 组合楼栋宿舍号
-					this.dorm_number = res.data.info[0].build + res.data.info[0].dom
-					// 校区
-					// this.compus = res.data.info[0].campus
-
-					// 请求选定的月份消费记录
-					this.request_consumption_records()
-
+					// 判断存储的stu_number与返回的stu_number是否一致
+					// if (res.data.info[0].stu_number == this.$store.state.userInfo.card_number) {
+					if (res.data.info[0].card_number == this.$store.state.userInfo.card_number) {
+						// 学号
+						this.stu_number = res.data.info[0].stu_number
+						// 剩余金额
+						this.amount = res.data.info[0].balance.toFixed(2)
+						if (this.amount > 0)
+							this.$store.state.reshui_amount = this.amount
+						// 组合楼栋宿舍号
+						this.dorm_number = res.data.info[0].build + res.data.info[0].dom
+						// 校区
+						// this.compus = res.data.info[0].campus
+
+						// 请求选定的月份消费记录
+						this.request_consumption_records()
+					} else {
+						uni.showToast({
+							title: '学工号不一致!',
+							icon: 'success'
+						});
+					}
 				} else if (res.data.mess == '未查询到用户信息') {
 				} else if (res.data.mess == '未查询到用户信息') {
 					uni.redirectTo({
 					uni.redirectTo({
 						url: '../index/index'
 						url: '../index/index'
@@ -247,7 +297,7 @@
 			 * 请求选定的月份消费记录
 			 * 请求选定的月份消费记录
 			 */
 			 */
 			async request_consumption_records() {
 			async request_consumption_records() {
-				if (this.$store.state.stu_number != '') {
+				if (this.stu_number != '' && typeof(this.stu_number) != 'undefined') {
 					this.xiaofei_items = []
 					this.xiaofei_items = []
 					const res = await this.$myRequest({
 					const res = await this.$myRequest({
 						host: this.ceshi,
 						host: this.ceshi,
@@ -257,7 +307,7 @@
 							'content-type': 'application/x-www-form-urlencoded'
 							'content-type': 'application/x-www-form-urlencoded'
 						},
 						},
 						data: {
 						data: {
-							stu_number: this.$store.state.stu_number,
+							stu_number: this.stu_number,
 							begin_time: this.date
 							begin_time: this.date
 						}
 						}
 					});
 					});
@@ -283,7 +333,7 @@
 				} else {
 				} else {
 					uni.showToast({
 					uni.showToast({
 						icon: 'success',
 						icon: 'success',
-						title: '学号为空'
+						title: '未获得学号'
 					})
 					})
 				}
 				}
 			},
 			},
@@ -993,13 +1043,13 @@
 			 * 请求获取设备启动码
 			 * 请求获取设备启动码
 			 */
 			 */
 			async request_device_start_code() {
 			async request_device_start_code() {
-				if (this.byte35 != '' && this.$store.state.stu_number != '') {
+				if (this.byte35 != '' && this.stu_number != '') {
 					const res = await this.$myRequest({
 					const res = await this.$myRequest({
 						host: this.ceshi,
 						host: this.ceshi,
 						url: '/HotWaters/wpstart.action',
 						url: '/HotWaters/wpstart.action',
 						data: {
 						data: {
 							collect_code: this.byte35,
 							collect_code: this.byte35,
-							stu_number: this.$store.state.stu_number
+							stu_number: this.stu_number
 						}
 						}
 					})
 					})
 
 

+ 0 - 9
pages/select/select.vue

@@ -342,17 +342,8 @@
 					else if (this.allData.data[this.index1].builds[this.index2].floors[this.index3].rooms[i] == index[0]) {
 					else if (this.allData.data[this.index1].builds[this.index2].floors[this.index3].rooms[i] == index[0]) {
 						this.index4 = i
 						this.index4 = i
 					}
 					}
-					//将选择器中的值加到变量room中,传到下一个页面
-					// this.room = this.room.concat(this.array1[this.index1], this.array2[this.index2], this.array3[this.index3],
-					// 	this.array4[this.index4]);
 				}
 				}
 				this.room = this.room.concat(this.array1[this.index1], this.array4[this.index4]);
 				this.room = this.room.concat(this.array1[this.index1], this.array4[this.index4]);
-				// this.dis_num5 = 0;
-				// console.log(this.array1[this.index1])
-				// console.log(this.array2[this.index2])
-				// console.log(this.array3[this.index3])
-				// console.log(this.array4[this.index4])
-				// console.log(this.room)
 			},
 			},
 			//跳转缴费页面
 			//跳转缴费页面
 			navigateToIndex(e) {
 			navigateToIndex(e) {

+ 63 - 26
pages/show/show.vue

@@ -58,37 +58,69 @@
 				}),
 				}),
 				startDate: this.$getDate('start_date'),
 				startDate: this.$getDate('start_date'),
 				endDate: this.$getDate('end_date'),
 				endDate: this.$getDate('end_date'),
-				all_data: '', //所有数据
-				list: [], //消费列表
+				all_data: '', // 所有数据
+				list: [], // 消费列表
 				code: '',
 				code: '',
 				ceshi: 'code',
 				ceshi: 'code',
-				stu_number: 0, //用户卡号
+				stu_number: '', // 学号
+				roomSelect: '', // 选择的宿舍号
+				changeDate: false // 是否是手动选择日期
 			}
 			}
 		},
 		},
 		onLoad() {
 		onLoad() {
-			// 获取学号
-			this.stu_number = this.$store.state.stu_number
-			// 充值记录
-			this.get_chongzhijilu()
-			// 消费记录
-			this.get_xiaofeijilu()
+			try {
+				// 获取学号
+				this.stu_number = this.$store.state.userInfo.card_number
+				this.roomSelect = this.$store.state.building.roomSelect
+
+				if (this.stu_number == '' || this.roomSelect == '' || typeof(this.stu_number) == 'undefined' || 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 {
+						uni.redirectTo({
+							url: '../index/index'
+						})
+
+						uni.showToast({
+							icon: 'none',
+							title: '学号或宿舍号为空,请授权',
+							duration: 3000
+						})
+						
+						return
+					}
+				}
+				// console.log(this.stu_number);
+				// console.log(this.roomSelect);
+				// 能耗记录
+				this.get_nenghaojilu()
+				// 缴费记录
+				this.get_jiaofeijilu()
+			} catch (e) {
+				console.log(e);
+			}
 		},
 		},
 		methods: {
 		methods: {
 			/**
 			/**
 			 * 获取选择日期
 			 * 获取选择日期
-			 * @param {Object} e
 			 */
 			 */
 			bindDateChange: function(e) {
 			bindDateChange: function(e) {
 				this.date = e.detail.value
 				this.date = e.detail.value
-				// 充值记录
-				this.get_chongzhijilu()
+				this.changeDate = true
+				// 能耗记录
+				this.get_nenghaojilu()
+				// 缴费记录
+				this.get_jiaofeijilu()
 			},
 			},
 			/**
 			/**
-			 * 获取充值记录
+			 * 获取缴费记录
 			 */
 			 */
-			async get_chongzhijilu() {
-				// console.log(this.$store.state.stu_number);
-				if (this.$store.state.stu_number != '') {
+			async get_jiaofeijilu() {
+				// console.log(this.stu_number);
+				if (this.stu_number != '') {
 					const res = await this.$myRequest({
 					const res = await this.$myRequest({
 						host: this.ceshi,
 						host: this.ceshi,
 						url: '/HotWaters/elqueyRecordEle.action',
 						url: '/HotWaters/elqueyRecordEle.action',
@@ -97,17 +129,22 @@
 							'content-type': 'application/x-www-form-urlencoded'
 							'content-type': 'application/x-www-form-urlencoded'
 						},
 						},
 						data: {
 						data: {
-							'stu_number': this.$store.state.stu_number,
+							'stu_number': this.stu_number,
 							're_time': this.date
 							're_time': this.date
 						}
 						}
 					})
 					})
-					
+
 					// console.log(res);
 					// console.log(res);
 					if (res.data.mess == '未查到记录') {
 					if (res.data.mess == '未查到记录') {
-						uni.showToast({
-							title: '该月无缴费记录',
-							icon: 'success'
-						});
+						if (this.changeDate) {
+							uni.showToast({
+								title: '该月无缴费记录',
+								icon: 'success',
+								success: (res) => {
+									this.changeDate = false
+								}
+							});
+						}
 					} else {
 					} else {
 						// 充值绑定显示到界面
 						// 充值绑定显示到界面
 						for (var i = 0; i < res.data.data.length; i++) {
 						for (var i = 0; i < res.data.data.length; i++) {
@@ -122,10 +159,10 @@
 				}
 				}
 			},
 			},
 			/**
 			/**
-			 * 缴费记录
+			 * 能耗记录
 			 */
 			 */
-			async get_xiaofeijilu() {
-				if (this.$store.state.building.roomSelect != '') {
+			async get_nenghaojilu() {
+				if (this.roomSelect != '' && typeof(this.roomSelect) != 'undefined') {
 					const res = await this.$myRequest({
 					const res = await this.$myRequest({
 						host: this.ceshi,
 						host: this.ceshi,
 						url: '/HotWaters/buildgetMonthBill.action',
 						url: '/HotWaters/buildgetMonthBill.action',
@@ -134,7 +171,7 @@
 							'content-type': 'application/x-www-form-urlencoded'
 							'content-type': 'application/x-www-form-urlencoded'
 						},
 						},
 						data: {
 						data: {
-							'roomSelect': this.$store.state.building.roomSelect
+							'roomSelect': this.roomSelect
 						}
 						}
 					})
 					})
 
 

+ 3 - 0
static/api.js

@@ -2,6 +2,7 @@ const WEXIN_BASE_URL = 'https://api.mch.weixin.qq.com' // wexin
 const WECARD_BASE_URL = 'https://open.wecard.qq.com' // wecard
 const WECARD_BASE_URL = 'https://open.wecard.qq.com' // wecard
 const CODE_BASE_URL = 'https://jtishfw.ncjti.edu.cn/jxch-smartmp' // code
 const CODE_BASE_URL = 'https://jtishfw.ncjti.edu.cn/jxch-smartmp' // code
 const IP_BASE_URL = 'https://pv.sohu.com/cityjson' // ip
 const IP_BASE_URL = 'https://pv.sohu.com/cityjson' // ip
+// const LOCAL_BASE_URL = 'http://baibai.natapp1.cc' // local
 
 
 const myRequest = (options) => {
 const myRequest = (options) => {
 	// 域名 或 url 为空,则不执行任何操作
 	// 域名 或 url 为空,则不执行任何操作
@@ -20,6 +21,8 @@ const myRequest = (options) => {
 			BASE_URL = CODE_BASE_URL;
 			BASE_URL = CODE_BASE_URL;
 		} else if (options.host == 'ip') {
 		} else if (options.host == 'ip') {
 			BASE_URL = IP_BASE_URL;
 			BASE_URL = IP_BASE_URL;
+		// } else if (options.host == 'local') {
+			// BASE_URL = LOCAL_BASE_URL;
 		} else {
 		} else {
 			uni.showToast({
 			uni.showToast({
 				title: '域名无效',
 				title: '域名无效',