Browse Source

说明:开发阶段测试完成,进入集中测试阶段

程志平 4 years ago
parent
commit
e5c35264ac
8 changed files with 209 additions and 150 deletions
  1. 31 12
      pages/index/index.vue
  2. 76 60
      pages/jiaofei/jiaofei.vue
  3. 6 0
      pages/recharge/recharge.vue
  4. 26 29
      pages/reshui/reshui.vue
  5. 1 1
      pages/show/show.css
  6. 68 46
      pages/show/show.vue
  7. 1 0
      static/api.js
  8. 0 2
      static/openMidas.js

+ 31 - 12
pages/index/index.vue

@@ -32,18 +32,15 @@
 			return {
 				code: '',
 				showPop: false, //弹窗
-				// stu_number: '20210210140101',
-				// id_card: '88888888',
 				stu_number: '',
 				id_card: '',
-				ceshi: 'code'
+				ceshi: 'code',
+				huanjing: '部署环境' // 部署环境是key,用来获取环境
 			}
 		},
 		onLoad() {
 			// 是否是测试环境,查询数据接口中参数的值决定,方便以后测试
-			
-			
-			this.getCode()
+			this.isTestEnvironment()
 		},
 		methods: {
 			/**
@@ -52,17 +49,33 @@
 			async isTestEnvironment() {
 				const res = await this.$myRequest({
 					host: this.ceshi,
-					url: '/',
+					url: '/HotWaters/conEnvi.action',
 					method: 'POST',
 					header: {
 						'content-type': 'application/x-www-form-urlencoded'
+					},
+					data: {
+						name: this.huanjing
 					}
 				})
-			
-				// console.log(res.data.mess);
-				// if (res.data.mess == '绑定成功') {
-				// 	this.$store.state.test = res.data.test
-				// }
+
+				// console.log(res);
+				if (res.data.mess == '返回成功') {
+					// 0 测试环境, 1 部署环境
+					if (res.data.data[0].value == 0) {
+						this.$store.state.test = true
+					} else {
+						this.$store.state.test = false
+					}
+				} else {
+					uni.showToast({
+						title: res.data.mess,
+						icon: 'success'
+					});
+				}
+
+				// 获取code
+				this.getCode()
 			},
 			/**
 			 * 弹窗
@@ -107,6 +120,12 @@
 			 * 请求服务器,获得openid
 			 */
 			async getOpenId(code) {
+				if (this.stu_number == '' || this.id_card == '') {
+					uni.showToast({
+						title: '学号或身份证号为空'
+					});
+					return
+				}
 				const res = await this.$myRequest({
 					host: this.ceshi,
 					url: '/HotWaters/wpopenid.action',

+ 76 - 60
pages/jiaofei/jiaofei.vue

@@ -71,10 +71,12 @@
 				inputMoney: '', //手动输入增加金额
 				addMoney: 0, //选择充值金额
 				sub_appid: '', //商户号
+				code: '',
+				IP: '',
 				xiaofei_items: '', // 消费记录
-				ceshi: 'code',
 				dorm_number: '', //栋宿舍号
 				compus: '', //校区
+				ceshi: 'code',
 				test: this.$store.state.test
 			}
 		},
@@ -83,7 +85,7 @@
 			this.$store.state.building.roomSelect = '';
 			this.$store.state.building.add_class = 0;
 			this.$store.state.building.dorm_number = '';
-			
+
 			// 获得code
 			this.getCode()
 		},
@@ -93,7 +95,7 @@
 				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()
@@ -134,13 +136,13 @@
 					url: '/',
 					method: 'POST'
 				})
-			
+
 				if (res) {
 					// 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()
 				}
