Browse Source

说明:热水充值完成,部分共用js函数抽取到api.js中,然后统一暴露给全局。

程志平 5 years ago
parent
commit
f6f42e265c
10 changed files with 386 additions and 183 deletions
  1. 1 1
      App.vue
  2. 5 1
      main.js
  3. 67 0
      pages/index/index.vue
  4. 122 31
      pages/jiaofei/jiaofei.vue
  5. 64 62
      pages/recharge/recharge.vue
  6. 45 43
      pages/reshui/reshui.vue
  7. 2 1
      pages/select/select.vue
  8. 16 5
      pages/show/show.css
  9. 9 36
      pages/show/show.vue
  10. 55 3
      static/api.js

+ 1 - 1
App.vue

@@ -11,7 +11,7 @@
 		},
 		},
 		globalData: {
 		globalData: {
 			primaryColor: '#1296db',
 			primaryColor: '#1296db',
-			test: true
+			test: true  // 控制是否是测试环境
 		}
 		}
 	}
 	}
 </script>
 </script>

+ 5 - 1
main.js

@@ -2,11 +2,15 @@ import Vue from 'vue'
 import App from './App'
 import App from './App'
 import {
 import {
 	CODE_BASE_URL,
 	CODE_BASE_URL,
-	myRequest
+	myRequest,
+	getDate,
+	getOrderId
 } from './static/api.js'
 } from './static/api.js'
 
 
 Vue.prototype.$myRequest = myRequest
 Vue.prototype.$myRequest = myRequest
 Vue.prototype.$code_base_url = CODE_BASE_URL
 Vue.prototype.$code_base_url = CODE_BASE_URL
+Vue.prototype.$getDate = getDate
+Vue.prototype.$getOrderId = getOrderId
 
 
 // import {common} from './static/common.js'
 // import {common} from './static/common.js'
 // Vue.prototype.$request = common.axios
 // Vue.prototype.$request = common.axios

+ 67 - 0
pages/index/index.vue

@@ -201,6 +201,9 @@
 							duration: 800,
 							duration: 800,
 							success: (res) => {
 							success: (res) => {
 								this.my_display = true
 								this.my_display = true
+								
+								// 查询本系统后台是否存在该用户信息
+								this.select_user_info()
 							}
 							}
 						})
 						})
 					} catch (e) {
 					} catch (e) {
@@ -213,6 +216,70 @@
 					});
 					});
 				}
 				}
 			},
 			},
