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

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

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