记录一下uni-app公众号里边的支付
大多数的逻辑都是后台请求的东西,这里记录一下前端需要做的:
1.调用后台的接口把支付所需要的数据请求过来:
async getPayMessage(){
let[err,res] = await this.$http.get("Weixin/wxpayapi/" + this.OrderNo,{},{token:true})
this.$http.tokenOver(res.data.Code)
// console.log(res.data.Data)
if(res.data.Code == 200){
this.Detail = res.data.Data
}else if(res.data.Code == 400){
uni.showToast({ title: res.data.Message, icon:"none" })
}
},
2.做支付:
// 立即支付
async handleClickPay(){
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
"appId":this.Detail.AppId, //公众号名称,由商户传入
"timeStamp":this.Detail.TimeStamp, //时间戳,自1970年以来的秒数
"nonceStr":this.Detail.NonceStr, //随机串
"package":this.Detail.Package,
"signType":"MD5", //微信签名方式:
"paySign":this.Detail.PaySign //微信签名
},
function(res){
if(res.err_msg == "get_brand_wcpay_request:ok" ){
uni.reLaunch({
url:'/pages/buy-goodsList/buy-goodsList?payPage=1',
})
// 使用以上方式判断前端返回,微信团队郑重提示:
//res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
}
});
}
记录比较简略 看不懂可以评论一下 我做修改