|
|
|
@ -232,32 +232,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
// #ifdef H5
|
|
|
|
// #ifdef H5
|
|
|
|
// H5微信支付
|
|
|
|
// H5微信支付
|
|
|
|
if (typeof WeixinJSBridge !== "undefined") {
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
|
|
|
WeixinJSBridge.invoke(
|
|
|
|
|
|
|
|
"getBrandWCPayRequest", {
|
|
|
|
|
|
|
|
appId: 'wxc504638e03981812',
|
|
|
|
|
|
|
|
timeStamp: orderInfo.timeStamp,
|
|
|
|
|
|
|
|
nonceStr: orderInfo.nonceStr,
|
|
|
|
|
|
|
|
package: orderInfo.package,
|
|
|
|
|
|
|
|
signType: orderInfo.signType,
|
|
|
|
|
|
|
|
paySign: orderInfo.paySign,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
(res) => {
|
|
|
|
|
|
|
|
if (res.err_msg === "get_brand_wcpay_request:ok") {
|
|
|
|
|
|
|
|
resolve({
|
|
|
|
|
|
|
|
success: true,
|
|
|
|
|
|
|
|
data: res
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else if (res.err_msg === "get_brand_wcpay_request:cancel") {
|
|
|
|
|
|
|
|
reject(new Error("用户取消支付"));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
reject(new Error("微信支付失败"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// 不在微信环境,跳转到支付页面
|
|
|
|
// 不在微信环境,跳转到支付页面
|
|
|
|
const payUrl = orderInfo.mwebUrl; // 后端返回的H5支付链接
|
|
|
|
const payUrl = orderInfo.mwebUrl; // 后端返回的H5支付链接
|
|
|
|
window.location.href = payUrl;
|
|
|
|
window.location.href = payUrl;
|
|
|
|
@ -265,7 +239,7 @@
|
|
|
|
success: true,
|
|
|
|
success: true,
|
|
|
|
redirect: true
|
|
|
|
redirect: true
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// #endif
|
|
|
|
// #endif
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
@ -287,7 +261,7 @@
|
|
|
|
const alipayPay = async (orderInfo) => {
|
|
|
|
const alipayPay = async (orderInfo) => {
|
|
|
|
// #ifdef H5
|
|
|
|
// #ifdef H5
|
|
|
|
// H5支付宝支付
|
|
|
|
// H5支付宝支付
|
|
|
|
const payUrl = orderInfo.payUrl; // 后端返回的支付宝H5支付链接
|
|
|
|
const payUrl = orderInfo.pay_url; // 后端返回的支付宝H5支付链接
|
|
|
|
window.location.href = payUrl;
|
|
|
|
window.location.href = payUrl;
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
success: true,
|
|
|
|
success: true,
|
|
|
|
@ -353,27 +327,41 @@
|
|
|
|
// };
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
uni.hideLoading();
|
|
|
|
uni.hideLoading();
|
|
|
|
|
|
|
|
let orderResult = {}
|
|
|
|
// 3. 根据支付方式调用对应的支付方法
|
|
|
|
// 3. 根据支付方式调用对应的支付方法
|
|
|
|
let paymentResult;
|
|
|
|
let paymentResult;
|
|
|
|
if (selectedPayment.value === "wxpay") {
|
|
|
|
if (selectedPayment.value === "wxpay") {
|
|
|
|
|
|
|
|
// #ifdef MP-WEIXIN
|
|
|
|
const res = await uni.login({
|
|
|
|
const res = await uni.login({
|
|
|
|
provider: 'weixin'
|
|
|
|
provider: 'weixin'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
const orderResult = await RPC.post('/membership/order/pay_by_wechat_mini', {
|
|
|
|
orderResult = await RPC.post('/membership/order/pay_by_wechat_mini', {
|
|
|
|
code: res.code,
|
|
|
|
code: res.code,
|
|
|
|
"order_no": orderNum.order_no
|
|
|
|
"order_no": orderNum.order_no
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
// #endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// #ifdef H5
|
|
|
|
|
|
|
|
orderResult = await RPC.post('/membership/order/pay_by_wechat_h5', {
|
|
|
|
|
|
|
|
"order_no": orderNum.order_no
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
// #endif
|
|
|
|
uni.showLoading({
|
|
|
|
uni.showLoading({
|
|
|
|
title: "正在跳转微信支付...",
|
|
|
|
title: "正在跳转微信支付...",
|
|
|
|
});
|
|
|
|
});
|
|
|
|
console.log('orderResult', orderResult)
|
|
|
|
console.log('orderResult', orderResult)
|
|
|
|
|
|
|
|
if(1==1) return
|
|
|
|
paymentResult = await wechatPay(orderResult);
|
|
|
|
paymentResult = await wechatPay(orderResult);
|
|
|
|
} else if (selectedPayment.value === "alipay") {
|
|
|
|
} else if (selectedPayment.value === "alipay") {
|
|
|
|
|
|
|
|
orderResult = await RPC.post('/membership/order/pay_by_alipay', {
|
|
|
|
|
|
|
|
"order_no": orderNum.order_no
|
|
|
|
|
|
|
|
})
|
|
|
|
uni.showLoading({
|
|
|
|
uni.showLoading({
|
|
|
|
title: "正在跳转支付宝...",
|
|
|
|
title: "正在跳转支付宝...",
|
|
|
|
});
|
|
|
|
});
|
|
|
|
paymentResult = await alipayPay(orderResult.alipayInfo);
|
|
|
|
console.log('orderResult', orderResult)
|
|
|
|
|
|
|
|
paymentResult = await alipayPay(orderResult);
|
|
|
|
} else if (selectedPayment.value === 'wallet') {
|
|
|
|
} else if (selectedPayment.value === 'wallet') {
|
|
|
|
const res = await showModalAsync({
|
|
|
|
const res = await showModalAsync({
|
|
|
|
title: '确认支付',
|
|
|
|
title: '确认支付',
|
|
|
|
|