|
|
|
|
@ -119,18 +119,18 @@
|
|
|
|
|
import RPC from "@/utils/request";
|
|
|
|
|
|
|
|
|
|
const authStore = useAuthStore();
|
|
|
|
|
const userStore = useUserStore();
|
|
|
|
|
|
|
|
|
|
const memberInfo = ref({})
|
|
|
|
|
const getMemberInfo = () => {
|
|
|
|
|
uni.showLoading();
|
|
|
|
|
RPC.post('/membership/user/info', {
|
|
|
|
|
user_id: userStore.userInfo.id
|
|
|
|
|
}).then(res => {
|
|
|
|
|
memberInfo.value = res || {}
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
uni.hideLoading();
|
|
|
|
|
})
|
|
|
|
|
const userStore = useUserStore();
|
|
|
|
|
|
|
|
|
|
const memberInfo = ref({})
|
|
|
|
|
const getMemberInfo = () => {
|
|
|
|
|
uni.showLoading();
|
|
|
|
|
RPC.post('/membership/user/info', {
|
|
|
|
|
user_id: userStore.userInfo.id
|
|
|
|
|
}).then(res => {
|
|
|
|
|
memberInfo.value = res || {}
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
uni.hideLoading();
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 响应式数据
|
|
|
|
|
@ -139,7 +139,7 @@
|
|
|
|
|
const customAmount = ref('');
|
|
|
|
|
const selectedPayment = ref('wxpay');
|
|
|
|
|
const recharging = ref(false);
|
|
|
|
|
const showAlipay = ref(true);
|
|
|
|
|
const showAlipay = ref(true);
|
|
|
|
|
const isWechat = ref(false)
|
|
|
|
|
|
|
|
|
|
// 充值金额选项
|
|
|
|
|
@ -217,13 +217,13 @@
|
|
|
|
|
// #ifdef MP-WEIXIN
|
|
|
|
|
// 微信小程序环境,隐藏支付宝选项
|
|
|
|
|
showAlipay.value = false;
|
|
|
|
|
isWechat.value = true;
|
|
|
|
|
isWechat.value = true;
|
|
|
|
|
selectedPayment.value = 'wxpay';
|
|
|
|
|
// #endif
|
|
|
|
|
|
|
|
|
|
// #ifdef H5
|
|
|
|
|
// H5环境,显示所有支付选项
|
|
|
|
|
showAlipay.value = true;
|
|
|
|
|
showAlipay.value = true;
|
|
|
|
|
selectedPayment.value = 'alipay';
|
|
|
|
|
// #endif
|
|
|
|
|
};
|
|
|
|
|
@ -258,37 +258,12 @@
|
|
|
|
|
|
|
|
|
|
// #ifdef H5
|
|
|
|
|
// H5微信支付
|
|
|
|
|
if (typeof WeixinJSBridge !== 'undefined') {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
WeixinJSBridge.invoke('getBrandWCPayRequest', {
|
|
|
|
|
appId: orderInfo.appId,
|
|
|
|
|
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;
|
|
|
|
|
window.location.href = payUrl;
|
|
|
|
|
return {
|
|
|
|
|
success: true,
|
|
|
|
|
redirect: true
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
const payUrl = orderInfo.h5_url; // 后端返回的H5支付链接
|
|
|
|
|
window.location.href = payUrl;
|
|
|
|
|
return {
|
|
|
|
|
success: true,
|
|
|
|
|
redirect: true,
|
|
|
|
|
};
|
|
|
|
|
// #endif
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@ -356,7 +331,7 @@
|
|
|
|
|
// 调用后端创建充值订单API
|
|
|
|
|
const orderNum = await RPC.post('/wallet/recharge', {
|
|
|
|
|
user_id: userStore.userInfo.id,
|
|
|
|
|
amount_cents: finalAmount.value * 100,
|
|
|
|
|
amount_cents: finalAmount.value * 100,
|
|
|
|
|
pay_channel: selectedPayment.value
|
|
|
|
|
})
|
|
|
|
|
console.log('orderNum', orderNum)
|
|
|
|
|
@ -398,9 +373,9 @@
|
|
|
|
|
});
|
|
|
|
|
console.log('orderResult', orderResult)
|
|
|
|
|
paymentResult = await wechatPay(orderResult);
|
|
|
|
|
} else if (selectedPayment.value === 'alipay') {
|
|
|
|
|
const orderResult = await RPC.post('/membership/order/pay_by_alipay', {
|
|
|
|
|
order_no: orderNum.order_no
|
|
|
|
|
} else if (selectedPayment.value === 'alipay') {
|
|
|
|
|
const orderResult = await RPC.post('/membership/order/pay_by_alipay', {
|
|
|
|
|
order_no: orderNum.order_no
|
|
|
|
|
})
|
|
|
|
|
uni.showLoading({
|
|
|
|
|
title: '正在跳转支付宝...'
|
|
|
|
|
@ -428,9 +403,9 @@
|
|
|
|
|
|
|
|
|
|
// 重置选择
|
|
|
|
|
selectedAmount.value = 0;
|
|
|
|
|
customAmount.value = '';
|
|
|
|
|
// setTimeout(() => {
|
|
|
|
|
// getMemberInfo()
|
|
|
|
|
customAmount.value = '';
|
|
|
|
|
// setTimeout(() => {
|
|
|
|
|
// getMemberInfo()
|
|
|
|
|
// },1000)
|
|
|
|
|
|
|
|
|
|
// 延迟返回上一页
|
|
|
|
|
@ -515,7 +490,7 @@
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
onShow(() => {
|
|
|
|
|
handlePaymentCallback();
|
|
|
|
|
handlePaymentCallback();
|
|
|
|
|
getMemberInfo()
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|