Procházet zdrojové kódy

说明:水电支付等都本地测试完成

程志平 před 4 roky
rodič
revize
e9185a18c0
5 změnil soubory, kde provedl 97 přidání a 45 odebrání
  1. 35 20
      pages/jiaofei/jiaofei.vue
  2. 0 1
      pages/recharge/recharge.vue
  3. 59 21
      pages/show/show.vue
  4. 2 2
      static/api.js
  5. 1 1
      store/index.js

+ 35 - 20
pages/jiaofei/jiaofei.vue

@@ -70,17 +70,11 @@
 				add_class1: '',
 				inputMoney: '', //手动输入增加金额
 				addMoney: 0, //选择充值金额
-				userinfo: {}, //用户信息
-				order_id: '', // 订单号
-				card_number: '', //用户卡号
-				dom: '', //房间号
 				campus: '', //校区
-				access_token: '',
 				sub_appid: '', //商户号
-				pay_info: '',
 				xiaofei_items: '', // 消费记录
 				ceshi: 'code',
-				dorm_number: '',
+				dorm_number: '', //房间号
 				compus: '',
 				test: this.$store.state.test
 			}
@@ -89,7 +83,7 @@
 			// 初始化参数
 			this.$store.state.building.roomSelect = '';
 			this.$store.state.building.add_class = 0;
-			this.$store.state.building.dom = '';
+			this.$store.state.building.dorm_number = '';
 
 			this.getCode()
 		},
@@ -98,7 +92,7 @@
 				// 如果是选择宿舍号返回
 				this.roomSelect = this.$store.state.building.roomSelect;
 				this.add_class = this.$store.state.building.add_class;
-				this.dom = this.$store.state.building.dom;
+				this.dorm_number = this.$store.state.building.dorm_number;
 
 				if (this.roomSelect != '') {
 					this.getDianLiang()
@@ -112,13 +106,14 @@
 			getCode(param) {
 				uni.login({
 					success: (res) => {
-						console.log('jiaofei', res);
+						// console.log('获得code', res);
 						if (res.code) {
 							this.code = res.code
 							// 请求服务器,获得openid
-							if (param == 'comfirm')
-								this.jsapi()
-							else
+							if (param == 'comfirm') {
+								// 获取IP
+								this.getIP()
+							} else
 								this.getOpenId()
 						} else {
 							uni.showToast({
@@ -130,6 +125,26 @@
 				})
 			},
 			/**
+			 * 获取IP
+			 */
+			async getIP() {
+				const res = await this.$myRequest({
+					host: 'ip',
+					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()
+				}
+			},
+			/**
 			 * 请求服务器,获得openid
 			 */
 			async getOpenId() {
@@ -145,10 +160,9 @@
 					}
 				})
 
-				// console.log(res);
+				// console.log('获得openid', res);
 				if (res.data.mess == '返回成功') {
 					this.$store.state.stu_number = res.data.info[0].stu_number
-					this.amount = res.data.info[0].balance
 					// 宿舍号
 					this.dorm_number = res.data.info[0].build + res.data.info[0].dom
 					// 校区
@@ -184,7 +198,7 @@
 					}
 				})
 
-				// console.log(res);
+				// console.log('取得电费额度', res);
 				if (res.data.mess == '0') {
 					setTimeout(() => {
 						this.remainElec = res.data.amount.toFixed(2)
@@ -294,18 +308,19 @@
 			async jsapi() {
 				const res = await this.$myRequest({
 					host: this.ceshi,
-					url: '/HotWaters/wpPay.action',
+					url: '/HotWaters/elPay.action',
 					method: 'POST',
 					header: {
 						'content-type': 'application/x-www-form-urlencoded'
 					},
 					data: {
 						code: this.code,
-						num: this.amount,
+						num: this.addMoney,
 						ip: this.IP
 					}
 				})
-				console.log(res);
+
+				// console.log(res);
 				if (res.data.pay == 'error') {
 					uni.showToast({
 						title: '未获得支付参数',
@@ -337,7 +352,7 @@
 							}
 						},
 						complete: (res) => {
-							console.log(res);
+							// console.log(res);
 						}
 					});
 				}

+ 0 - 1
pages/recharge/recharge.vue

@@ -221,7 +221,6 @@
 							}
 						}
 					})
