会员购买
This commit is contained in:
parent
cb4c207ca8
commit
6f73e43950
|
|
@ -86,6 +86,7 @@ import { ref, computed, onMounted } from 'vue'
|
|||
import { useUserStore } from '@/store/user.js'
|
||||
import { getMemberInfo } from '@/api/member.js'
|
||||
import { createOrder } from '@/api/order.js'
|
||||
import { queryOrderStatus } from '@/api/pay.js'
|
||||
import { getFullImageUrl } from '@/utils/image.js'
|
||||
import Loading from '@/components/Loading/index.vue'
|
||||
|
||||
|
|
@ -249,6 +250,7 @@ export default {
|
|||
}
|
||||
|
||||
const paymentParams = orderRes.data.payParams
|
||||
const orderNo = orderRes.data.orderNo
|
||||
console.log('支付参数:', paymentParams)
|
||||
|
||||
if (!paymentParams) {
|
||||
|
|
@ -263,17 +265,38 @@ export default {
|
|||
console.log('调起微信支付...')
|
||||
await requestPayment(paymentParams)
|
||||
|
||||
// 支付成功,更新会员状态
|
||||
userStore.setMemberStatus(true, selectedTier.value)
|
||||
// 支付成功后,主动查询订单状态(触发后端去微信查询并处理)
|
||||
uni.showLoading({ title: '处理中...' })
|
||||
|
||||
// 主动查询订单支付状态,后端会去微信查询并开通会员
|
||||
console.log('查询订单状态:', orderNo)
|
||||
const statusRes = await queryOrderStatus(orderNo)
|
||||
console.log('订单状态:', statusRes)
|
||||
|
||||
// 从服务器刷新用户信息(包括会员状态)
|
||||
await userStore.refreshFromServer()
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
uni.showToast({
|
||||
title: '开通成功',
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
if (userStore.isMember) {
|
||||
uni.showToast({
|
||||
title: '开通成功',
|
||||
icon: 'success'
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
} else {
|
||||
// 如果还没成为会员,可能是回调还没处理完,提示用户
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '支付已完成,会员权益正在开通中,请稍后查看',
|
||||
showCancel: false,
|
||||
success: () => {
|
||||
uni.navigateBack()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('购买失败:', error)
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@
|
|||
"CertPath": "apiclient_cert.pem",
|
||||
"PlatformCertPath": "pub_key.pem",
|
||||
"PlatformCertSerialNo": "PUB_KEY_ID_0117379432252026012200382382002003",
|
||||
"NotifyUrl": "https://app.zpc-xy.com/xyqj/api/pay/notify"
|
||||
"NotifyUrl": "https://app.zpc-xy.com/xyqj/api/app/pay/notify"
|
||||
},
|
||||
"Storage": {
|
||||
"Provider": "TencentCos",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user