http.post(`${api.api}/config `,
{
URL: location.href.split ("#" [0]//Intercept the address bar and pass it to the background.
})
. Then ((RES)= & gt;; {
//Get the parameters returned by the background
this.appId = res.data.appId
this.nonce = res.data.nonce
this . signature = RES . data . signature
this . timestamp = RES . data . timestamp
//Call the official configuration interface of WeChat
wx.config({
Debug: false,//Turn on debugging mode, and the return values of all called APIs will be displayed in the client alarm. If you want to view the incoming parameters, you can open them on the pc side, and the parameter information will be printed through the log, which will only be printed on the pc side.
AppId: this.appId,//required, the unique identifier of the official account of WeChat.
Timestamp: this.timestamp,//required, generates the timestamp of the signature.
Noncaster: this. nonce,//required, generates a signed random string.
Signature: this.Signature,//required, signature
JsApiList: ['chooseWXPay'] // Required, list of JS interfaces to be used.
});
})
. Catch ((Error) =>{
Console.log (error);
});
//Call the background interface to get the order information, and use wx.ready to call the WeChat payment method.
var id = JSON . parse(local storage . getitem(' token '))。 Identification (identification)
http.get(`${api.api}/orders? id = $ { id } & ampmoney = $ { this . total * 100 } & amp; type = $ { 0 } & ampcount = $ { this.date } & ampacount=${this.count} `)
. Then ((RES)= & gt;; {
console.log(res)
wx . ready(()= & gt; {
wx.chooseWXPay({
Timestamp: res.data.timestamp,//Payment signature timestamp. Note that all fields that use timestamps in WeChat jssdk are lowercase. However, the latest version of the timestamp field name used in the payment background generation signature requires an uppercase S character.
Non castr:RES. data. non castr,//payment signature random string, with a length of no more than 32 bits.
Package: res.data.package,//The prepayment _ ID parameter value returned by the unified payment interface, and the submission format is as follows: prepayment _ ID = \ * \ * \ *).
SignType: 'MD5',//signature method, the default is' SHA 1', and the new version needs' MD5' for payment.
PaySign: res.data.paySign,//payment signature
Success:? (RES)= & gt; {
//Callback function after successful payment
This. $ router . push({ path:'/credit card ' })
}
});
})
})
. Catch ((Error) =>{
Console.log (error);
});