gaoxs
5 years ago
9 changed files with 62 additions and 28 deletions
@ -1,20 +1,47 @@ |
|||||||
|
import { getProvider } from "@/utils"; |
||||||
|
|
||||||
// 支付模块
|
// 支付模块
|
||||||
export const weappPay = (option) => { |
export const weappPay = (option) => { |
||||||
return new Promise((resolve, reject) => { |
return new Promise((resolve, reject) => { |
||||||
// 吊起微信支付
|
// 吊起微信支付
|
||||||
uni.requestPayment({ |
getProvider().then(provider => { |
||||||
...option, |
let orderInfo = { |
||||||
timeStamp: option.timeStamp + '', |
...option, |
||||||
success: (success) => { |
timeStamp: option.timestamp + '', |
||||||
uni.showToast({ |
|
||||||
title: '支付成功', icon: 'success', duration: 2000 |
|
||||||
}); |
|
||||||
resolve(success) |
|
||||||
}, |
|
||||||
fail: (error) => { |
|
||||||
uni.showToast({ title: '支付失败', icon: 'none', duration: 2000 }); |
|
||||||
reject(error) |
|
||||||
} |
} |
||||||
|
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) |
||||||
|
} |
||||||
|
}) |
||||||
}) |
}) |
||||||
}) |
}) |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue