Browse Source

Merge branch 'master' of https://e.coding.net/chuanghaikeji/smarCampus/waterElectricityMinApp

zhang 5 years ago
parent
commit
4b9545d990
7 changed files with 247 additions and 209 deletions
  1. 2 1
      App.vue
  2. 1 1
      manifest.json
  3. 1 1
      pages.json
  4. 47 34
      pages/index/index.vue
  5. 96 90
      pages/jiaofei/jiaofei.vue
  6. 70 40
      pages/recharge/recharge.vue
  7. 30 42
      pages/select/select.vue

+ 2 - 1
App.vue

@@ -10,7 +10,8 @@
 			// console.log('App Hide')
 			// console.log('App Hide')
 		},
 		},
 		globalData: {
 		globalData: {
-			primaryColor: '#1296db'
+			primaryColor: '#1296db',
+			test: true
 		}
 		}
 	}
 	}
 </script>
 </script>

+ 1 - 1
manifest.json

@@ -50,7 +50,7 @@
     "quickapp" : {},
     "quickapp" : {},
     /* 小程序特有相关 */
     /* 小程序特有相关 */
     "mp-weixin" : {
     "mp-weixin" : {
-        "appid" : "wx2fc3f45732fae5d3",
+        "appid" : "wxd6f090391d410534",
         "setting" : {
         "setting" : {
             "urlCheck" : false
             "urlCheck" : false
         },
         },

+ 1 - 1
pages.json

@@ -25,7 +25,7 @@
 			"path": "pages/jiaofei/jiaofei",
 			"path": "pages/jiaofei/jiaofei",
 			"style": {
 			"style": {
 				"navigationBarTitleText": "缴电费",
 				"navigationBarTitleText": "缴电费",
-				"enablePullDownRefresh": true
+				"enablePullDownRefresh": false
 			}
 			}
 		}
 		}
 		,
 		,

+ 47 - 34
pages/index/index.vue

@@ -150,20 +150,26 @@
 						'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://wxd6f090391d410534'
 					}
 					}
 				})
 				})
+				if (res.statusCode == 200) {
+					if (res.data.refresh_token == '' || res.data.refresh_token == 'undefined') {
+						uni.showToast({
+							title: '未获得token'
+						})
+					} else {
+						this.access_token = res.data.access_token;
+						this.refresh_token = res.data.refresh_token;
 
 
-				if (res.data.refresh_token == '' || res.data.refresh_token == 'undefined') {
-					uni.showToast({
-						title: '未获得token'
-					});
+						// 通过access_token换取用户信息
+						this.get_user_info();
+					}
 				} else {
 				} else {
-					this.access_token = res.data.access_token;
-					this.refresh_token = res.data.refresh_token;
-
-					// 通过access_token换取用户信息
-					this.get_user_info();
+					uni.showToast({
+						icon: 'none',
+						title: '请求失败,未获得token'
+					})
 				}
 				}
 			},
 			},
 
 
@@ -183,34 +189,41 @@
 					}
 					}
 				});
 				});
 
 
-				if (res.data.errcode == 0 && res.data.errmsg == 'OK') {
-					try {
-						this.userinfo = res.data
-						this.userinfo.amount = this.amount
-						// 微校参数
-						this.userinfo.appkey = this.appkey
-						this.userinfo.app_secret = this.app_secret
-						this.userinfo.ocode = this.ocode
-						this.userinfo.sub_appid = this.sub_appid
-						this.userinfo.appid = this.appid
-						// 存储用户信息
-						uni.setStorageSync('userinfo_storage_key', this.userinfo)
-						// 提示授权成功
+				if (res.statusCode == 200) {
+					if (res.data.errcode == 0 && res.data.errmsg == 'OK') {
+						try {
+							this.userinfo = res.data
+							this.userinfo.amount = this.amount
+							// 微校参数
+							this.userinfo.appkey = this.appkey
+							this.userinfo.app_secret = this.app_secret
+							this.userinfo.ocode = this.ocode
+							this.userinfo.sub_appid = this.sub_appid
+							this.userinfo.appid = this.appid
+							// 存储用户信息
+							uni.setStorageSync('userinfo_storage_key', this.userinfo)
+							// 提示授权成功
+							uni.showToast({
+								icon: 'success',
+								title: '授权成功',
+								duration: 800,
+								success: (res) => {
+									this.my_display = true
+								}
+							})
+						} catch (e) {
+							console.log(e)
+						}
+					} else {
 						uni.showToast({
 						uni.showToast({
-							icon: 'success',
-							title: '授权成功',
-							duration: 800,
-							success: (res) => {
-								this.my_display = true
-							}
-						})
-					} catch (e) {
-						console.log(e)
+							title: '未获得用户信息',
+							duration: 1000
+						});
 					}
 					}
 				} else {
 				} else {
 					uni.showToast({
 					uni.showToast({
-						title: '未获得用户信息',
-						duration: 1000
+						icon: 'none',
+						title: '请求失败,未授权成功'
 					});
 					});
 				}
 				}
 			},
 			},

