Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
mlaj
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2025-06-13 10:12:22 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6336a3a05a1d9f709f7de1b50d61787b74dc532b
6336a3a0
1 parent
34a3c166
feat(课程详情页): 添加未登录用户购买课程时的登录检查
在立即购买操作前检查用户是否登录,未登录则跳转至登录页并提示
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
0 deletions
src/views/courses/CourseDetailPage.vue
src/views/courses/CourseDetailPage.vue
View file @
6336a3a
...
...
@@ -213,6 +213,7 @@
import { ref, onMounted, defineComponent, h } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useCart } from '@/contexts/cart'
import { useAuth } from '@/contexts/auth'
import { useTitle } from '@vueuse/core';
import { showToast } from 'vant';
import { formatDate } from '@/utils/tools'
...
...
@@ -230,6 +231,7 @@ useTitle($route.meta.title);
const route = useRoute()
const router = useRouter()
const { currentUser } = useAuth()
const course = ref(null)
const lecturers = ref([])
...
...
@@ -311,6 +313,13 @@ const rightContent = h(RightContent)
// 立即购买操作
const handlePurchase = () => {
// 检查用户是否已登录
if (!currentUser.value) {
showToast('请先登录')
router.replace({ path: '/login', query: { redirect: $route.fullPath } })
return
}
if (course.value) {
addToCart({
id: course.value.id,
...
...
Please
register
or
login
to post a comment