//獲取微信支付接口信息
? ? ? ? ? ? ? ? ? ? http.post(`${api.api}/config`,
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? url: location.href.split("#")[0]//截取地址欄地址傳到后臺
? ? ? ? ? ? ? ? ? ? })
? ? ? ? ? ? ? ? ? ? .then((res) => {
? ? ? ? ? ? ? ? ? ? ? ? //獲取后臺返回的參數(shù)
? ? ? ? ? ? ? ? ? ? ? ? this.appId = res.data.appId
? ? ? ? ? ? ? ? ? ? ? ? this.nonce = res.data.nonce
? ? ? ? ? ? ? ? ? ? ? ? this.signature = res.data.signature
? ? ? ? ? ? ? ? ? ? ? ? this.timestamp = res.data.timestamp
? ? ? ? ? ? ? ? ? ? ? ? //調(diào)取微信官方config接口
? ? ? ? ? ? ? ? ? ? ? ? wx.config({
? ? ? ? ? ? ? ? ? ? ? ? debug: false, // 開啟調(diào)試模式,調(diào)用的所有api的返回值會在客戶端alert出來梯刚,若要查看傳入的參數(shù)手蝎,可以在pc端打開锄贷,參數(shù)信息會通過log打出吧碾,僅在pc端時才會打印健提。
? ? ? ? ? ? ? ? ? ? ? ? appId: this.appId, // 必填赤套,公眾號的唯一標識
? ? ? ? ? ? ? ? ? ? ? ? timestamp: this.timestamp, // 必填穿稳,生成簽名的時間戳
? ? ? ? ? ? ? ? ? ? ? ? nonceStr: this.nonce, // 必填,生成簽名的隨機串
? ? ? ? ? ? ? ? ? ? ? ? signature: this.signature,// 必填档叔,簽名
? ? ? ? ? ? ? ? ? ? ? ? jsApiList: ['chooseWXPay'] // 必填,需要使用的JS接口列表
? ? ? ? ? ? ? ? ? ? });
? ? ? ? ? ? ? ? ? ? })
? ? ? ? ? ? ? ? ? ? .catch((error) => {
? ? ? ? ? ? ? ? ? ? ? ? console.log(error);
? ? ? ? ? ? ? ? ? ? });
? ? ? ? ? ? ? ? ? ? //調(diào)取后臺接口蒸绩,獲取下單信息衙四,并用wx.ready調(diào)取微信支付方法
? ? ? ? ? ? ? ? ? ? var id = JSON.parse(localStorage.getItem('token')).id
? ? ? ? ? ? ? ? ? ? http.get(`${api.api}/orders?id=${id}&money=${this.total*100}&type=${0}&count=${this.date}&acount=${this.count}`)
? ? ? ? ? ? ? ? ? ? .then((res) => {
? ? ? ? ? ? ? ? ? ? ? ? console.log(res)
? ? ? ? ? ? ? ? ? ? ? ? wx.ready(()=>{
? ? ? ? ? ? ? ? ? ? ? ? ? ? wx.chooseWXPay({
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? timestamp: res.data.timeStamp, // 支付簽名時間戳,注意微信jssdk中的所有使用timestamp字段均為小寫患亿。但最新版的支付后臺生成簽名使用的timeStamp字段名需大寫其中的S字符
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? nonceStr: res.data.nonceStr, // 支付簽名隨機串传蹈,不長于 32 位
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? package: res.data.package, // 統(tǒng)一支付接口返回的prepay_id參數(shù)值,提交格式如:prepay_id=\*\*\*)
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? signType: 'MD5', // 簽名方式步藕,默認為'SHA1'惦界,使用新版支付需傳入'MD5'
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? paySign: res.data.paySign, // 支付簽名
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? success:? (res) => {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // 支付成功后的回調(diào)函數(shù)
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? this.$router.push({path:'/creditcard'})
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? ? ? });
? ? ? ? ? ? ? ? ? ? ? ? })
? ? ? ? ? ? ? ? ? ? })
? ? ? ? ? ? ? ? ? ? .catch((error) => {
? ? ? ? ? ? ? ? ? ? ? ? console.log(error);
? ? ? ? ? ? ? ? ? ? });