-
 					return
 				}
 				// 生产环境

+ 59 - 21
pages/show/show.vue

@@ -44,7 +44,6 @@
 </template>
 
 <script>
-	// import data from '../../static/test_xiaofei.js'
 	export default {
 		data() {
 			return {
@@ -61,40 +60,71 @@
 				endDate: this.$getDate('end_date'),
 				all_data: '', //所有数据
 				list: [], //消费列表
-				card_number: 0, //用户卡号
+				code: '',
+				ceshi: 'code',
+				stu_number: 0, //用户卡号
 			}
 		},
-		onLoad(options) {
-			// console.log(this.chartData.series[0].data)
+		onLoad() {
+			// 获取学号
+			this.stu_number = this.$store.state.stu_number
 
-			// this.list = this.all_data.data[0].xiaofei;
-			// this.name = this.all_data.data[0].xiaofei.name;
-			// console.log(this.date)
-			this.card_number = options.card_number
-			// console.log(this.card_number)
-
-			this.get_data()
+			this.get_xiaofeijilu()
+			
+			this.get_chongzhijilu()
 		},
 		methods: {
+			/**
+			 * 获取选择日期
+			 * @param {Object} e
+			 */
 			bindDateChange: function(e) {
 				this.date = e.detail.value
+				
+				this.get_chongzhijilu()
 			},
-			async get_data() {
-				//http://ecu9ys.natappfree.cc/HotWaters/buildgetMonthBill.action
+			/**
+			 * 获取充值记录
+			 */
+			async get_chongzhijilu() {
+				console.log(this.$store.state.stu_number);
 				const res = await this.$myRequest({
-					host: 'ceshi',
-					url: 'http://ecu9ys.natappfree.cc/HotWaters/buildgetMonthBill.action',
+					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'
+					});
+				}
+				
+				// this.list = this.all_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
-						// 'roomSelect': '墨轩湖校区1101'
 					}
 				})
 
-				// console.log(res.data);
+				console.log(res);
 				let tmparr_date_time = []
 				let tmparr_use_elec = []
 				for (var i = 0; i < res.data.date_time.length; i++) {
@@ -103,11 +133,19 @@
 				for (var i = 0; i < res.data.use_elc.length; i++) {
 					tmparr_use_elec.push(res.data.use_elc[i])
 				}
-
+				
+				let chrt_data = {
+					categories: [],
+					series: [{
+						data: [],
+					}],
+				}
+				chrt_data.categories = tmparr_date_time
+				chrt_data.series[0].data = tmparr_use_elec
+				console.log(chrt_data);
 				setTimeout(() => {
-					this.chartData.categories = tmparr_date_time;
-					this.chartData.series[0].data = tmparr_use_elec;
-				}, 300)
+					this.chartData = chrt_data;
+				}, 30)
 			}
 		}
 	}

+ 2 - 2
static/api.js

@@ -1,6 +1,6 @@
 const WEXIN_BASE_URL = 'https://api.mch.weixin.qq.com' // wexin
-// const CODE_BASE_URL = 'https://developdomain.chuanghai-tech.com' // code
-const CODE_BASE_URL = 'http://grzpqy.natappfree.cc' // 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
 
 const myRequest = (options) => {

+ 1 - 1
store/index.js

@@ -12,7 +12,7 @@ const store = new Vuex.Store({
 		building: {
 			roomSelect: '',
 			add_class: 0,
-			dom: ''
+			dorm_number: ''
 		},
 		stu_number: '',
 		reshui_amount: 0.00.toFixed(2)