+			
+			/**
+			 * 查询用户信息
+			 */
+			async select_user_info() {
+				const res = await this.$myRequest({
+					host: 'code',
+					url: '/HotWater/userget_stu.action',
+					method: 'POST',
+					header: {
+						'content-type': 'application/x-www-form-urlencoded'
+					},
+					data: {
+						card_number: this.userinfo.card_number
+					}
+				});
+			
+				// console.log(res, 'select_user_info');
+				if (res.data.info) {
+					let cnumber = this.userinfo.card_number
+			
+					if (cnumber == null || cnumber == undefined || cnumber == '') {
+						// 之前未绑定用户信息,现在去绑定用户信息
+						this.send_save_user_info()
+					}
+				} else {
+					uni.showToast({
+						icon: 'success',
+						title: '获取用户信息失败'
+					})
+				}
+			},
+			
+			/**
+			 * 绑定用户信息
+			 */
+			async send_save_user_info() {
+				const res = await this.$myRequest({
+					host: 'code',
+					url: '/HotWater/userstu_info.action',
+					method: 'POST',
+					header: {
+						'content-type': 'application/x-www-form-urlencoded'
+					},
+					data: {
+						user: JSON.stringify(this.userinfo)
+					}
+				});
+			
+				// console.log('send_save_user_info:', res)
+				let error = res.data.erro;
+				if (error == '未获取到数据!') {
+					uni.showToast({
+						title: '绑定用户失败',
+						duration: 2000
+					})
+				} else {
+					uni.showToast({
+						icon: 'success',
+						title: '绑定用户成功',
+						duration: 2000
+					})
+				}
+			},
 
 
 			/**
 			/**
 			 * 获取应用有效凭证
 			 * 获取应用有效凭证

+ 122 - 31
pages/jiaofei/jiaofei.vue

@@ -15,7 +15,7 @@
 				<image class="picker-item-logo-left" src="/static/image/elec.png"></image>
 				<image class="picker-item-logo-left" src="/static/image/elec.png"></image>
 			</view>
 			</view>
 			<view class="picker-item-label">剩余电量</view>
 			<view class="picker-item-label">剩余电量</view>
-			<view class="picker-item-content font-txt">{{remainElec}}度</view>
+			<view class="picker-item-content font-txt">{{remainElec}} 度</view>
 		</view>
 		</view>
 		<view class="show-item add-money">
 		<view class="show-item add-money">
 			<view class="add-money-show">
 			<view class="add-money-show">
@@ -65,7 +65,7 @@
 			return {
 			return {
 				index: 0,
 				index: 0,
 				roomSelect: '', //房间号
 				roomSelect: '', //房间号
-				remainElec: 80.1, //剩余电量
+				remainElec: 80.10.toFixed(2), //剩余电量
 				add_class: '', //增加class属性
 				add_class: '', //增加class属性
 				add_class1: '',
 				add_class1: '',
 				inputMoney: '', //手动输入增加金额
 				inputMoney: '', //手动输入增加金额
@@ -78,6 +78,7 @@
 				access_token: '',
 				access_token: '',
 				sub_appid: '', //商户号
 				sub_appid: '', //商户号
 				pay_info: '',
 				pay_info: '',
+				xiaofei_items: '', // 消费记录
 				test: getApp().globalData.test
 				test: getApp().globalData.test
 			}
 			}
 		},
 		},
@@ -91,6 +92,9 @@
 				this.roomSelect = item.roomSelect;
 				this.roomSelect = item.roomSelect;
 				this.add_class = 1;
 				this.add_class = 1;
 				this.dom = item.dom;
 				this.dom = item.dom;
+				
+				// 请求选定的月份消费记录
+				this.request_consumption_records()
 			}
 			}
 			try {
 			try {
 				// 获取存储的用户数据
 				// 获取存储的用户数据
@@ -108,7 +112,7 @@
 					// 更新存储的用户信息
 					// 更新存储的用户信息
 					uni.setStorageSync('userinfo_storage_key', this.userinfo)
 					uni.setStorageSync('userinfo_storage_key', this.userinfo)
 					this.roomSelect = this.campus + this.dom
 					this.roomSelect = this.campus + this.dom
-				} else if (value != '') {
+				} else if (JSON.stringify(value) !== '{}') {
 					this.userinfo = value;
 					this.userinfo = value;
 				}
 				}
 				this.campus = this.userinfo.campus
 				this.campus = this.userinfo.campus
@@ -123,7 +127,7 @@
 			//将缓存中的卡号进行获取
 			//将缓存中的卡号进行获取
 			this.card_number = this.userinfo.card_number
 			this.card_number = this.userinfo.card_number
 
 
-			// 查询用户信息
+			// 获取应用有效凭证
 			this.get_valid_credentials()
 			this.get_valid_credentials()
 		},
 		},
 
 
@@ -159,6 +163,119 @@
 						duration: 2000
 						duration: 2000
 					})
 					})
 				}
 				}
+				
+				// 查询用户信息
+				this.select_user_info()
+			},
+			
+			/**
+			 * 查询用户信息
+			 */
+			async select_user_info() {
+				const res = await this.$myRequest({
+					host: 'code',
+					url: '/HotWater/userget_stu.action',
+					method: 'POST',
+					header: {
+						'content-type': 'application/x-www-form-urlencoded'
+					},
+					data: {
+						card_number: this.userinfo.card_number
+					}
+				});
+			
+				// console.log(res, 'select_user_info');
+				if (res.data.info) {
+					let cnumber = this.userinfo.card_number
+			
+					if (cnumber == null || cnumber == undefined || cnumber == '') {
+						// 之前未绑定用户信息,现在去绑定用户信息
+						this.send_save_user_info()
+					}
+				} else {
+					uni.showToast({
+						icon: 'success',
+						title: '获取用户信息失败'
+					})
+				}
+			},
+			
+			/**
+			 * 请求选定的月份消费记录
+			 */
+			async request_consumption_records() {
+				if (this.card_number != '') {
+					this.xiaofei_items = []
+					const res = await this.$myRequest({
+						host: 'code',
+						url: '/HotWater/wxpayqueryConsume.action',
+						method: 'POST',
+						header: {
+							'content-type': 'application/x-www-form-urlencoded'
+						},
+						data: {
+							card_number: this.card_number,
+							begin_time: this.date
+						}
+					});
+			
+					// console.log(res.data.mess, 'request_consumption_records');
+					if (typeof(res.data.mess) != 'undefined') {
+						let items = res.data.mess
+						// 按时间倒序排列
+						// items.sort((a, b) => {
+						// 	return a.begin_time < b.begin_time ? 1 : -1;
+						// })
+						for (var i = 0; i < items.length; i++) {
+							// 过滤掉为0的记录,只显示消费大于0的记录
+							// if (items[i].use_amount > 0.00) {
+							this.xiaofei_items.push(items[i])
+							// }
+						}
+					} else {
+						uni.showToast({
+							icon: 'success',
+							title: '该月无消费记录'
+						})
+					}
+				} else {
+					uni.showToast({
+						icon: 'success',
+						title: '用户卡号为空'
+					})
+				}
+			},
+			
+			/**
+			 * 绑定用户信息
+			 */
+			async send_save_user_info() {
+				const res = await this.$myRequest({
+					host: 'code',
+					url: '/HotWater/userstu_info.action',
+					method: 'POST',
+					header: {
+						'content-type': 'application/x-www-form-urlencoded'
+					},
+					data: {
+						user: JSON.stringify(this.userinfo)
+					}
+				});
+			
+				// console.log('send_save_user_info:', res)
+				let error = res.data.erro;
+				if (error == '未获取到数据!') {
+					uni.showToast({
+						title: '绑定用户失败',
+						duration: 2000
+					})
+				} else {
+					uni.showToast({
+						icon: 'success',
+						title: '绑定用户成功',
+						duration: 2000
+					})
+				}
 			},
 			},
 
 
 			//跳转到选择页面
 			//跳转到选择页面
