Browse Source

解决学号为空

soft5566 3 years ago
parent
commit
24f3b7b2f1

+ 59 - 0
components/Popup.vue

@@ -0,0 +1,59 @@
+<template>
+	<view v-if="showPopup" class="popup-mask">
+		<view class="popup-content">
+			<view class="close-button" @click="closePopup">×</view>
+			<slot></slot>
+		</view>
+	</view>
+</template>
+<script>
+	export default {
+		props: {
+			showPopup: {
+				type: Boolean,
+				default: false
+			}
+		},
+		methods: {
+			closePopup() {
+				this.$emit('close');
+			}
+		}
+	};
+</script>
+<style>
+	.popup-mask {
+		position: fixed;
+		top: 0;
+		left: 0;
+		width: 100%;
+		height: 100%;
+		background-color: rgba(0, 0, 0, 0.5);
+		display: flex;
+		justify-content: center;
+		align-items: center;
+	}
+
+	.popup-content {
+		/* Styling for the popup content */
+		background-color: rgba(255, 255, 255, 0.8);
+		width: 100%;
+		height: 60%;
+		padding: 30rpx;
+	}
+
+	.close-button {
+		position: absolute;
+		top: 10px;
+		right: 10px;
+		font-size: 20px;
+		color: #fff;
+		cursor: pointer;
+		width: 46rpx;
+		height: 46rpx;
+		line-height: 46rpx;
+		text-align: center;
+		border-radius: 23rpx;
+		background-color: rgba(255, 255, 255, 0.3);
+	}
+</style>

+ 46 - 58
pages/index/index.vue

@@ -15,10 +15,10 @@
 					<image src="../../static/images/air.png" mode=""></image>
 					<image src="../../static/images/air.png" mode=""></image>
 					<text>共享空调</text>
 					<text>共享空调</text>
 				</navigator>
 				</navigator>
-				<!-- <navigator :url="'/pagesBus/bus/bus'" open-type="navigate" class="menu_item">
+				<navigator :url="'/pagesBus/bus/bus'" open-type="navigate" class="menu_item">
 					<image src="../../static/images/bus.png" mode=""></image>
 					<image src="../../static/images/bus.png" mode=""></image>
 					<text>校车预约</text>
 					<text>校车预约</text>
-				</navigator> -->
+				</navigator>
 				<!-- <navigator :url="'/pagesClockIn/index/index'" open-type="navigate" class="menu_item">
 				<!-- <navigator :url="'/pagesClockIn/index/index'" open-type="navigate" class="menu_item">
 					<image src="../../static/images/clockIn.png" mode=""></image>
 					<image src="../../static/images/clockIn.png" mode=""></image>
 					<text>校园打卡</text>
 					<text>校园打卡</text>
@@ -29,23 +29,32 @@
 				</navigator> -->
 				</navigator> -->
 			</view>
 			</view>
 		</view>
 		</view>
-		<view class="qr_code" v-if="showQR_code"><image :src="qr_code_url" mode="aspectFit"></image></view>
 		<view v-if="showLogin">
 		<view v-if="showLogin">
 			<login
 			<login
 				:ocode="ocode"
 				:ocode="ocode"
 				:appkey="appkey"
 				:appkey="appkey"
 				scope="snsapi_userinfo"
 				scope="snsapi_userinfo"
 				:visible="visible"
 				:visible="visible"
-				@success="login_success_callback()"
-				@cancel="login_cancel_callback()"
-				@fail="login_fail_callback()"
+				@success="login_success_callback"
+				@cancel="login_cancel_callback"
+				@fail="login_fail_callback"
 			/>
 			/>
 		</view>
 		</view>
+		<Popup :showPopup="showPopup" @close="showPopup = false">
+			<view class="pupup-content">
+				<text class="pupup-title">请截屏,再识别二维码领取校园卡</text>
+				<image src="../../static/images/qr.jpg" mode="aspectFill" class="pupup-img"></image>
+			</view>
+		</Popup>
 	</view>
 	</view>
 </template>
 </template>
 
 
 <script>
 <script>
