Browse Source

Accept Merge Request #3: (master-zhang -> master)
Merge Request: 等待appid发起jsapi支付

Created By: @程志平
Accepted By: @程志平
URL: https://chuanghaikeji.coding.net/p/smarCampus/d/waterElectricityMinApp/git/merge/3

程志平 5 years ago
parent
commit
b4ab6cdbd1
2 changed files with 34 additions and 6 deletions
  1. 6 4
      pages/index/index.vue
  2. 28 2
      pages/jiaofei/jiaofei.vue

+ 6 - 4
pages/index/index.vue

@@ -38,13 +38,14 @@
 				showLogin: true,
 				appkey: '5AA49F3E4CACA380',
 				sub_appid: '1015730314_1941301045',
-				appid: 'wx2fc3f45732fae5d3', // 获取用户信息
+				// appid: 'wx2fc3f45732fae5d3', // 获取用户信息
+				appid: 'wxd6f090391d410534 ', // 获取用户信息
 				ocode: '1015730314', // 获取用户信息
 				app_secret: '58D34C81D82B35179ED896C4362B0FC0', // 获取用户信息
 				// 用于传给后代页面
-				appid_pass: 'wxd6f090391d410534', // 传给后代页面,用于唤起支付
-				ocode_pass: '1609853253', // 传给后代页面,用于唤起支付
-				app_secret_pass: 'eb99fffa11caa585fcf7c97c891a5e1f', // 传给后代页面,用于唤起支付
+				// appid_pass: 'wxd6f090391d410534', // 传给后代页面,用于唤起支付
+				// ocode_pass: '1609853253', // 传给后代页面,用于唤起支付
+				// app_secret_pass: 'eb99fffa11caa585fcf7c97c891a5e1f', // 传给后代页面,用于唤起支付
 				wxcode: '',
 				access_token: '',
 				access_token_for_amount: '', // 获取到应用有效凭证
@@ -200,6 +201,7 @@
 						this.userinfo.app_secret = this.app_secret_pass
 						this.userinfo.ocode = this.ocode_pass
 						this.userinfo.access_token = this.access_token
+						// console.log(this.userinfo)
 						// console.log(this.access_token)
 						// 存储用户信息
 						uni.setStorageSync('userinfo_storage_key', this.userinfo)

+ 28 - 2
pages/jiaofei/jiaofei.vue

@@ -75,7 +75,7 @@
 				dom: '', //房间号
 				campus: '', //校区
 				access_token: '',
-				sub_appid: '1015730314_1941301045', //商户号
+				sub_appid: '', //商户号
 				order_id: '202107151048111111', //订单号
 				pay_info: '',
 				item: {},
@@ -141,6 +141,10 @@
 						this.roomSelect = this.campus + this.dom
 
 						this.add_class = 1;
+						
+						this.order_id = get_order_id();
+						
+						this.sub_appid = this.userinfo.sub_appid;
 
 						// this.sub_appid = this.userinfo.sub_appid
 
@@ -326,7 +330,7 @@
 						'sub_appid': this.sub_appid,
 						'user_id': this.card_number,
 						"order_id": this.order_id,
-						"amount": this.addMoney * 100,
+						"amount": this.addMoney,
 					}
 				});
 				// console.log(res)
@@ -378,6 +382,28 @@
 
 		},
 	}
+	
+	function get_order_id() {
+		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()
+	
+		month = month > 9 ? month : '0' + month
+		day = day > 9 ? day : '0' + day
+		second = second > 9 ? second : '0' + second
+		// 小于4位数,前补0
+		// millisecond = millisecond < 1000 ? '00' + millisecond : millisecond
+		// 小于4位数,前补随机数
+		millisecond = millisecond < 1000 ? Math.floor(Math.random() * 999 + 1000) + millisecond : millisecond
+	
+		return `${year}${month}${day}${hour}${minute}${second}${millisecond}`
+	}
 </script>
 
 <style>