使用history方式
比較坑吧就不吐槽了,說下實現方式
需要解決問題:
1.因為我的微信支付授權路由是:m.xxxx.com,this.$router.push(‘xxx’)之后經常出現 【微信支付URL未注冊】
2.有三個頁面進入微信支付 分別是【待付款 , 訂單提交 , 訂單詳情】有時頁面經常使用this.$router.push(‘xxx’)會把頁面路徑修改
方案:
1.配置vue路由,這里有點投機,沒有配置子路由
//引入:
import Vue from 'vue'
import Router from 'vue-router'
import wechat from './../src/components/pay/wechat.vue'
//設置
const router = new Router({
mode: 'history',
routes: [
{path: '/paywechat' ,component:wechat, name:'wechat' }, //微信支付
]
})
2.(待付款 , 訂單提交 , 訂單詳情)3個進行支付頁面跳轉支付
window.location.href="/paywechat?orderid="+this.orderid;
3.微信支付頁面使用this.$router.query.orderid 接受訂單ID,當然如果你的傳遞參數比較多寫幾個參數進行傳遞
let id = this.orderid = this.$route.query.orderid;
let id = this.orderid = this.$route.query.orderid;
//判斷是否正確頁面,如果不是講進行刷新頁面
if(this.$route.fullPath.indexOf('/paywechat?orderid=') < 0){
window.location.href="/paywechat?orderid="+id;
}