xuqiaoying 2 жил өмнө
parent
commit
44bad979f1

+ 4 - 10
pages/index/index.vue

@@ -337,22 +337,16 @@ export default {
 			}
 			console.log('获取的optObj:', this.optObj);
 			uni.setStorageSync('h5_code', this.optObj.code)
-			// this.OfficialLogin()
+			this.OfficialLogin()
 		} else {
+			console.log('没有code', uni.getStorageSync('h5_code'));
 			// 没有code,就重定向到地址https://www.xyyxt.net?ask_type=h.xyyxt.net 去获取code,授权后就会把code带上然后访问域名,就拿到code了
 			if (!uni.getStorageSync('h5_code')) {
-				console.log('跳转');
-				// location.replace(
-				// 	"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx6f48f721d18244eb" +
-				// 	"&redirect_uri=" +
-				// 	encodeURIComponent('https://www.xyyxt.net/?ask_type=h.xyyxt.net') +
-				// 	"&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect"
-				// )
 				location.replace('https://www.xyyxt.net/?ask_type=h.xyyxt.net')
 				return
 			} else {
 				this.$set(this.optObj, 'code', uni.getStorageSync('h5_code'))
-				// this.OfficialLogin()
+				this.OfficialLogin()
 			}
 		}
 		// #endif
@@ -439,7 +433,7 @@ export default {
 				url: '/app/common/gzh_login',
 				method: 'post',
 				data: {
-					code: this.optObj.code || '011j2t0w3R1oNZ2Vh44w3sgS251j2t0B'
+					code: this.optObj.code
 				},
 				noToken: true
 			}).then((res) => {

+ 8 - 7
pages2/order/confirm_pay.vue

@@ -246,6 +246,7 @@ export default {
 		},
 		h5_wxpay(data) {
 			console.log('====调起支付状态', data);
+			let self = this
 			function onBridgeReady() {
 				// 加载框
 				WeixinJSBridge.invoke(
@@ -259,20 +260,20 @@ export default {
 					},
 					function(res) {
 						// 判断支付状态
-						console.log('支付状态',res)
+						console.log('支付状态',res, 'this:', this, self)
 						if (res.err_msg === 'get_brand_wcpay_request:ok') {
-							this.$u.toast('支付成功')
+							self.$u.toast('支付成功')
 							uni.hideLoading()
-							this.btnNo = false
+							self.btnNo = false
 							uni.redirectTo({
-								url: `/pages2/order/confirm_success?sn=${data.orderSn}&isBk=${this.isBK}`
+								url: `/pages2/order/confirm_success?sn=${data.orderSn}&isBk=${self.isBK}`
 							});
 						} else if (res.err_msg === 'get_brand_wcpay_request:cancel') {
-							this.$u.toast('取消支付')
+							self.$u.toast('取消支付')
 						} else {
 							uni.hideLoading()
-							this.btnNo = false
-							this.$u.toast('支付失败')
+							self.btnNo = false
+							self.$u.toast('支付失败')
 						}
 					}
 				)

+ 6 - 4
pages2/order/index.vue

@@ -314,6 +314,8 @@ export default {
 			// #endif
 		},
 		h5_wxpay(data) {
+			console.log('调起支付状态1', data);
+			let self = this
 			function onBridgeReady() {
 				// 加载框
 				WeixinJSBridge.invoke(
@@ -327,16 +329,16 @@ export default {
 					},
 					function(res) {
 						// 判断支付状态
-						console.log('支付状态',res)
+						console.log('支付状态',res, 'this:', this, self)
 						if (res.err_msg === 'get_brand_wcpay_request:ok') {
-							this.$u.toast('支付成功')
+							self.$u.toast('支付成功')
 							uni.redirectTo({
 							    url: '/pages2/order/confirm_success?sn='+data.orderSn
 							});
 						} else if (res.err_msg === 'get_brand_wcpay_request:cancel') {
-							this.$u.toast('取消支付')
+							self.$u.toast('取消支付')
 						} else {
-							this.$u.toast('支付失败')
+							self.$u.toast('支付失败')
 						}
 					}
 				)