+ 96 - 90
pages/jiaofei/jiaofei.vue

@@ -30,6 +30,9 @@
 						:class="{'bg-color':add_class1==1}">10元</button>
 						:class="{'bg-color':add_class1==1}">10元</button>
 				</view>
 				</view>
 				<view class="add-money-button">
 				<view class="add-money-button">
+					<button class="select-submit" :data-item="20" @tap="add_money">20元</button>
+				</view>
+				<view class="add-money-button">
 					<button class="select-submit" :data-item="30" @tap="add_money">30元</button>
 					<button class="select-submit" :data-item="30" @tap="add_money">30元</button>
 				</view>
 				</view>
 				<view class="add-money-button">
 				<view class="add-money-button">
@@ -41,14 +44,11 @@
 				<view class="add-money-button">
 				<view class="add-money-button">
 					<button class="select-submit" :data-item="200" @tap="add_money">200元</button>
 					<button class="select-submit" :data-item="200" @tap="add_money">200元</button>
 				</view>
 				</view>
-				<view class="add-money-button">
-					<button class="select-submit" :data-item="300" @tap="add_money">300元</button>
-				</view>
 			</view>
 			</view>
 		</view>
 		</view>
 		<view class="show-item">
 		<view class="show-item">
-			<input class="input-money" placeholder="请输入金额(1-1000)" v-model:value="inputMoney"
-				placeholder-class="#B3B3B3" @input="onInput" />
+			<input class="input-money" maxlength="4" placeholder="请输入金额(1-200)" v-model:value="inputMoney"
+				placeholder-class="#B3B3B3" @input="onInput" @blur="onBlur" />
 		</view>
 		</view>
 		<view class="submit-item">
 		<view class="submit-item">
 			<button class="submit" :data-rooms='room' @tap="input_money">充值</button>
 			<button class="submit" :data-rooms='room' @tap="input_money">充值</button>
@@ -64,43 +64,34 @@
 		data() {
 		data() {
 			return {
 			return {
 				index: 0,
 				index: 0,
-				roomSelect: '请选择房间号', //房间号
+				roomSelect: '', //房间号
 				remainElec: 80.1, //剩余电量
 				remainElec: 80.1, //剩余电量
 				add_class: '', //增加class属性
 				add_class: '', //增加class属性
 				add_class1: '',
 				add_class1: '',
 				inputMoney: '', //手动输入增加金额
 				inputMoney: '', //手动输入增加金额
 				addMoney: 0, //选择充值金额
 				addMoney: 0, //选择充值金额
-				// add_class_money: '',  
 				userinfo: {}, //用户信息
 				userinfo: {}, //用户信息
-				card_number: 0, //用户卡号
+				order_id: '', // 订单号
+				card_number: '', //用户卡号
 				dom: '', //房间号
 				dom: '', //房间号
 				campus: '', //校区
 				campus: '', //校区
 				access_token: '',
 				access_token: '',
 				sub_appid: '', //商户号
 				sub_appid: '', //商户号
-				order_id: '', //订单号
 				pay_info: '',
 				pay_info: '',
-				item: {},
-				// storage: {},
+				test: getApp().globalData.test
 			}
 			}
 		},
 		},
