//调用微信支付时,需要传一个openId,是用户的openID,是通过wx.login得到的,要保存下来!!!
调支付时,其他的参数,都是后台那边传给我的,包括时间戳,签名,啥的。
这样我传给后台时,时间戳,签名都是一致的!!!!
调用就非常简单了,Taro版的,如下。小程序原生版的,官网有例子,就不搬过来了
let options={}
options.openId=openId
this.props.payWX(options).then((res)=>{
let trade=res.out_trade_no;
Taro.requestPayment({
timeStamp:res.timeStamp,
nonceStr:res.nonceStr,
signType:'MD5',
package:res.package,
paySign:res.paySign,
success(res){
Taro.showToast({
title:'支付成功',
icon:'none',
duration:1000
})
},
fail(res){
Taro.showToast({
title:'支付失败',
icon:'none',
duration:1000
})
}
})
})