@@ -259,7 +376,7 @@
 						'access_token': this.access_token,
 						'access_token': this.access_token,
 						'sub_appid': this.sub_appid,
 						'sub_appid': this.sub_appid,
 						'user_id': this.card_number,
 						'user_id': this.card_number,
-						"order_id": this.order_id = get_order_id('dianfei'),
+						"order_id": this.order_id = this.$getOrderId('dianfei'),
 						"amount": this.addMoney * 100,
 						"amount": this.addMoney * 100,
 						'order_type': 1,
 						'order_type': 1,
 						'callback_url': ''
 						'callback_url': ''
@@ -359,32 +476,6 @@
 			}
 			}
 		},
 		},
 	}
 	}
-
-	function get_order_id(head) {
-		const date = new Date()
-	
-		let year = date.getFullYear()
-		let month = date.getMonth() + 1
-		let day = date.getDate()
-		let hour = date.getHours()
-		let minute = date.getMinutes()
-		let second = date.getSeconds()
-		let millisecond = date.getMilliseconds()
-		let len_mill = millisecond.toString().length
-	
-		month = month > 9 ? month : '0' + month
-		day = day > 9 ? day : '0' + day
-		second = second > 9 ? second : '0' + second
-		if (len_mill == 1) {
-			millisecond = (Math.floor(Math.random () * 9000) + 10000).toString() + millisecond
-		} else if (len_mill == 2) {
-			millisecond = (Math.floor(Math.random () * 900) + 1000).toString() + millisecond
-		} else if (len_mill == 3) {
-			millisecond = (Math.floor(Math.random () * 900) + 100).toString() + millisecond
-		}
-	
-		return `${head}${year}${month}${day}${hour}${minute}${second}${millisecond}`
-	}
 </script>
 </script>
 
 
 <style>
 <style>

+ 64 - 62
pages/recharge/recharge.vue

@@ -35,7 +35,7 @@
 	export default {
 	export default {
 		data() {
 		data() {
 			return {
 			return {
-				amount: 10.0.toFixed(0), // 金额
+				amount: 10, // 金额
 				phone_number: '13645689854', // 客户热线电话
 				phone_number: '13645689854', // 客户热线电话
 				userinfo: '', // 用户信息
 				userinfo: '', // 用户信息
 				order_id: '', // 订单号
 				order_id: '', // 订单号
@@ -44,7 +44,7 @@
 				sub_appid: '',
 				sub_appid: '',
 				card_number: '',
 				card_number: '',
 				user_name: '',
 				user_name: '',
-				test: getApp().globalData.test
+				test: getApp().globalData.test // 获取全局变量,控制是否是测试环境
 			};
 			};
 		},
 		},
 		onLoad(options) {
 		onLoad(options) {
@@ -66,7 +66,7 @@
 					this.userinfo = JSON.parse(item)
 					this.userinfo = JSON.parse(item)
 					// 更新存储的用户信息
 					// 更新存储的用户信息
 					uni.setStorageSync('userinfo_storage_key', this.userinfo)
 					uni.setStorageSync('userinfo_storage_key', this.userinfo)
-				} else if (value != '') {
+				} else if (JSON.stringify(value) !== '{}') {
 					// 处理JSON字符串
 					// 处理JSON字符串
 					// this.userinfo = value.replace(/"/g, "'");
 					// this.userinfo = value.replace(/"/g, "'");
 					this.userinfo = value;
 					this.userinfo = value;
@@ -75,6 +75,9 @@
 				console.log(e)
 				console.log(e)
 			}
 			}
 
 
+			if (this.test) //测试环境
+				this.amount = 0.01
+
 			this.sub_appid = this.userinfo.sub_appid
 			this.sub_appid = this.userinfo.sub_appid
 			this.card_number = this.userinfo.card_number
 			this.card_number = this.userinfo.card_number
 			this.user_name = this.userinfo.name
 			this.user_name = this.userinfo.name
@@ -127,10 +130,10 @@
 						'access_token': this.access_token,
 						'access_token': this.access_token,
 						'sub_appid': this.sub_appid,
 						'sub_appid': this.sub_appid,
 						'user_id': this.card_number,
 						'user_id': this.card_number,
-						'order_id': this.order_id = get_order_id('shuifei'),
+						'order_id': this.order_id = this.$getOrderId('shuifei'),
 						'amount': this.amount * 100,
 						'amount': this.amount * 100,
 						'order_type': 1,
 						'order_type': 1,
-						// 'callback_url': 'http://x3ys5i.natappfree.cc'
+						// 'callback_url': 'http://wvwviw.natappfree.cc/HotWaters/wxpayrecharge.action'
 						'callback_url': this.$code_base_url + '/HotWater/wxpayrecharge.action'
 						'callback_url': this.$code_base_url + '/HotWater/wxpayrecharge.action'
 					}
 					}
 				})
 				})
