diff --git a/src/views/openpage/onlinePay.vue b/src/views/openpage/onlinePay.vue index 0ef75b6..e3bb109 100644 --- a/src/views/openpage/onlinePay.vue +++ b/src/views/openpage/onlinePay.vue @@ -148,12 +148,19 @@ export default { }; }, created() { - this.reset(); - const ua = window.navigator.userAgent.toLowerCase(); - if (!ua.match(/MicroMessenger/i)) { - this.isWx=false; + const params = new URLSearchParams(window.location.search); + let code=params.get('code'); + let state=params.get('code'); + if (code) { + this.requestPayment(code,state); + }else{ + this.reset(); + const ua = window.navigator.userAgent.toLowerCase(); + if (!ua.match(/MicroMessenger/i)) { + this.isWx=false; + } + this.initPayOrder(); } - this.initPayOrder(); }, methods: { // 表单重置 @@ -254,18 +261,9 @@ export default { }); }, handleWeixinPay(){ - const params = new URLSearchParams(window.location.search); - let code=params.get('code'); - let state=params.get('code'); - // 如果是微信回调,拉起微信支付 - if (code) { - this.requestPayment(code,state); - } - else{ - this.billNo = this.$route.query.bid; - const authUrl = this.generateAuthUrl("https://oms.tanex56.com/onlinePay","snsapi_base",this.billNo); - window.location.href = authUrl; - } + this.billNo = this.$route.query.bid; + const authUrl = this.generateAuthUrl("https://oms.tanex56.com/onlinePay","snsapi_base",this.billNo); + window.location.href = authUrl; }, requestPayment(code,state) { this.loadingVisible = true;