@@ -149,39 +151,46 @@
 			 * 请求服务器,获得openid
 			 */
 			async getOpenId() {
-				const res = await this.$myRequest({
-					host: this.ceshi,
-					url: '/HotWaters/wpget_stu.action',
-					method: 'POST',
-					header: {
-						'content-type': 'application/x-www-form-urlencoded'
-					},
-					data: {
-						code: this.code
-					}
-				})
+				if (this.code != '') {
+					const res = await this.$myRequest({
+						host: this.ceshi,
+						url: '/HotWaters/wpget_stu.action',
+						method: 'POST',
+						header: {
+							'content-type': 'application/x-www-form-urlencoded'
+						},
+						data: {
+							code: this.code
+						}
+					})
 
-				// console.log('获得openid', res);
-				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.compus = res.data.info[0].campus
-					// 填充校区宿舍号 
-					this.roomSelect = this.compus + this.dorm_number.split('栋')[1]
-					// 存储选择
-					this.$store.state.building.roomSelect = this.roomSelect
-					// 样式
-					this.add_class = 1
-					
-					// 请求选定的月份消费记录
-					this.getDianLiang()
-					
-				} else if (res.data.mess == '未查询到用户信息') {
-					uni.redirectTo({
-						url: '../index/index'
+					// console.log('获得openid', res);
+					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.compus = res.data.info[0].campus
+						// 填充校区宿舍号 
+						this.roomSelect = this.compus + this.dorm_number.split('栋')[1]
+						// 存储选择
+						this.$store.state.building.roomSelect = this.roomSelect
+						// 样式
+						this.add_class = 1
+
+						// 请求选定的月份消费记录
+						this.getDianLiang()
+
+					} else if (res.data.mess == '未查询到用户信息') {
+						uni.redirectTo({
+							url: '../index/index'
+						});
+					}
+				} else {
+					uni.showToast({
+						title: 'code为空!',
+						icon: 'success'
 					});
 				}
 			},
@@ -189,31 +198,32 @@
 			 * 取得电费额度
 			 */
 			async getDianLiang() {
-				let res;
-				res = await this.$myRequest({
-					host: 'code',
-					url: '/HotWaters/buildoverElec.action',
-					method: 'POST',
-					header: {
-						'content-type': 'application/x-www-form-urlencoded'
-					},
-					data: {
-						'roomSelect': this.roomSelect
-					}
-				})
+				if (this.roomSelect != '') {
+					const res = await this.$myRequest({
+						host: 'code',
+						url: '/HotWaters/buildoverElec.action',
+						method: 'POST',
+						header: {
+							'content-type': 'application/x-www-form-urlencoded'
+						},
+						data: {
+							'roomSelect': this.roomSelect
+						}
+					})
 
-				// console.log('取得电费额度', res);
-				if (res.data.mess == '0') {
-					setTimeout(() => {
-						this.remainElec = res.data.amount.toFixed(2)
-					}, 30);
+					// console.log('取得电费额度', res);
+					if (res.data.mess == '0') {
+						setTimeout(() => {
+							this.remainElec = res.data.amount.toFixed(2)
+						}, 30);
+					} else {
+						this.remainElec = 0.00.toFixed(2)
+					}
 				} else {
-					this.remainElec = 0.00.toFixed(2)
-					// uni.showToast({
-					// 	// 未获取到户号
-					// 	title: res.data.mess,
-					// 	duration: 2000
-					// })
+					uni.showToast({
+						title: '宿舍号为空',
+						icon: 'success'
+					});
 				}
 			},
 
@@ -310,6 +320,12 @@
 			 * 请求服务器,获取支付参数,并支付
 			 */
 			async jsapi() {
+				if (this.code == '' || this.addMoney == '' || this.IP == '') {
+					uni.showToast({
+						title: 'code、充值金额或IP为空'
+					});
+					return
+				}
 				const res = await this.$myRequest({
 					host: this.ceshi,
 					url: '/HotWaters/elPay.action',

+ 6 - 0
pages/recharge/recharge.vue

@@ -93,6 +93,12 @@
 			 * 请求服务器,获取支付参数,并支付
 			 */
 			async jsapi() {
+				if (this.code == '' || this.amount == '' || this.IP == '') {
+					uni.showToast({
+						title: 'code、充值金额 或 IP为空'
+					});
+					return
+				}
 				const res = await this.$myRequest({
 					host: this.ceshi,
 					url: '/HotWaters/wpPay.action',

+ 26 - 29
pages/reshui/reshui.vue

@@ -128,10 +128,10 @@
 					title: this.$store.state.payInfo.resultMsg,
 					icon: 'success'
 				})
-				
+
 				this.$store.state.payInfo.resultMsg = ''
 				this.$store.state.payInfo.from = ''
-				
+
 				// this.amount = this.$store.state.reshui_amount + this.amount
 				// 重新调用一次,刷新金额
 				this.getCode()
@@ -162,6 +162,13 @@
 			 * 请求服务器,获得openid
 			 */
 			async getOpenId() {
+				if (this.code == '') {
+					uni.showToast({
+						title: 'code未获取到!',
+						icon: 'success'
+					});
+					return
+				}
 				const res = await this.$myRequest({
 					host: this.ceshi,
 					url: '/HotWaters/wpget_stu.action',
@@ -187,10 +194,10 @@
 					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 if (res.data.mess == '未查询到用户信息') {
 					uni.redirectTo({
 						url: '../index/index'
@@ -276,10 +283,10 @@
 							success: (res) => {
 								if (res.confirm) {
 									this.isChecked = true
-									
+
 									// 开始连接匹配的蓝牙设备
 									// setTimeout(async () => {
-										// 请求获取设备启动码
+									// 请求获取设备启动码
 									this.request_device_start_code()
 									// }, 1000)
 								} else if (res.cancel) {
@@ -678,7 +685,6 @@
 					// 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
 					characteristicId: this.characteristicIdForNotity,
 					success: (res) => {
-
 						this.process_control(2)
 						this.isScan = false
 						// console.log('通知启用(notifyBLECharacteristicValueChange)',res);
@@ -706,28 +712,6 @@
 				})
 			},
 
-			// /**
-			//  * 请求设备信息
-			//  */
-			// async request_device_info() {
-			// 	const res = await this.$myRequest({
-			// 		url: '',
-			// 		data: {
-
-			// 		}
-			// 	})
-
-			// 	console.log('', res)
-			// },
-
-			// /**
-			//  * 显示设备启动授权金额
-			//  */
-			// display_device_startup_amount() {
-			// 	// 待开发
-
-			// },
-
 			/**
 			 * 999999999999999999999999999999999
 			 * 监听低功耗蓝牙设备的特征值变化
@@ -988,6 +972,12 @@
 			 * 请求获取设备启动码
 			 */
 			async request_device_start_code() {
+				if (this.byte35 == '' || this.$store.state.stu_number == '') {
+					uni.showToast({
+						title: '字节码或学号为空!'
+					});
+					return
+				}
 				const res = await this.$myRequest({
 					host: 'code',
 					url: '/HotWaters/wpstart.action',
@@ -1014,6 +1004,13 @@
 			 * 请求结算
 			 */
 			async request_pay() {
+				if (this.byte35.substring(2) == '') {
+					uni.showToast({
+						title: '字节码为空!',
+						icon: 'success'
+					});
+					return
+				}
 				const res = await this.$myRequest({
 					host: 'code',
 					url: '/HotWaters/wpconsume.action',

+ 1 - 1
pages/show/show.css

@@ -122,7 +122,7 @@ page {
 
 .item-list-left {
 	display: flex;
-	justify-content: space-between;
+	justify-content: space-around;
 	width: 425upx;
 }
 

+ 68 - 46
pages/show/show.vue

@@ -31,10 +31,10 @@
 				<view class="uni-list">
 					<view class="item-list" v-for="(item, i) in list" :key="i">
 						<view class="item-list-left">
-							<text class="item-list-txt">{{item.name}}</text>
-							<text class="item-list-txt">{{item.tdate}} {{item.time}}</text>
+							<text class="item-list-txt">{{item.user_name}}</text>
+							<text class="item-list-txt">{{item.re_time}}</text>
 						</view>
-						<text class="item-list-txt show-money">{{item.money}}</text>
+						<text class="item-list-txt show-money">{{item.account}}</text>
 					</view>
 				</view>
 
@@ -88,59 +88,81 @@
 			 */
 			async get_chongzhijilu() {
 				// console.log(this.$store.state.stu_number);
-				const res = await this.$myRequest({
-					host: this.ceshi,
-					url: '/HotWaters/elqueyRecordEle.action',
-					method: 'POST',
-					header: {
-						'content-type': 'application/x-www-form-urlencoded'
-					},
-					data: {
-						'stu_number': this.$store.state.stu_number,
-						're_time': this.date
+				if (this.$store.state.stu_number != '') {
+					const res = await this.$myRequest({
+						host: this.ceshi,
+						url: '/HotWaters/elqueyRecordEle.action',
+						method: 'POST',
+						header: {
+							'content-type': 'application/x-www-form-urlencoded'
+						},
+						data: {
+							'stu_number': this.$store.state.stu_number,
+							're_time': this.date
+						}
+					})
+					
+					// console.log(res);
+					if (res.data.mess == '未查到记录') {
+						uni.showToast({
+							title: '该月无缴费记录',
+							icon: 'success'
+						});
+					} else {
+						// 充值绑定显示到界面
+						for (var i = 0; i < res.data.data.length; i++) {
+							this.list.push(res.data.data[i])
+						}
 					}
-				})
-
-				console.log(res);
-				if (res.data.mess == '未查到记录') {
+				} else {
 					uni.showToast({
-						title: '该月无缴费记录',
+						title: '学号为空',
 						icon: 'success'
 					});
-				} else {
-					// 充值绑定显示到界面
-					this.list = res.data.data[0].xiaofei
 				}
 			},
+			/**
+			 * 缴费记录
+			 */
 			async get_xiaofeijilu() {
-				const res = await this.$myRequest({
-					host: this.ceshi,
-					url: '/HotWaters/buildgetMonthBill.action',
-					method: 'POST',
-					header: {
-						'content-type': 'application/x-www-form-urlencoded'
-					},
-					data: {
-						'roomSelect': this.$store.state.building.roomSelect
+				if (this.$store.state.building.roomSelect != '') {
+					const res = await this.$myRequest({
+						host: this.ceshi,
+						url: '/HotWaters/buildgetMonthBill.action',
+						method: 'POST',
+						header: {
+							'content-type': 'application/x-www-form-urlencoded'
+						},
+						data: {
+							'roomSelect': this.$store.state.building.roomSelect
+						}
+					})
+
+					// console.log(res);
+					if (res.data.mess == '未查询到数据') {
+						return
+					}
+					let chrt_data = {
+						categories: [],
+						series: [{
+							data: [],
+						}],
+					}
+					for (var i = 0; i < res.data.date_time.length; i++) {
+						chrt_data.categories.push(res.data.date_time[i])
+						chrt_data.series[0].data.push(res.data.use_elc[i])
 					}
-				})
 
-				// console.log(res);
-				let chrt_data = {
-					categories: [],
-					series: [{
-						data: [],
-					}],
-				}
-				for (var i = 0; i < res.data.date_time.length; i++) {
-					chrt_data.categories.push(res.data.date_time[i])
-					chrt_data.series[0].data.push(res.data.use_elc[i])
+					// console.log(chrt_data);
+					setTimeout(() => {
+						this.chartData = chrt_data;
+					}, 1000)
+				} else {
+					uni.showToast({
+						title: '宿舍号为空',
+						icon: 'success'
+					});
 				}
-
-				// console.log(chrt_data);
-				setTimeout(() => {
-					this.chartData = chrt_data;
-				}, 1000)
 			}
 		}
 	}

+ 1 - 0
static/api.js

@@ -1,4 +1,5 @@
 const WEXIN_BASE_URL = 'https://api.mch.weixin.qq.com' // wexin
+// const CODE_BASE_URL = 'https://jtishfw.ncjti.edu.cn/jxch-smartmp' // code
 const CODE_BASE_URL = 'https://developdomain.chuanghai-tech.com' // code
 // const CODE_BASE_URL = 'http://grzpqy.natappfree.cc' // code
 const IP_BASE_URL = 'http://pv.sohu.com/cityjson?ie=utf-8' // ip

File diff suppressed because it is too large
+ 0 - 2
static/openMidas.js