uniapp 微信支付,支付宝支付,公众号H5支付
1,微信支付
uni.requestPayment({
provider: "wxpay",
orderInfo: res.data.data,
success: (res) => {
uni.showToast({
title: "支付成功!",
icon: "none",
duration: 2000
});
},
fail(err) {
uni.showToast({
title: "支付失败!",
icon: "none",
duration: 2000
});
},
complete(com) {
}
});
2,支付宝支付
uni.requestPayment({
provider: 'alipay',
orderInfo: res.data.data.sign,
success(e) {
uni.showToast({
title: "支付成功!",
icon: "none",
duration: 2000
});
},
fail(err) {
uni.showToast({
title: "支付失败!",
icon: "none",
duration: 2000
});
},
complete(com) {
}
});
3,公众号支付
let data = res.data.data;
WeixinJSBridge.invoke('getBrandWCPayRequest', {
"appId": data.appId, //公众号名称,由商户传入
"timeStamp": data.timeStamp, //时间戳
"nonceStr": data.nonceStr, //随机串
"package": data.package, //扩展包
"signType": data.signType, //微信签名方式:MD5
"paySign": data.paySign //微信签名
}, function(respay) {
if (respay.err_msg === "get_brand_wcpay_request:ok") {
that.page = 1;
that.list = [];
that.getData();
} else if (respay.err_msg === "get_brand_wcpay_request:cancel") {
uni.showToast({
title:"取消支付",
icon:"none",
duration:2000
});
that.isClick = true;
} else if (respay.err_msg === "get_brand_wcpay_request:fail") {
uni.showToast({
title:"支付失败",
icon:"none",
duration:2000
})
that.isClick = true;
}
}, function(err) {
uni.showToast({
title:res.data.msg,
icon:"none",
duration:2000
});
});