相关文档:uni.requestPayment(OBJECT) | uni-app官网
示例代码:
javascript
import qs from 'qs'
async aliPay(){
const { provider } = await uni.getProvider({ service:'payment' })
if(provider.includes('alipay')){
uni.request({
url:'后端接口地址',
data:{ //传参 },
success(res){
let data = res.data.data
uni.requestPayment({
provider: 'alipay',
orderInfo: qs.stringify(data), //支付宝
//orderInfo: data, //支付宝
success: function (res) {
console.log('success:' + JSON.stringify(res));
},
fail: function (err) {
console.log('fail:' + JSON.stringify(err));
}
});
}
})
}
}