更新:游客模式、我的湖分、我的证书

This commit is contained in:
2025-12-09 14:28:02 +08:00
parent 79aa8e3fe6
commit 66b004d6bf
18 changed files with 702 additions and 60 deletions

View File

@@ -211,7 +211,9 @@ import { commonApi } from '@/api/modules/common'
import { getNotchHeight } from '@/utils/system'
// import { onPageJump } from '@/utils'
import type { IMedicalTag, ICourse, INews } from '@/types/course'
import { useUserStore } from '@/stores/user'
const userStore = useUserStore()
const { t } = useI18n()
// 系统信息
@@ -239,18 +241,21 @@ const selectedFirstLevel = ref<number>('医学') // 当前选中的一级分类
* 学科点击处理
*/
const handleFirstLevelClick = (item: string) => {
selectedFirstLevel.value = item
switch (item) {
case '医学':
getMedicalTags()
break
case '心理学':
getSoulCateList()
break
case '国学':
getSociologyCateList()
break
}
getPrompt()
if(!userStore.token) return
selectedFirstLevel.value = item
switch (item) {
case '医学':
getMedicalTags()
break
case '心理学':
getSoulCateList()
break
case '国学':
getSociologyCateList()
break
}
}
/**
* 医学
@@ -326,15 +331,19 @@ const getSociologyCateList = async () => {
* 终极分类点击处理
*/
const curseClickJump = (item: IMedicalTag) => {
uni.navigateTo({
url: `/pages/course/list/category?id=${item.id}&title=${item.title}&pid=${item.pid}&subject=${selectedFirstLevel.value}`
})
getPrompt()
if(!userStore.token) return
uni.navigateTo({
url: `/pages/course/list/category?id=${item.id}&title=${item.title}&pid=${item.pid}&subject=${selectedFirstLevel.value}`
})
}
/**
* 页面跳转统一处理
*/
const onPageJump = (url: string, id?: number, title?: string) => {
getPrompt()
if(!userStore.token) return
let targetUrl = url
if (id !== undefined) {
targetUrl += `?id=${id}`
@@ -381,9 +390,12 @@ const getNewsList = async () => {
* 新闻点击处理
*/
const newsClick = (item: INews) => {
uni.navigateTo({
url: `/pages/news/details?newsId=${item.id}&url=${item.url}&type=${item.type}`
})
getPrompt()
if(!userStore.token) return
uni.navigateTo({
url: `/pages/news/details?newsId=${item.id}&url=${item.url}&type=${item.type}`
})
}
// 精彩试听
@@ -406,31 +418,59 @@ const getTryListenList = async () => {
}
}
/**
* 登录提示语
*/
const getPrompt = () => {
if(!userStore.token) {
uni.showModal({
title: '提示',
content: '请先登录后访问该页面',
confirmText: '去登录',
success: (res) => {
console.log(res, 'res');
if (res.confirm) uni.navigateTo({
url: '/pages/login/login'
});
}
});
}
}
/**
* 统一请求所有数据
*/
const requestAll = async () => {
getLearnCourse()
getMedicalTags()
getTryListenList()
getNewsList()
if(userStore.token){
getLearnCourse()
}
getMedicalTags()
getTryListenList()
getNewsList()
}
/**
* 页面挂载
*/
onMounted(() => {
if(!userStore.token) {
uni.navigateTo({
url: '/pages/login/login'
});
}
// 重置分类索引
currentIndex.value = 0
// 请求所有数据
requestAll()
console.log('进来了2');
})
/**
* 页面显示
*/
onShow(() => {
console.log('进来了1');
// 检查是否有固定的分类选择状态
const fixed = uni.getStorageSync('fixed')
if (fixed && currentItem.value) {