1.在uniapp的manifest.json文件中勾选
2.支付宝支付代码
uni.request({
method: "POST",
url: this.httpUrl + '5fe',
header: {
'content-type': "application/x-www-form-urlencoded"
},
data: {
user_id:this.user_id,
goods_id:this.goods_id,
pay_way:this.selectIndex,
discounts_id:this.yh_id
},
success: (res) => {
// 调起支付宝
var data = res.data;
uni.requestPayment({
provider: 'alipay', //服务提供商(支付宝)(服务提供商,通过uni.getProvider获取)
orderInfo: data,
success(res) {
uni.showToast({
title: '支付成功',
icon: 'none'
})
setTimeout(function(){
uni.redirectTo({
url:'/pages/pay/peisong'
})
},1000)
},
fail(err) {
this.flag_submit=true
uni.showToast({
title: '支付失败',
icon: 'none'
})
}
});
}
});