Files
yshopb2c-uniapp/libs/wechat.js

48 lines
1.3 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-23 19:55:05 +08:00
getProvider().then(provider => {
let orderInfo = {
...option,
timeStamp: option.timestamp + '',
2020-03-15 13:59:43 +08:00
}
2020-04-23 19:55:05 +08:00
console.log({
provider: provider,
signType: "MD5",
timeStamp: orderInfo.timestamp,
nonceStr: orderInfo.noncestr,
package: orderInfo.prepayid,
signType: "MD5",
paySign: orderInfo.sign,
orderInfo,
},'发起支付')
// 调用登录接口
uni.requestPayment({
provider: provider,
signType: "MD5",
timeStamp: orderInfo.timeStamp,
nonceStr: orderInfo.noncestr,
package: orderInfo.prepayid,
signType: "MD5",
paySign: orderInfo.sign,
orderInfo,
success: (success) => {
console.log(error)
uni.showToast({
title: '支付成功', icon: 'success', duration: 2000
});
resolve(success)
},
fail: (error) => {
console.log(error)
uni.showToast({ title: '支付失败', icon: 'none', duration: 2000 });
reject(error)
}
})
2020-03-15 13:59:43 +08:00
})
})
}