Files
yshopb2c-uniapp/libs/wechat.js

41 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-04-23 19:55:05 +08:00
import { getProvider } from "@/utils";
2020-03-15 13:59:43 +08:00
// 支付模块
export const weappPay = (option) => {
return new Promise((resolve, reject) => {
2020-04-13 17:48:31 +08:00
// 吊起微信支付
2020-04-24 18:03:29 +08:00
// getProvider('payment').then(provider => {
let orderInfo = {
appid: option.appid,
noncestr: option.noncestr,
package: option.package,
partnerid: option.partnerid,
prepayid: option.prepayid,
sign: option.sign,
timestamp: option.timestamp + '',
}
// 调用登录接口
uni.requestPayment({
provider: 'wxpay',
...option,
timestamp: orderInfo.timestamp,
orderInfo,
success: (success) => {
console.log(success)
uni.showToast({
title: '支付成功', icon: 'success', duration: 5000
});
resolve(success)
},
fail: (error) => {
console.log(error)
if (error.errMsg == 'requestPayment:fail cancel') {
uni.showToast({ title: '已取消支付', icon: 'none', duration: 5000 });
}
reject(error)
2020-03-15 13:59:43 +08:00
}
})
2020-04-24 18:03:29 +08:00
// })
2020-03-15 13:59:43 +08:00
})
}