-
-		onPullDownRefresh: function() {
-			uni.navigateTo({
-				url: '../jiaofei/jiaofei',
-			});
-			// console.log('触发了下拉刷新')
-		},
-
 		onLoad: function(options) {
 		onLoad: function(options) {
 			// console.log('item:' + options.item);
 			// console.log('item:' + options.item);
-			// console.log(options.item.card_number)
 			try {
 			try {
 				// 获取存储的用户数据
 				// 获取存储的用户数据
-				const value = uni.getStorageSync('userinfo_storage_key');
+				const value = uni.getStorageSync('userinfo_storage_key')
+				let item_tmp = decodeURIComponent(options.item)
+
 				//将字符串解密转换成对象
 				//将字符串解密转换成对象
-				let item = JSON.parse(decodeURIComponent(options.item));
+				let item = JSON.parse(item_tmp);
 				// console.log(item)
 				// console.log(item)
-				if (JSON.stringify(item) === '{}') { // 如果没有用户信息,返回首页
+				if (item_tmp == '{}') { // 如果没有用户信息,返回首页
 					uni.redirectTo({
 					uni.redirectTo({
 						url: '../index/index'
 						url: '../index/index'
 					});
 					});
@@ -108,14 +99,14 @@
 				}
 				}
 
 
 				//判断item是否存在
 				//判断item是否存在
-				if (JSON.stringify(item) != '') {
+				if (item_tmp != '') {
 					//判断是哪个页面传入
 					//判断是哪个页面传入
 					if (typeof(item.roomSelect) != 'undefined') {
 					if (typeof(item.roomSelect) != 'undefined') {
 						// this.item = item;
 						// this.item = item;
 						this.roomSelect = item.roomSelect;
 						this.roomSelect = item.roomSelect;
 						this.add_class = 1;
 						this.add_class = 1;
 						this.dom = item.dom;
 						this.dom = item.dom;
-						console.log(this.roomSelect)
+						// console.log(this.roomSelect)
 					} else {
 					} else {
 						// 处理JSON字符串
 						// 处理JSON字符串
 						// this.userinfo = options.item.replace(/"/g, "'");
 						// this.userinfo = options.item.replace(/"/g, "'");
@@ -123,13 +114,11 @@
 						// 更新存储的用户信息
 						// 更新存储的用户信息
 						uni.setStorageSync('userinfo_storage_key', this.userinfo)
 						uni.setStorageSync('userinfo_storage_key', this.userinfo)
 						// console.log(this.userinfo)
 						// console.log(this.userinfo)
-						this.card_number = this.userinfo.card_number
 						this.campus = this.userinfo.campus
 						this.campus = this.userinfo.campus
 						this.dom = this.userinfo.dorm_number
 						this.dom = this.userinfo.dorm_number
+						this.sub_appid = this.userinfo.sub_appid
 						this.roomSelect = this.campus + this.dom
 						this.roomSelect = this.campus + this.dom
-						this.add_class = 1;
-						this.order_id = get_order_id();
-						this.sub_appid = this.userinfo.sub_appid;
+						this.add_class = 1
 					}
 					}
 				} else if (value != '') {
 				} else if (value != '') {
 					// 处理JSON字符串
 					// 处理JSON字符串
@@ -141,17 +130,12 @@
 			} 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.get_valid_credentials()
 			this.get_valid_credentials()
-
-			// console.log('房间号' + this.dom)
-
-			//将缓存中的token码进行获取
-			// this.access_token = uni.getStorageSync('userinfo_storage_key').access_token
 		},
 		},
 
 
 		methods: {
 		methods: {
@@ -166,6 +150,8 @@
 			 * 获取应用有效凭证
 			 * 获取应用有效凭证
 			 */
 			 */
 			async get_valid_credentials() {
 			async get_valid_credentials() {
+				const value = uni.getStorageSync('userinfo_storage_key')
+				// console.log(value)
 				const res = await this.$myRequest({
 				const res = await this.$myRequest({
 					host: 'wecard',
 					host: 'wecard',
 					url: '/cgi-bin/oauth2/token',
 					url: '/cgi-bin/oauth2/token',
@@ -174,11 +160,11 @@
 						'content-type': 'application/json'
 						'content-type': 'application/json'
 					},
 					},
 					data: {
 					data: {
-						'app_key': this.userinfo.appkey,
-						'app_secret': this.userinfo.app_secret,
+						'app_key': value.appkey,
+						'app_secret': value.app_secret,
 						'grant_type': 'client_credentials',
 						'grant_type': 'client_credentials',
 						'scope': 'base',
 						'scope': 'base',
-						'ocode': this.userinfo.ocode
+						'ocode': value.ocode
 					}
 					}
 				});
 				});
 
 
@@ -192,11 +178,11 @@
 					})
 					})
 				}
 				}
 			},
 			},
