1.首先在app模块勾选
2.调用后端接口,把订单信息传到后端接口获取订单号
3. 拿着后端返回的订单号调用后端的支付接口,然后会返回一个类似于这样的订单信息字符串
app_id=2015052600090779&biz_content=%7B%22timeout_express%22%3A%2230m%22%2C%22seller_id%22%3A%22%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%2C%22total_amount%22%3A%220.02%22%2C%22subject%22%3A%221%22%2C%22body%22%3A%22%E6%88%91%E6%98%AF%E6%B5%8B%E8%AF%95%E6%95%B0%E6%8D%AE%22%2C%22out_trade_no%22%3A%22314VYGIAGG7ZOYY%22%7D&charset=utf-8&method=alipay.trade.app.pay&sign_type=RSA2×tamp=2016-08-15%2012%3A12%3A15&version=1.0&sign=MsbylYkCzlfYLy9PeRwUUIg9nZPeN9SfXPNavUCroGKR5Kqvx0nEnd3eRmKxJuthNUx4ERCXe552EV9PfwexqW%2B1wbKOdYtDIb4%2B7PL3Pc94RZL0zKaWcaY3tSL89%2FuAVUsQuFqEJdhIukuKygrXucvejOUgTCfoUdwTi7z%2BZzQ%3D
4. 最后再调用手机支付宝完成支付
uni.getProvider({
service: 'payment',
success: function (res) {
console.log(res.provider)
if (~res.provider.indexOf('alipay')) {
uni.requestPayment({
"provider": "alipay", //固定值为"alipay"
"orderInfo": orderInfo, //此处为后端返回的订单信息字符串
success: function (res) {
var rawdata = JSON.parse(res.rawdata);
console.log("支付成功");
},
fail: function (err) {
console.log('支付失败:' + JSON.stringify(err));
}
});
}
}
});
大致就是调用两个后端接口,然后拿着后端返回的信息去调取支付宝支付