测试支付功能

This commit is contained in:
gaoxs
2020-04-23 19:55:05 +08:00
parent 2171e9f7bd
commit c66a90ed50
9 changed files with 62 additions and 28 deletions

View File

@ -71,6 +71,7 @@ export function delOrderHandle(orderId) {
}
export function payOrderHandle(orderId, type, from) {
console.log(orderId, type, from, '支付')
return new Promise((resolve, reject) => {
uni.showLoading({ title: '加载中' })
payOrder(orderId, type, from)
@ -97,6 +98,10 @@ export function payOrderHandle(orderId, type, from) {
weappPay(data.result.jsConfig).then(res => {
resolve(data);
});
case "WECHAT_APP_PAY":
weappPay(data.result.jsConfig).then(res => {
resolve(data);
});
}
})
.catch(err => {

View File

@ -1,20 +1,47 @@
import { getProvider } from "@/utils";
// 支付模块
export const weappPay = (option) => {
return new Promise((resolve, reject) => {
// 吊起微信支付
uni.requestPayment({
...option,
timeStamp: option.timeStamp + '',
success: (success) => {
uni.showToast({
title: '支付成功', icon: 'success', duration: 2000
});
resolve(success)
},
fail: (error) => {
uni.showToast({ title: '支付失败', icon: 'none', duration: 2000 });
reject(error)
getProvider().then(provider => {
let orderInfo = {
...option,
timeStamp: option.timestamp + '',
}
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)
}
})
})
})
}