-			
+
 			//跳转到选择页面
 			//跳转到选择页面
 			navigateToSelect() {
 			navigateToSelect() {
 				uni.navigateTo({
 				uni.navigateTo({
-					url: '../select/select',
+					url: '../select/select?roomSelect=' + this.roomSelect,
 				});
 				});
 			},
 			},
 
 
@@ -211,72 +197,75 @@
 			add_money(e) {
 			add_money(e) {
 				this.add_class1 = 0
 				this.add_class1 = 0
 				this.addMoney = e.currentTarget.dataset.item
 				this.addMoney = e.currentTarget.dataset.item
+
+				this.confirm_info()
+			},
+
+			confirm_info(num_money) {
+				if (this.roomSelect == '') {
+					uni.showToast({
+						title: '请选择房间号',
+						icon:'success'
+					})
+					
+					return
+				}
+				
 				uni.showModal({
 				uni.showModal({
 					// title: '确定充值'+this.inputMoney+'元',
 					// title: '确定充值'+this.inputMoney+'元',
 					title: '确定充值' + this.addMoney + '元',
 					title: '确定充值' + this.addMoney + '元',
 					success: (res) => {
 					success: (res) => {
 						if (res.confirm) {
 						if (res.confirm) {
-							// console.log('用户点击确定');
-							// console.log(this.addMoney);
 							this.pay_money_start()
 							this.pay_money_start()
-							// console.log(this.access_token)
-							// console.log('卡号' + this.card_number)
-							// console.log(this.sub_appid)
-							// console.log(this.order_id)
-							// console.log(this.addMoney)
 						} else if (res.cancel) {
 						} else if (res.cancel) {
 							console.log('用户点击取消');
 							console.log('用户点击取消');
 						}
 						}
 					}
 					}
-				});
-
-				// this.pay_money_start()
+				})
 			},
 			},
 
 
 			//增加可变金额
 			//增加可变金额
 			input_money(e) {
 			input_money(e) {
-
 				// console.log(e)
 				// console.log(e)
 				//判断输入是否为空或不是数字
 				//判断输入是否为空或不是数字
 				if (this.inputMoney == '' || this.inputMoney == null) {
 				if (this.inputMoney == '' || this.inputMoney == null) {
 					uni.showToast({
 					uni.showToast({
-						title: '请输入',
-						duration: 2000
-					});
-				} else if (isNaN(this.inputMoney)) {
-					uni.showToast({
-						title: '输入错误',
+						title: '请输入充值金额',
 						duration: 2000
 						duration: 2000
-					});
-				} else if (this.inputMoney > 1000 || this.inputMoney < 0) {
+					})
+
+					return
+				}
+
+				if (isNaN(this.inputMoney)) {
 					uni.showToast({
 					uni.showToast({
-						title: '超出范围',
+						title: '请输入数值',
 						duration: 2000
 						duration: 2000
-					});
+					})
+
+					return
+				}
+				if (this.test) {
+
 				} else {
 				} else {
-					this.addMoney = this.inputMoney
-					uni.showModal({
-						// title: '确定充值'+this.inputMoney+'元',
-						title: '确定充值' + this.addMoney + '元',
-						success: (res) => {
-							if (res.confirm) {
-								// console.log('用户点击确定');
-								// console.log(this.addMoney)
-								this.pay_money_start()
-							} else if (res.cancel) {
-								console.log('用户点击取消');
-							}
-						}
-					});
+					if (this.inputMoney > 200 || this.inputMoney < 10) {
+						uni.showToast({
+							title: '限额10~200元',
+							duration: 2000
+						})
 
 
+						return
+					}
 				}
 				}
 
 
+				this.addMoney = this.inputMoney
+
+				this.confirm_info()
 			},
 			},
 
 
 			//准备支付
 			//准备支付
 			async pay_money_start() {
 			async pay_money_start() {
 				const res = await this.$myRequest({
 				const res = await this.$myRequest({
-					// ip: 'https://open.wecard.qq.com',
 					host: 'wecard',
 					host: 'wecard',
 					url: "/cgi-bin/pay/app/mppay",
 					url: "/cgi-bin/pay/app/mppay",
 					method: 'POST',
 					method: 'POST',
@@ -287,16 +276,11 @@
 						'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,
+						"order_id": this.order_id = get_order_id('dianfei'),
 						"amount": this.addMoney * 100,
 						"amount": this.addMoney * 100,
 					}
 					}
-				});
-				console.log(this.access_token)
-				console.log(this.sub_appid)
-				console.log(this.card_number)
-				console.log(this.order_id)
-				console.log(this.addMoney)
-				console.log(res.data)
+				})
+
 				if (res.data.code == 0) {
 				if (res.data.code == 0) {
 					this.pay_info = res.data.data.pay_info
 					this.pay_info = res.data.data.pay_info
 					// 发起支付
 					// 发起支付
@@ -348,6 +332,10 @@
 			 * 输入充值金额
 			 * 输入充值金额
 			 */
 			 */
 			onInput(e) {
 			onInput(e) {
+				if (this.test) {
+					return
+				}
+
 				const v = e.detail.value
 				const v = e.detail.value
 				this.inputMoney = 10
 				this.inputMoney = 10
 
 
@@ -364,18 +352,30 @@
 						final = final.slice(1) - 0 || 0
 						final = final.slice(1) - 0 || 0
 					}
 					}
 
 
-					if (final > 1000) {
-						final = 1000
+					if (final > 200) {
+						final = 200
 					}
 					}
 				}
 				}
 				this.$nextTick(() => {
 				this.$nextTick(() => {
 					this.inputMoney = final.toString() || '0'
 					this.inputMoney = final.toString() || '0'
 				})
 				})
+			},
+			/**
+			 * 失去焦点时
+			 */
+			onBlur() {
+				if (this.test) {
+					return
+				}
+
+				if (this.inputMoney < 10) {
+					this.inputMoney = 10
+				}
 			}
 			}
 		},
 		},
 	}
 	}
 
 
-	function get_order_id() {
+	function get_order_id(head) {
 		const date = new Date()
 		const date = new Date()
 
 
 		let year = date.getFullYear()
 		let year = date.getFullYear()
@@ -385,14 +385,20 @@
 		let minute = date.getMinutes()
 		let minute = date.getMinutes()
 		let second = date.getSeconds()
 		let second = date.getSeconds()
 		let millisecond = date.getMilliseconds()
 		let millisecond = date.getMilliseconds()
+		let len_mill = millisecond.length
 
 
 		month = month > 9 ? month : '0' + month
 		month = month > 9 ? month : '0' + month
 		day = day > 9 ? day : '0' + day
 		day = day > 9 ? day : '0' + day
 		second = second > 9 ? second : '0' + second
 		second = second > 9 ? second : '0' + second
-		// 小于4位数,前补0
-		millisecond = millisecond.length < 3 ? '0' + millisecond : millisecond
+		if (len_mill == 1) {
+			millisecond = '000' + millisecond
+		} else if (len_mill == 2) {
+			millisecond = '00'
+		} else if (len_mill == 3) {
+			millisecond = '0' + millisecond
+		}
 
 
-		return `${year}${month}${day}${hour}${minute}${second}${millisecond}`
+		return `${head}${year}${month}${day}${hour}${minute}${second}${millisecond}`
 	}
 	}
 </script>
 </script>
 
 

+ 70 - 40
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="3" v-model="amount" @input="onInput" @blur="onBlur"
+				<input 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>
@@ -40,7 +40,8 @@
 				userinfo: '', // 用户信息
 				userinfo: '', // 用户信息
 				order_id: '', // 订单号
 				order_id: '', // 订单号
 				pay_info: '', // 支付参数。将此参数透传给支付 SDK 发起支付
 				pay_info: '', // 支付参数。将此参数透传给支付 SDK 发起支付
