uniapp,使用uni.requestPayment,参考uni官方文档
https://uniapp.dcloud.io/api/plugins/payment.html
const requestTask = uni.request({
url: 'https://xxxx.com',//接口数据
method:'POST',
data: {
amount:that.pay.needmoney,
openid: that.oppenid,
},
header: {
'content-type': 'application/x-www-form-urlencoded', //自定义请求头信息
},
success: function(res) {
let jsConfig = res.data.data
console.log(res.data.data)
uni.requestPayment({
provider: 'wxpay',
timeStamp: jsConfig.timeStamp,
appId: jsConfig.appId,
nonceStr: jsConfig.nonceStr,
package: jsConfig.package,
signType: jsConfig.signType,
paySign: jsConfig.paySign,
success: function (res) {
console.log(res)
if (res.errMsg == 'requestPayment:ok') {
uni.navigateTo({
url:'sign_msg?title='+ this.title +'&timeend=' +this.time +'&payment_method='+this.payment_method+'&agentid='+this.agentid+'&activityid='+this.activityid+'&recordid='+this.recordid
})
}else{
console.log('fail:' + JSON.stringify(res));
}
},
fail: function (err) {
uni.showToast({
title:"pay err",
icon:'error'
})
console.log(err)
}
});
},
fail:function(res){
uni.showToast({
title:"url fial",
icon:'error'
})
}
});