+import Popup from '@/components/Popup.vue';
 export default {
 export default {
+	components: {
+	    Popup
+	},
 	data() {
 	data() {
 		return {
 		return {
 			ceshi: 'code',
 			ceshi: 'code',
@@ -62,7 +71,7 @@ export default {
 			validation_times: 0, // 授权次数
 			validation_times: 0, // 授权次数
 			from: 0, // 跳转参数
 			from: 0, // 跳转参数
 			execed_onload: false,
 			execed_onload: false,
-			qr_code_url: this.$code_base_url + '/HotWaters/image/1.jpg'
+			showPopup: false
 		}
 		}
 	},
 	},
 	onLoad(options) {
 	onLoad(options) {
@@ -168,7 +177,7 @@ export default {
 				this.login_fail_callback()
 				this.login_fail_callback()
 			} else {
 			} else {
 				try {
 				try {
-					uni.removeStorageSync('userinfo_storage_key')
+					// uni.removeStorageSync('userinfo_storage_key')
 					setTimeout(() => {
 					setTimeout(() => {
 						this.showLogin = false
 						this.showLogin = false
 						this.userinfo = {}
 						this.userinfo = {}
@@ -187,12 +196,10 @@ export default {
 		 * 授权登陆取消回调
 		 * 授权登陆取消回调
 		 */
 		 */
 		login_fail_callback() {
 		login_fail_callback() {
-			this.userinfo = {}
-			// setTimeout(() => {
-			// 	this.validation_failed = true
-			// }, 3000);
-			if (!this.validation_failed) {
-				this.validation_failed = false
+			var _this = this;
+			_this.userinfo = {}
+			if (!_this.validation_failed) {
+				_this.validation_failed = false
 				uni.showModal({
 				uni.showModal({
 					title: '提示',
 					title: '提示',
 					content: '授权:请先领取校园卡、并激活!',
 					content: '授权:请先领取校园卡、并激活!',
@@ -200,34 +207,8 @@ export default {
 					confirmText: '领取',
 					confirmText: '领取',
 					success: res1 => {
 					success: res1 => {
 						if (res1.confirm) {
 						if (res1.confirm) {
-							uni.navigateTo({
-								url: '../qr_code/qr_code'
-							})
-							// 出现二维码,用户扫描二维码添加校园卡、激活
-							// uni.downloadFile({
-							// 	url: 'https://chtech.ncjti.edu.cn/shuidian/HotWaters/image/1.jpg',
-							// 	success: (res2) => {
-							// 		// console.log(res2);
-							// 		if (res2.statusCode == 200) {
-							// 			uni.saveImageToPhotosAlbum({
-							// 				filePath: res2
-							// 					.tempFilePath,
-							// 				success: function() {
-							// 					uni.showToast({
-							// 						title: "保存成功!请用微信扫码添加校园卡!",
-							// 						icon: "none"
-							// 					});
-							// 				},
-							// 				fail: function() {
-							// 					uni.showToast({
-							// 						title: "保存失败,请手动截图保存,再用微信扫二维码!",
-							// 						icon: "none"
-							// 					});
-							// 				}
-							// 			});
-							// 		}
-							// 	}
-							// })
+							// 截屏,用户利用微信识别二维码添加校园卡、激活
+							_this.showPopup = true;
 						} else if (res1.cancel) {
 						} else if (res1.cancel) {
 							// console.log('用户点击取消');
 							// console.log('用户点击取消');
 							// uni.showToast({
 							// uni.showToast({
@@ -263,7 +244,7 @@ export default {
 			setTimeout(() => {
 			setTimeout(() => {
 				uni.hideLoading()
 				uni.hideLoading()
 			}, 1000)
 			}, 1000)
-
+			
 			// 通过wxcode换取access_token
 			// 通过wxcode换取access_token
 			this.get_access_token(wxcode)
 			this.get_access_token(wxcode)
 		},
 		},
@@ -310,14 +291,14 @@ export default {
 				data: {
 				data: {
 					access_token: param_access_token
 					access_token: param_access_token
 				}
 				}
-			})
+			});
 
 
 			// console.log(res);
 			// console.log(res);
 			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
-
+					this.$store.state.userInfo = res.data
+					
 					// 获取code,然后去检查是否存在数据库中
 					// 获取code,然后去检查是否存在数据库中
 					this.getCode()
 					this.getCode()
 				} catch (e) {
 				} catch (e) {
@@ -334,12 +315,13 @@ export default {
 		 * 获得code
 		 * 获得code
 		 */
 		 */
 		getCode() {
 		getCode() {
+			var _this = this;
 			uni.login({
 			uni.login({
 				success: res => {
 				success: res => {
 					// console.log('reshui', res);
 					// console.log('reshui', res);
 					if (res.code) {
 					if (res.code) {
 						// 检查用户是否存在第三方库
 						// 检查用户是否存在第三方库
-						this.chk_user_is_in_db(res.code)
+						_this.chk_user_is_in_db(res.code)
 					} else {
 					} else {
 						uni.showToast({
 						uni.showToast({
 							title: res.errMsg,
 							title: res.errMsg,
@@ -353,16 +335,17 @@ export default {
 		 * 检查数据库中是否有该用户信息
 		 * 检查数据库中是否有该用户信息
 		 */
 		 */
 		async chk_user_is_in_db(param_code) {
 		async chk_user_is_in_db(param_code) {
-			const res = await this.$myRequest({
+			var _this = this;
+			const res = await _this.$myRequest({
 				// host: 'local',
 				// host: 'local',
-				host: this.ceshi,
+				host: _this.ceshi,
 				url: '/HotWaters/wpopenid.action',
 				url: '/HotWaters/wpopenid.action',
 				method: 'POST',
 				method: 'POST',
 				header: {
 				header: {
 					'content-type': 'application/x-www-form-urlencoded'
 					'content-type': 'application/x-www-form-urlencoded'
 				},
 				},
 				data: {
 				data: {
-					userinfo: JSON.stringify(this.userinfo),
+					userinfo: JSON.stringify(_this.userinfo),
 					code: param_code
 					code: param_code
 				}
 				}
 			})
 			})
@@ -370,14 +353,14 @@ export default {
 			// console.log(res);
 			// console.log(res);
 			if (res.data.code == 0 || res.data.code == 100) {
 			if (res.data.code == 0 || res.data.code == 100) {
 				// 存储用户信息
 				// 存储用户信息
-				uni.setStorageSync('userinfo_storage_key', this.userinfo)
+				uni.setStorageSync('userinfo_storage_key', _this.userinfo)
 				// 提示授权成功
 				// 提示授权成功
 				uni.showToast({
 				uni.showToast({
 					icon: 'success',
 					icon: 'success',
 					title: '授权成功',
 					title: '授权成功',
 					duration: 800,
 					duration: 800,
 					success: res => {
 					success: res => {
-						if (this.from != 0 || this.from != '0') {
+						if (_this.from != 0 || _this.from != '0') {
 							uni.navigateBack({
 							uni.navigateBack({
 								delta: 1
 								delta: 1
 							})
 							})
@@ -469,16 +452,21 @@ export default {
 		}
 		}
 	}
 	}
 
 
-	.qr_code {
+		
+	.pupup-content {
 		display: flex;
 		display: flex;
+		flex-direction: column;
 		justify-content: center;
 		justify-content: center;
 		align-items: center;
 		align-items: center;
-		width: 750rpx;
 		height: 100%;
 		height: 100%;
-		position: fixed;
-		left: 0;
-		top: 0;
-		background-color: #ffffff;
+		
+		.pupup-title {
+			padding-bottom: 20rpx;
+		}
+		
+		.pupup-img {
+			height: 90%;
+		}
 	}
 	}
 }
 }
 </style>
 </style>

+ 4 - 0
pages/recharge/recharge.vue

@@ -36,6 +36,7 @@
 	export default {
 	export default {
 		data() {
 		data() {
 			return {
 			return {
+				card_number: '',
 				amount: '', // 金额
 				amount: '', // 金额
 				phone_number: '13645689854', // 客户热线电话
 				phone_number: '13645689854', // 客户热线电话
 				IP: '',
 				IP: '',
@@ -131,6 +132,7 @@
 					data: {
 					data: {
 						// ip: param_ip,
 						// ip: param_ip,
 						code: param_code,
 						code: param_code,
+						card_number: this.card_number,
 						num: this.amount
 						num: this.amount
 					}
 					}
 				})
 				})
@@ -238,6 +240,8 @@
 			has_user_info() {
 			has_user_info() {
 				try {
 				try {
 					const value = uni.getStorageSync('userinfo_storage_key');
 					const value = uni.getStorageSync('userinfo_storage_key');
+					if (value)
+						this.card_number = value.card_number;
 					// console.log(value.campus);
 					// console.log(value.campus);
 					if (value.campus != '墨轩湖校区') {
 					if (value.campus != '墨轩湖校区') {
 						this.isXiaoqu = false;
 						this.isXiaoqu = false;

+ 16 - 20
pages/reshui/reshui.vue

@@ -158,12 +158,6 @@
 					uni.getLocation({
 					uni.getLocation({
 						success: (loc) => {
 						success: (loc) => {
 							// console.log(loc);
 							// console.log(loc);
-							// uni.showToast({
-							// 	icon: 'none',
-							// 	title: '纬度:' + loc.latitude + '\n' + '经度:' + loc
-							// 		.longitude,
-							// 	duration: 2000
-							// })
 							uni.showToast({
 							uni.showToast({
 								icon: 'success',
 								icon: 'success',
 								title: '已获定位信息'
 								title: '已获定位信息'
@@ -337,7 +331,7 @@
 					// 获取学号
 					// 获取学号
 					this.stu_number = this.$store.state.userInfo.card_number
 					this.stu_number = this.$store.state.userInfo.card_number
 
 
-					if (this.stu_number == '' || typeof(this.stu_number) == 'undefined') {
+					if (this.stu_number == '' || typeof this.stu_number == 'undefined') {
 						const userinfo = uni.getStorageSync('userinfo_storage_key')
 						const userinfo = uni.getStorageSync('userinfo_storage_key')
 						if (userinfo) {
 						if (userinfo) {
 							this.stu_number = userinfo.card_number
 							this.stu_number = userinfo.card_number
@@ -371,7 +365,7 @@
 						})
 						})
 					}
 					}
 				}
 				}
-
+				
 				// 获取code
 				// 获取code
 				this.getCode(options, param);
 				this.getCode(options, param);
 			},
 			},
@@ -398,15 +392,17 @@
 			 * 请求服务器,获得openid
 			 * 请求服务器,获得openid
 			 */
 			 */
 			async getOpenId(options, param_code, param) {
 			async getOpenId(options, param_code, param) {
+				var _this = this;
 				const res = await this.$myRequest({
 				const res = await this.$myRequest({
-					host: this.ceshi,
+					host: _this.ceshi,
 					url: '/HotWaters/wpget_stu.action',
 					url: '/HotWaters/wpget_stu.action',
 					method: 'POST',
 					method: 'POST',
 					header: {
 					header: {
 						'content-type': 'application/x-www-form-urlencoded'
 						'content-type': 'application/x-www-form-urlencoded'
 					},
 					},
 					data: {
 					data: {
-						code: param_code
+						code: param_code,
+						card_number: _this.stu_number
 					}
 					}
 				})
 				})
 
 
@@ -416,23 +412,23 @@
 					let cardNumber = res.data.info[0].card_number
 					let cardNumber = res.data.info[0].card_number
 					if (typeof(cardNumber) != 'undefined' && cardNumber != '' && JSON.stringify(cardNumber) != '{}') {
 					if (typeof(cardNumber) != 'undefined' && cardNumber != '' && JSON.stringify(cardNumber) != '{}') {
 						// 学号 和 姓名
 						// 学号 和 姓名
-						this.stu_number = res.data.info[0].stu_number
-						this.user_name = res.data.info[0].user_name
+						_this.stu_number = res.data.info[0].stu_number
+						_this.user_name = res.data.info[0].user_name
 						// 剩余金额
 						// 剩余金额
-						this.amount = res.data.info[0].balance.toFixed(2)
-						// if (this.amount > 0)
-						this.$store.state.reshui_amount = this.amount
+						_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.dorm_number = res.data.info[0].build + res.data.info[0].dom
 						// 校区
 						// 校区
-						// this.compus = res.data.info[0].campus
+						// _this.compus = res.data.info[0].campus
 
 
 						if (param == 'onLoad' && typeof(options.from) != 'undefined' && options.from != 0) {
 						if (param == 'onLoad' && typeof(options.from) != 'undefined' && options.from != 0) {
 							// 初始化蓝牙
 							// 初始化蓝牙
-							this.openBluetoothAdapter()
+							_this.openBluetoothAdapter()
 						}
 						}
 						// 请求选定的月份消费记录
 						// 请求选定的月份消费记录
-						this.request_consumption_records()
+						_this.request_consumption_records()
 					} else {
 					} else {
 						uni.showToast({
 						uni.showToast({
 							title: '未获取到学号!',
 							title: '未获取到学号!',
@@ -445,7 +441,7 @@
 					}
 					}
 				} else if (res.data.mess == '未查询到用户信息') {
 				} else if (res.data.mess == '未查询到用户信息') {
 					// 数据库中 未查询到用户信息,就清除本地存储
 					// 数据库中 未查询到用户信息,就清除本地存储
-					uni.removeStorageSync('userinfo_storage_key');
+					// uni.removeStorageSync('userinfo_storage_key');
 
 
 					uni.showToast({
 					uni.showToast({
 						title: '获取用户信息失败!'
 						title: '获取用户信息失败!'

File diff suppressed because it is too large
+ 523 - 525
pagesElectric/jiaofei/jiaofei.vue


+ 10 - 9
pagesElectric/show/show.vue

@@ -165,37 +165,38 @@
 			 */
 			 */
 			async get_jiaofeijilu() {
 			async get_jiaofeijilu() {
 				// console.log(this.stu_number);
 				// console.log(this.stu_number);
-				if (this.stu_number != '') {
-					const res = await this.$myRequest({
-						host: this.ceshi,
+				var _this = this;
+				if (_this.stu_number != '') {
+					const res = await _this.$myRequest({
+						host: _this.ceshi,
 						url: '/HotWaters/elqueyRecordEle.action',
 						url: '/HotWaters/elqueyRecordEle.action',
 						method: 'POST',
 						method: 'POST',
 						header: {
 						header: {
 							'content-type': 'application/x-www-form-urlencoded'
 							'content-type': 'application/x-www-form-urlencoded'
 						},
 						},
 						data: {
 						data: {
-							'stu_number': this.stu_number,
-							're_time': this.date
+							'stu_number': _this.stu_number,
+							're_time': _this.date
 						}
 						}
 					})
 					})
 
 
 					// console.log(res);
 					// console.log(res);
 					if (res.data.mess == '未查到记录') {
 					if (res.data.mess == '未查到记录') {
-						if (this.changeDate) {
+						if (_this.changeDate) {
 							uni.showToast({
 							uni.showToast({
 								title: '该月无缴费记录',
 								title: '该月无缴费记录',
 								icon: 'success',
 								icon: 'success',
 								success: (res) => {
 								success: (res) => {
-									this.changeDate = false
+									_this.changeDate = false
 								}
 								}
 							});
 							});
 
 
-							this.list = []
+							_this.list = []
 						}
 						}
 					} else {
 					} else {
 						// 充值绑定显示到界面
 						// 充值绑定显示到界面
 						for (var i = 0; i < res.data.data.length; i++) {
 						for (var i = 0; i < res.data.data.length; i++) {
-							this.list.push(res.data.data[i])
+							_this.list.push(res.data.data[i])
 						}
 						}
 					}
 					}
 				} else {
 				} else {

+ 2 - 1
static/api.js

@@ -1,6 +1,7 @@
 const WEXIN_BASE_URL = 'https://api.mch.weixin.qq.com' // wexin
 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://chtech.ncjti.edu.cn/shuidian' // code
+// const CODE_BASE_URL = 'https://chtech.ncjti.edu.cn/shuidian' // code
+const CODE_BASE_URL = 'https://jtishfw.ncjti.edu.cn/jxch-smartmp/HotWaters' // code
 const AIR_BASE_URL = 'https://chtech.ncjti.edu.cn/air-conditioner-control' // air
 const AIR_BASE_URL = 'https://chtech.ncjti.edu.cn/air-conditioner-control' // air
 const IP_BASE_URL = 'https://pv.sohu.com/cityjson' // ip
 const IP_BASE_URL = 'https://pv.sohu.com/cityjson' // ip
 
 

BIN
static/images/qr.jpg