@@ -142,38 +145,65 @@
 			// 调起支付
 			// 调起支付
 			pay_amount() {
 			pay_amount() {
 				var OpenMidas = require("@/static/openMidas.js") // 引入小程序目录下的SDK文件
 				var OpenMidas = require("@/static/openMidas.js") // 引入小程序目录下的SDK文件
+				if (this.test) { // 是否是测试环境
+					// 设置支付配置
+					wx['OpenMidasConfig'] = {
+						apiCommonConf: {
+							version: "weixiao"
+						},
+						cgiDomain: {
+							test: "midas.weixiao.qq.com/api", // 私有化参数联系微卡客服进行获取
+						},
+						webDomain: "https://midas.weixiao.qq.com/h5", // 私有化参数联系微卡客服进行获取
+						sandboxWebDomain: "https://midas.weixiao.qq.com/h5" // 私有化参数联系微卡客服进行获取
+					}
 
 
-				// 设置支付配置
-				wx['OpenMidasConfig'] = {
-					apiCommonConf: {
-						version: "weixiao"
-					},
-					cgiDomain: {
-						test: "midas.weixiao.qq.com/api", // 私有化参数联系微卡客服进行获取
-					},
-					webDomain: "https://midas.weixiao.qq.com/h5", // 私有化参数联系微卡客服进行获取
-					sandboxWebDomain: "https://midas.weixiao.qq.com/h5" // 私有化参数联系微卡客服进行获取
-				}
-
-				var payInfo = this.pay_info; // 请求mppay接口返回的数据
-				// var appMetaData = "card_number=" + this.card_number + "&user_name=" + this.user_name + "&account=" + this
-				// 	.amount; // 自定义回调数据
+					var payInfo = this.pay_info; // 请求mppay接口返回的数据
+					// var appMetaData = "card_number=" + this.card_number + "&user_name=" + this.user_name + "&account=" + this
+					// 	.amount; // 自定义回调数据
+					OpenMidas.init("test");
+				} else {
+					// 设置支付配置
+					wx['OpenMidasConfig'] = {
+						apiCommonConf: {
+							version: "weixiao"
+						},
+						cgiDomain: {
+							release: "midas.weixiao.qq.com/api", // 私有化参数联系微卡客服进行获取
+						},
+						webDomain: "https://midas.weixiao.qq.com/h5", // 私有化参数联系微卡客服进行获取
+						sandboxWebDomain: "https://midas.weixiao.qq.com/h5" // 私有化参数联系微卡客服进行获取
+					}
 
 
-				OpenMidas.init("test");
+					var payInfo = this.pay_info; // 请求mppay接口返回的数据
+					// var appMetaData = "card_number=" + this.card_number + "&user_name=" + this.user_name + "&account=" + this
+					// 	.amount; // 自定义回调数据
+					OpenMidas.init("release");
+				}
 				OpenMidas.pay(
 				OpenMidas.pay(
 					payInfo,
 					payInfo,
 					// function(resultCode, innerCode, resultMsg, appMetaData) {
 					// function(resultCode, innerCode, resultMsg, appMetaData) {
 					function(resultCode, innerCode, resultMsg) {
 					function(resultCode, innerCode, resultMsg) {
-						console.log(resultCode); // 支付响应状态码
-						console.log(innerCode); // 支付响应内部错误码
-						console.log(resultMsg); // 支付响应说明
-						console.log(appMetaData); // 自定义回调数据
-
-						// todo:处理业务逻辑
-						uni.showToast({
-							title: resultMsg,
-							icon: 'success'
-						})
+						// console.log(resultCode); // 支付响应状态码
+						// console.log(innerCode); // 支付响应内部错误码
+						// console.log(resultMsg); // 支付响应说明
+						// console.log(appMetaData); // 自定义回调数据
+
+						if (resultCode == 0) {
+							let pay_info_storage_key = {}
+							pay_info_storage_key.resultCode = resultCode
+							pay_info_storage_key.resultMsg = resultMsg
+							// 保存用户充值成功
+							uni.setStorageSync('pay_info_storage_key', pay_info_storage_key)
+							uni.navigateBack({
+								delta: 1
+							})
+						} else {
+							uni.showToast({
+								title: '支付异常',
+								icon: 'success'
+							})
+						}
 					}
 					}
 					// },
 					// },
 					// appMetaData
 					// appMetaData
@@ -183,7 +213,7 @@
 			 * 输入充值金额
 			 * 输入充值金额
 			 */
 			 */
 			onInput(e) {
 			onInput(e) {
-				if (this.test) {
+				if (this.test) { // 测试环境
 					return
 					return
 				}
 				}
 
 
@@ -215,7 +245,7 @@
 			 * 输入框,失去焦点时
 			 * 输入框,失去焦点时
 			 */
 			 */
 			onBlur() {
 			onBlur() {
-				if (this.test) {
+				if (this.test) { // 测试环境
 					return
 					return
 				}
 				}
 				if (this.amount < 10) {
 				if (this.amount < 10) {
@@ -232,7 +262,7 @@
 			 * 调用接口实现充值功能
 			 * 调用接口实现充值功能
 			 */
 			 */
 			chongzhi() {
 			chongzhi() {
-				if (this.test) {
+				if (this.test) { // 测试环境
 					uni.showModal({
 					uni.showModal({
 						title: '提示',
 						title: '提示',
 						content: '您选择了充值:¥' + this.amount + ' 元',
 						content: '您选择了充值:¥' + this.amount + ' 元',
@@ -285,34 +315,6 @@
 			}
 			}
 		}
 		}
 	}
 	}
-	/**
-	 * 时间生成订单号
-	 */
-	function get_order_id(head) {
-		const date = new Date()
-
-		let year = date.getFullYear()
-		let month = date.getMonth() + 1
-		let day = date.getDate()
-		let hour = date.getHours()
-		let minute = date.getMinutes()
-		let second = date.getSeconds()
-		let millisecond = date.getMilliseconds()
-		let len_mill = millisecond.toString().length
-
-		month = month > 9 ? month : '0' + month
-		day = day > 9 ? day : '0' + day
-		second = second > 9 ? second : '0' + second
-		if (len_mill == 1) {
-			millisecond = (Math.floor(Math.random() * 9000) + 10000).toString() + millisecond
-		} else if (len_mill == 2) {
-			millisecond = (Math.floor(Math.random() * 900) + 1000).toString() + millisecond
-		} else if (len_mill == 3) {
-			millisecond = (Math.floor(Math.random() * 900) + 100).toString() + millisecond
-		}
-
-		return `${head}${year}${month}${day}${hour}${minute}${second}${millisecond}`
-	}
 </script>
 </script>
 
 
 <style lang="scss" scoped>
 <style lang="scss" scoped>

+ 45 - 43
pages/reshui/reshui.vue

@@ -76,11 +76,11 @@
 		data() {
 		data() {
 			return {
 			return {
 				colorPrimary: getApp().globalData.primaryColor,
 				colorPrimary: getApp().globalData.primaryColor,
-				date: getDate({
+				date: this.$getDate({
 					format: true
 					format: true
 				}),
 				}),
-				startDate: getDate('start_date'),
-				endDate: getDate('end_date'),
+				startDate: this.$getDate('start_date'),
+				endDate: this.$getDate('end_date'),
 				flag: true,
 				flag: true,
 				isUserClose: false, // 是否是用户自己关闭
 				isUserClose: false, // 是否是用户自己关闭
 				isChecked: false,
 				isChecked: false,
@@ -108,7 +108,6 @@
 				byte35_tmp: '', // 70 个字符 临时变量
 				byte35_tmp: '', // 70 个字符 临时变量
 				start_code: '',
 				start_code: '',
 				// start_code: '3459A8C660F1C284E41003E80000120000',
 				// start_code: '3459A8C660F1C284E41003E80000120000',
-				// order_no: '', // 收集结算的订单号
 				xiaofei_items: [],
 				xiaofei_items: [],
 				userinfo: '',
 				userinfo: '',
 				card_number: '',
 				card_number: '',
@@ -122,34 +121,60 @@
 			try {
 			try {
 				// 获取存储的用户数据
 				// 获取存储的用户数据
 				const value = uni.getStorageSync('userinfo_storage_key')
 				const value = uni.getStorageSync('userinfo_storage_key')
-				let item = decodeURIComponent(options.item)
-				// console.log(value)
-				// console.log(item)
-				if (item === '{}' && value == '') { // 如果没有用户信息,返回首页
-					uni.redirectTo({
-						url: '../index/index'
-					});
-					return;
-				}
+				if (typeof(options.item) != 'undefined') {
+					let item = decodeURIComponent(options.item)
+					// console.log(value)
+					// console.log(item)
+					if (item === '{}') { // 如果没有用户信息,返回首页
+						uni.redirectTo({
+							url: '../index/index'
+						});
+						return;
+					}
 
 
-				if (item != '') {
-					// 处理JSON字符串
-					// this.userinfo = item.replace(/"/g, "'");
-					this.userinfo = JSON.parse(item);
+					if (item != '') {
+						// 处理JSON字符串
+						// this.userinfo = item.replace(/"/g, "'");
+						this.userinfo = JSON.parse(item);
+					}
 				} else if (value != '') {
 				} else if (value != '') {
 					// 处理JSON字符串
 					// 处理JSON字符串
 					// this.userinfo = value.replace(/"/g, "'");
 					// this.userinfo = value.replace(/"/g, "'");
 					this.userinfo = value;
 					this.userinfo = value;
+				} else {
+					uni.showToast({
+						title: '未获得授权信息',
+						icon: 'success'
+					})
+
+					uni.redirectTo({
+						url: '../index/index'
+					});
 				}
 				}
 			} catch (e) {
 			} catch (e) {
 				console.log(e)
 				console.log(e)
 			}
 			}
 
 
-			this.card_number = this.userinfo.card_number; // 卡号
+			this.card_number = this.userinfo.card_number;  // 卡号
 
 
 			// 查询用户信息
 			// 查询用户信息
 			this.select_user_info()
 			this.select_user_info()
 		},
 		},
+		onShow() {
+			try {
+				const pay_info = uni.getStorageSync('pay_info_storage_key')
+				if (pay_info && pay_info.resultCode == 0) {
+					uni.showToast({
+						title: pay_info.resultMsg,
+						icon: 'success'
+					})
+					
+					uni.removeStorageSync('pay_info_storage_key')
+				}
+			} catch (e) {
+				console.log(e)
+			}
+		},
 		methods: {
 		methods: {
 			/**
 			/**
 			 * 选择消费年月
 			 * 选择消费年月
@@ -229,7 +254,6 @@
 						card_number: this.userinfo.card_number
 						card_number: this.userinfo.card_number
 					}
 					}
 				});
 				});
-
 				// console.log(res, 'select_user_info');
 				// console.log(res, 'select_user_info');
 				if (res.data.info) {
 				if (res.data.info) {
 					// 将JSON字符串转化为JSON对象,取余额
 					// 将JSON字符串转化为JSON对象,取余额
@@ -239,7 +263,7 @@
 					this.user_name = userinfo.user_name;
 					this.user_name = userinfo.user_name;
 					this.dorm_number = userinfo.dom // 宿舍号
 					this.dorm_number = userinfo.dom // 宿舍号
 					if (amount != 0) {
 					if (amount != 0) {
-						this.amount = amount.toFixed(2)
+						this.amount = amount
 					}
 					}
 
 
 					if (cnumber == null || cnumber == undefined || cnumber == '') {
 					if (cnumber == null || cnumber == undefined || cnumber == '') {
@@ -273,7 +297,7 @@
 					}
 					}
 				});
 				});
 
 
-				console.log('send_save_user_info:', res)
+				// console.log('send_save_user_info:', res)
 				let error = res.data.erro;
 				let error = res.data.erro;
 				if (error == '未获取到数据!') {
 				if (error == '未获取到数据!') {
 					uni.showToast({
 					uni.showToast({
@@ -1119,28 +1143,6 @@
 	function sixteen_to_ten(str) {
 	function sixteen_to_ten(str) {
 		return parseInt(str, 16);
 		return parseInt(str, 16);
 	}
 	}
-
-	/**
-	 * 时间计算
-	 */
-	function getDate(type) {
-		const date = new Date();
-
-		let year = date.getFullYear();
-		let month = date.getMonth() + 1;
-		// let day = date.getDate();
-
-		if (type === 'start_date') {
-			year = year - 4;
-		} else if (type === 'end_date') {
-			year = year;
-		}
-
-		month = month > 9 ? month : '0' + month;
-		// day = day > 9 ? day : '0' + day;
-
-		return `${year}-${month}`;
-	}
 </script>
 </script>
 
 
 <style scoped lang="scss">
 <style scoped lang="scss">

+ 2 - 1
pages/select/select.vue

@@ -91,6 +91,7 @@
 
 
 		onLoad(options) {
 		onLoad(options) {
 			// console.log(options)
 			// console.log(options)
+			// 拆分楼栋和宿舍号
 			var str = options.roomSelect;
 			var str = options.roomSelect;
 			var arr = new Array();
 			var arr = new Array();
 			var i = 0;
 			var i = 0;
@@ -114,7 +115,7 @@
 			// }
 			// }
 			this.requestAllData()
 			this.requestAllData()
 
 
-			this.nschool = this.allData.data.length
+			// this.nschool = this.allData.data.length
 			
 			
 			// 自动填充
 			// 自动填充
 			if (arr.length > 0) {
 			if (arr.length > 0) {

+ 16 - 5
pages/show/show.css

@@ -102,7 +102,7 @@ page {
 }
 }
 
 
 
 
-.uni-list{
+.uni-list {
 	margin: 39upx 30upx 0 30upx;
 	margin: 39upx 30upx 0 30upx;
 	display: flex;
 	display: flex;
 	flex-direction: column;
 	flex-direction: column;
@@ -116,11 +116,11 @@ page {
 	border-top: 2rpx #CCCCCC solid;
 	border-top: 2rpx #CCCCCC solid;
 }
 }
 
 
-.item-list:last-child{
+.item-list:last-child {
 	border-bottom: 2rpx #CCCCCC solid;
 	border-bottom: 2rpx #CCCCCC solid;
 }
 }
 
 
-.item-list-left{
+.item-list-left {
 	display: flex;
 	display: flex;
 	justify-content: space-between;
 	justify-content: space-between;
 	width: 425upx;
 	width: 425upx;
@@ -131,8 +131,19 @@ page {
 	color: #333333;
 	color: #333333;
 }
 }
 
 
-.show-money{
+.show-money {
 	margin-right: 10upx;
 	margin-right: 10upx;
 	color: #F76200;
 	color: #F76200;
 	font-size: 32upx;
 	font-size: 32upx;
-}
+}
+
+.uni-input-label {
+	margin-right: 15rpx;
+	font-size: 32rpx;
+}
+
+.iconfont {
+	margin-bottom: 10rpx;
+	font-size: 32rpx;
+	color: $my-color-primary;
+}

+ 9 - 36
pages/show/show.vue

@@ -25,15 +25,9 @@
 				<picker mode="date" fields="month" :start="startDate" :end="endDate" @change="bindDateChange">
 				<picker mode="date" fields="month" :start="startDate" :end="endDate" @change="bindDateChange">
 					<view class="uni-input">
 					<view class="uni-input">
 						<text class="uni-input-label">{{date}}</text>
 						<text class="uni-input-label">{{date}}</text>
-						<text class="iconfont icon-sanjiaoxing"></text>
+						<text class="iconfont icon-arrow-down"></text>
 					</view>
 					</view>
 				</picker>
 				</picker>
-				<!-- <picker mode="date" fields="month" :start="startDate" :end="endDate" @change="bindDateChange">
-					<view class="uni-input">
-						<text class="uni-input-label">{{date}}</text>月
-						<text class="iconfont icon-sanjiaoxing"></text>
-					</view>
-				</picker> -->
 				<view class="uni-list">
 				<view class="uni-list">
 					<view class="item-list" v-for="(item, i) in list" :key="i">
 					<view class="item-list" v-for="(item, i) in list" :key="i">
 						<view class="item-list-left">
 						<view class="item-list-left">
@@ -50,7 +44,7 @@
 </template>
 </template>
 
 
 <script>
 <script>
-	import data from '../../static/test_xiaofei.js'
+	// import data from '../../static/test_xiaofei.js'
 	export default {
 	export default {
 		data() {
 		data() {
 			return {
 			return {
@@ -62,12 +56,12 @@
 						data: [],
 						data: [],
 					}],
 					}],
 				},
 				},
-				date: getDate({
-					// format: true
+				date: this.$getDate({
+					format: true
 				}),
 				}),
-				// startDate: getDate('start_date'),
-				// endDate: getDate('end_date'),
-				all_data: data, //所有数据
+				startDate: this.$getDate('start_date'),
+				endDate: this.$getDate('end_date'),
+				all_data: '', //所有数据
 				list: [] ,//消费列表
 				list: [] ,//消费列表
 				card_number: 0,   //用户卡号
 				card_number: 0,   //用户卡号
 			}
 			}
@@ -77,7 +71,7 @@
 			this.chartData.series[0].data = this.use_elec;
 			this.chartData.series[0].data = this.use_elec;
 			// console.log(this.chartData.series[0].data)
 			// console.log(this.chartData.series[0].data)
 			
 			
-			this.list = this.all_data.data[0].xiaofei;
+			// this.list = this.all_data.data[0].xiaofei;
 			// this.name = this.all_data.data[0].xiaofei.name;
 			// this.name = this.all_data.data[0].xiaofei.name;
 			// console.log(this.date)
 			// console.log(this.date)
 			this.card_number = options.card_number
 			this.card_number = options.card_number
@@ -86,29 +80,8 @@
 		methods: {
 		methods: {
 			bindDateChange: function(e) {
 			bindDateChange: function(e) {
 				this.date = e.detail.value
 				this.date = e.detail.value
-				// console.log(this.date)
-			},
-			
-		},
-		
-	}
-	function getDate(type) {
-		const date = new Date();
-	
-		let year = date.getFullYear();
-		let month = date.getMonth() + 1;
-		// let day = date.getDate();
-	
-		if (type === 'start_date') {
-			year = year - 4;
-		} else if (type === 'end_date') {
-			year = year;
+			}
 		}
 		}
-	
-		month = month > 9 ? month : '0' + month;
-		// day = day > 9 ? day : '0' + day;
-	
-		return `${year}-${month}`;
 	}
 	}
 </script>
 </script>
 
 

+ 55 - 3
static/api.js

@@ -2,7 +2,6 @@ const WECARD_BASE_URL = 'https://open.wecard.qq.com' // wecard
 const CODE_BASE_URL = 'https://developdomain.chuanghai-tech.com' // code
 const CODE_BASE_URL = 'https://developdomain.chuanghai-tech.com' // code
 
 
 const myRequest = (options) => {
 const myRequest = (options) => {
-
 	// 域名 或 url 为空,则不执行任何操作
 	// 域名 或 url 为空,则不执行任何操作
 	if (options.host == '' || options.url == '') {
 	if (options.host == '' || options.url == '') {
 		return
 		return
@@ -40,7 +39,7 @@ const myRequest = (options) => {
 				uni.showToast({
 				uni.showToast({
 					icon: 'none',
 					icon: 'none',
 					title: err.errMsg,
 					title: err.errMsg,
-					duration: 1000000
+					duration: 5000
 				})
 				})
 				reject(err)
 				reject(err)
 			}
 			}
@@ -52,7 +51,60 @@ const myRequest = (options) => {
 	)
 	)
 }
 }
 
 
+/**
+ * 时间计算
+ */
+const getDate = function getDate(type) {
+	const date = new Date();
+
+	let year = date.getFullYear();
+	let month = date.getMonth() + 1;
+	// let day = date.getDate();
+
+	if (type === 'start_date') {
+		year = year - 4;
+	} else if (type === 'end_date') {
+		year = year;
+	}
+
+	month = month > 9 ? month : '0' + month;
+	// day = day > 9 ? day : '0' + day;
+
+	return `${year}-${month}`;
+}
+
+/**
+ * 时间生成订单号
+ */
+const getOrderId = function get_order_id(head) {
+	const date = new Date()
+
+	let year = date.getFullYear()
+	let month = date.getMonth() + 1
+	let day = date.getDate()
+	let hour = date.getHours()
+	let minute = date.getMinutes()
+	let second = date.getSeconds()
+	let millisecond = date.getMilliseconds()
+	let len_mill = millisecond.toString().length
+
+	month = month > 9 ? month : '0' + month
+	day = day > 9 ? day : '0' + day
+	second = second > 9 ? second : '0' + second
+	if (len_mill == 1) {
+		millisecond = (Math.floor(Math.random() * 9000) + 10000).toString() + millisecond
+	} else if (len_mill == 2) {
+		millisecond = (Math.floor(Math.random() * 900) + 1000).toString() + millisecond
+	} else if (len_mill == 3) {
+		millisecond = (Math.floor(Math.random() * 900) + 100).toString() + millisecond
+	}
+
+	return `${head}${year}${month}${day}${hour}${minute}${second}${millisecond}`
+}
+
 export {
 export {
 	CODE_BASE_URL,
 	CODE_BASE_URL,
-	myRequest
+	myRequest,
+	getDate,
+	getOrderId
 }
 }