提交 0e904a16 authored 作者: 王鹏飞's avatar 王鹏飞

chore: 购买成功后刷新课程列表

上级 43222d5e
......@@ -4,6 +4,7 @@ import { getDateTime } from '@/utils'
import { getOrderList } from '../api'
import { useDevice } from '@/composables/useDevice'
import { useShopStore } from '@/stores/shop'
import { useUserStore } from '@/stores/user'
interface Props {
id: string
......@@ -22,8 +23,12 @@ async function getOrder() {
getOrderList({ order_detail_id: orderId.value })
.then(res => {
order.value = res.data[0]
// 未支付,返回支付页面
if (order.value?.order_status !== '4') {
if (order.value?.order_status === '4') {
// 支付成功
// 刷新已购买的课程列表
useUserStore().getCourse()
} else {
// 未支付,返回支付页面
router.replace(`/shop/pay/${props.id}`)
}
})
......
......@@ -26,17 +26,17 @@ export const useUserStore = defineStore({
actions: {
async getUser() {
const res = await getUser()
try {
this.courses = await getBuyShop()
} catch (error) {
console.log(error)
}
await this.getCourse()
this.user = res.data
},
async logout() {
await logout()
this.user = null
},
async getCourse() {
this.courses = await getBuyShop()
}
}
})
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论