-				access_token: ''
+				access_token: '',
+				test: getApp().globalData.test
 			};
 			};
 		},
 		},
 		onLoad(options) {
 		onLoad(options) {
@@ -48,6 +49,7 @@
 				// 获取存储的用户数据
 				// 获取存储的用户数据
 				const value = uni.getStorageSync('userinfo_storage_key')
 				const value = uni.getStorageSync('userinfo_storage_key')
 				let item = decodeURIComponent(options.item)
 				let item = decodeURIComponent(options.item)
+				// console.log(item)
 				if (item === '{}' && value == '') { // 如果没有用户信息,返回首页
 				if (item === '{}' && value == '') { // 如果没有用户信息,返回首页
 					uni.redirectTo({
 					uni.redirectTo({
 						url: '../index/index'
 						url: '../index/index'
@@ -119,17 +121,13 @@
 						'access_token': this.access_token,
 						'access_token': this.access_token,
 						'sub_appid': this.userinfo.sub_appid,
 						'sub_appid': this.userinfo.sub_appid,
 						'user_id': this.userinfo.card_number,
 						'user_id': this.userinfo.card_number,
-						'order_id': this.order_id = get_order_id(),
-						'amount': this.amount * 100
+						'order_id': this.order_id = get_order_id('shuifei'),
+						'amount': this.amount * 100,
+						'order_type': 1,
+						'callback_url': ''
 					}
 					}
 				})
 				})
-				console.log(this.access_token)
-				console.log(this.userinfo.sub_appid)
-				console.log(this.userinfo.card_number)
-				console.log(this.order_id)
-				console.log(this.amount)
-				console.log(res.data)
-				if (res.data.code == 0) {
+				if (res.statusCode == 200) {
 					this.pay_info = res.data.data.pay_info
 					this.pay_info = res.data.data.pay_info
 					// 发起支付
 					// 发起支付
 					this.pay_amount()
 					this.pay_amount()
@@ -144,40 +142,44 @@
 			// 调起支付
 			// 调起支付
 			pay_amount() {
 			pay_amount() {
 				var OpenMidas = require("@/static/openMidas.js") // 引入小程序目录下的SDK文件
 				var OpenMidas = require("@/static/openMidas.js") // 引入小程序目录下的SDK文件
-				
+
 				// 设置支付配置
 				// 设置支付配置
 				wx['OpenMidasConfig'] = {
 				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"// 私有化参数联系微卡客服进行获取
+					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 payInfo = this.pay_info; // 请求mppay接口返回的数据
 				var appMetaData = "app=test&version=1.1"; // 自定义回调数据
 				var appMetaData = "app=test&version=1.1"; // 自定义回调数据
-				
+
 				OpenMidas.init("test");
 				OpenMidas.init("test");
 				OpenMidas.pay(
 				OpenMidas.pay(
-				  payInfo,
-				  function(resultCode, innerCode, resultMsg, appMetaData) {
-				    console.log(resultCode); // 支付响应状态码
-				    console.log(innerCode); // 支付响应内部错误码
-				    console.log(resultMsg); // 支付响应说明
-				    console.log(appMetaData); // 自定义回调数据
-				
-				    // todo:处理业务逻辑
-				  },
-				  appMetaData
+					payInfo,
+					function(resultCode, innerCode, resultMsg, appMetaData) {
+						console.log(resultCode); // 支付响应状态码
+						console.log(innerCode); // 支付响应内部错误码
+						console.log(resultMsg); // 支付响应说明
+						console.log(appMetaData); // 自定义回调数据
+
+						// todo:处理业务逻辑
+					},
+					appMetaData
 				)
 				)
 			},
 			},
 			/**
 			/**
 			 * 输入充值金额
 			 * 输入充值金额
 			 */
 			 */
 			onInput(e) {
 			onInput(e) {
+				if (this.test) {
+					return
+				}
+				
 				const v = e.detail.value
 				const v = e.detail.value
 				this.amount = 10
 				this.amount = 10
 
 
@@ -201,11 +203,14 @@
 				this.$nextTick(() => {
 				this.$nextTick(() => {
 					this.amount = final.toString() || '0'
 					this.amount = final.toString() || '0'
 				})
 				})
-				// setTimeout(() => {
-				// 	this.amount = final.toString() || '0'
-				// }, 100)
 			},
 			},
+			/**
+			 * 输入框,失去焦点时
+			 */
 			onBlur() {
 			onBlur() {
+				if (this.test) {
+					return
+				}
 				if (this.amount < 10) {
 				if (this.amount < 10) {
 					this.amount = 10
 					this.amount = 10
 				}
 				}
@@ -220,6 +225,24 @@
 			 * 调用接口实现充值功能
 			 * 调用接口实现充值功能
 			 */
 			 */
 			chongzhi() {
 			chongzhi() {
+				if (this.test) {
+					uni.showModal({
+						title: '提示',
+						content: '您选择了充值:¥' + this.amount + ' 元',
+						cancelText: '算了',
+						confirmText: '充值',
+						success: (res) => {
+							if (res.confirm) {
+								// 组合地址,发起支付
+								this.jsapi()
+							} else if (res.cancel) {
+								return
+							}
+						}
+					})
+					
+					return
+				}
 				if (this.amount < 10 || this.amount > 100) {
 				if (this.amount < 10 || this.amount > 100) {
 					uni.showToast({
 					uni.showToast({
 						icon: 'none',
 						icon: 'none',
@@ -227,6 +250,7 @@
 						mask: true,
 						mask: true,
 						duration: 3000
 						duration: 3000
 					})
 					})
+					return
 				} else {
 				} else {
 					uni.showModal({
 					uni.showModal({
 						title: '提示',
 						title: '提示',
@@ -238,7 +262,7 @@
 								// 组合地址,发起支付
 								// 组合地址,发起支付
 								this.jsapi()
 								this.jsapi()
 							} else if (res.cancel) {
 							} else if (res.cancel) {
-								console.log('用户点击取消');
+								return
 							}
 							}
 						}
 						}
 					})
 					})
@@ -257,7 +281,7 @@
 	/**
 	/**
 	 * 时间生成订单号
 	 * 时间生成订单号
 	 */
 	 */
-	function get_order_id() {
+	function get_order_id(head) {
 		const date = new Date()
 		const date = new Date()
 
 
 		let year = date.getFullYear()
 		let year = date.getFullYear()
@@ -267,14 +291,20 @@
 		let minute = date.getMinutes()
 		let minute = date.getMinutes()
 		let second = date.getSeconds()
 		let second = date.getSeconds()
 		let millisecond = date.getMilliseconds()
 		let millisecond = date.getMilliseconds()
+		let len_mill = millisecond.length
 
 
 		month = month > 9 ? month : '0' + month
 		month = month > 9 ? month : '0' + month
 		day = day > 9 ? day : '0' + day
 		day = day > 9 ? day : '0' + day
 		second = second > 9 ? second : '0' + second
 		second = second > 9 ? second : '0' + second
-		// 小于4位数,前补0
-		millisecond = millisecond.length < 3 ? '0' + millisecond : millisecond
+		if (len_mill == 1) {
+			millisecond = '000' + millisecond
+		} else if (len_mill == 2) {
+			millisecond = '00'
+		} else if (len_mill == 3) {
+			millisecond = '0' + millisecond
+		}
 
 
-		return `${year}${month}${day}${hour}${minute}${second}${millisecond}`
+		return `${head}${year}${month}${day}${hour}${minute}${second}${millisecond}`
 	}
 	}
 </script>
 </script>
 
 

+ 30 - 42
pages/select/select.vue

@@ -89,8 +89,32 @@
 			}
 			}
 		},
 		},
 
 
-		onLoad() {
-			// console.log(this.allData.data[1].builds.length)
+		onLoad(options) {
+			// console.log(options)
+			var str = options.roomSelect;
+			var arr = new Array();
+			var i = 0;
+			while (i < str.length) {
+				var s = "";
+				while (str.charCodeAt(i) < 256) {
+					s = s + str.charAt(i);
+					i++;
+				}
+				arr.push(s);
+				var s = "";
+				while (str.charCodeAt(i) > 256) {
+					s = s + str.charAt(i);
+					i++;
+				}
+				arr.push(s);
+			}
+			for (i = 0; i < arr.length; i++) {
+				console.log(arr[i]);
+			}
+			
+			// 自动填充
+			
+			
 			this.nschool = this.allData.data.length
 			this.nschool = this.allData.data.length
 		},
 		},
 
 
@@ -98,102 +122,66 @@
 			changeSelect1(e) {
 			changeSelect1(e) {
 				// console.log(e);
 				// console.log(e);
 				this.index1 = e.detail.value;
 				this.index1 = e.detail.value;
-
 				//清空选择器
 				//清空选择器
 				if (this.array2) {
 				if (this.array2) {
-
 					this.array2 = []
 					this.array2 = []
-
 				}
 				}
-
+				
 				//获取选择器1的值
 				//获取选择器1的值
 				for (var i = 0; i < this.nschool; i++) {
 				for (var i = 0; i < this.nschool; i++) {
-
 					// this.array1.push(this.allData.data[i].school)
 					// this.array1.push(this.allData.data[i].school)
-
 					// console.log(this.allData.data[i].school)
 					// console.log(this.allData.data[i].school)
-
 					//判断是否为空,不为空则继续
 					//判断是否为空,不为空则继续
 					if (!this.allData.data[i].builds) {
 					if (!this.allData.data[i].builds) {
-
 						continue
 						continue
-
 					}
 					}
-
+					
 					//获取选择器二中的值
 					//获取选择器二中的值
 					if (i == this.index1) {
 					if (i == this.index1) {
-
 						//得到选择器二中值的个数
 						//得到选择器二中值的个数
 						this.nbuilds = this.allData.data[i].builds.length
 						this.nbuilds = this.allData.data[i].builds.length
-
 						// console.log(this.nbuilds)
 						// console.log(this.nbuilds)
-
 						//将数据加入选择器二中
 						//将数据加入选择器二中
 						for (var j = 0; j < this.nbuilds; j++) {
 						for (var j = 0; j < this.nbuilds; j++) {
-
 							this.array2.push(this.allData.data[i].builds[j].building)
 							this.array2.push(this.allData.data[i].builds[j].building)
-
 						}
 						}
-
 					}
 					}
-
 				}
 				}
 
 
 				this.arr1 = this.array1;
 				this.arr1 = this.array1;
-
 				// this.room = this.room.concat(this.array1[this.index1]);
 				// this.room = this.room.concat(this.array1[this.index1]);
-
 				this.add_class1 = 1;
 				this.add_class1 = 1;
-
 				this.dis_num2 = 0;
 				this.dis_num2 = 0;
-
 				// console.log(this.array2)
 				// console.log(this.array2)
 				// console.log(this.room)
 				// console.log(this.room)
 			},
 			},
 			changeSelect2(e) {
 			changeSelect2(e) {
 				// console.log(e);
 				// console.log(e);
 				this.index2 = e.detail.value;
 				this.index2 = e.detail.value;
-
 				if (this.array3) {
 				if (this.array3) {
-
 					this.array3 = []
 					this.array3 = []
-
 				}
 				}
-
+				
 				for (var i = 0; i < this.nbuilds; i++) {
 				for (var i = 0; i < this.nbuilds; i++) {
-
 					// this.array1.push(this.allData.data[i].school)
 					// this.array1.push(this.allData.data[i].school)
-
 					// console.log(this.allData.data[i].school)
 					// console.log(this.allData.data[i].school)
-
 					if (!this.allData.data[this.index1].builds[i].floors) {
 					if (!this.allData.data[this.index1].builds[i].floors) {
 						continue
 						continue
 					}
 					}
-
+					
 					if (i == this.index2) {
 					if (i == this.index2) {
-
 						this.floors = this.allData.data[this.index1].builds[i].floors.length
 						this.floors = this.allData.data[this.index1].builds[i].floors.length
-
 						// console.log(this.floors)
 						// console.log(this.floors)
-
 						for (var j = 0; j < this.floors; j++) {
 						for (var j = 0; j < this.floors; j++) {
-
 							this.array3.push(this.allData.data[this.index1].builds[i].floors[j].floor)
 							this.array3.push(this.allData.data[this.index1].builds[i].floors[j].floor)
-
 						}
 						}
-
 					}
 					}
-
 				}
 				}
 
 
 				this.arr2 = this.array2;
 				this.arr2 = this.array2;
-
 				// this.room = this.room.concat(this.array2[this.index2]);
 				// this.room = this.room.concat(this.array2[this.index2]);
-
 				this.add_class2 = 1;
 				this.add_class2 = 1;
-
 				this.dis_num3 = 0;
 				this.dis_num3 = 0;
-
 				// console.log(this.room)
 				// console.log(this.room)
 			},
 			},
 			changeSelect3(e) {
 			changeSelect3(e) {