更新:访客模式可以查看图书首页

This commit is contained in:
2025-12-12 14:33:47 +08:00
parent 04e2196942
commit 34d6cfdf9e
10 changed files with 43 additions and 53 deletions

View File

@@ -35,16 +35,16 @@
<view class="mine-1">
<text class="mine-title">{{ $t('bookHome.block1') }}</text>
<view
v-if="data.page.records.length > 0"
v-if="data?.page?.records.length > 0"
class="mine-more"
@click="handleMoreClick"
>
{{ $t('bookHome.more') }}
<image src="@/static/icon/icon_right.png" />
</view>
<view v-if="data.page.records.length > 0" class="mine-1-list">
<view v-if="data?.page?.records.length > 0" class="mine-1-list">
<view
v-for="(item, index) in data.page.records"
v-for="(item, index) in data?.page?.records"
:key="index"
class="mine-item"
@click="handleMyBookClick(item.id)"
@@ -284,7 +284,7 @@ const vipInfo = computed(() => userStore.userInfo?.userEbookVip?.[0] || null)
/**
* 获取我的书单
*/
const getMyBooks = () => bookHomeApi.getMyBooks(1, 10)
const getMyBooks = () => uni.getStorageSync('token') ? bookHomeApi.getMyBooks(1, 10) : []
/**
* 获取推荐图书
@@ -364,6 +364,8 @@ const handleMyBookClick = (bookId: number) => {
* 处理图书点击
*/
const handleBookClick = (bookId: number) => {
getPrompt()
if(!uni.getStorageSync('token')) return
uni.navigateTo({
url: `/pages/book/detail?id=${bookId}`
})
@@ -382,6 +384,8 @@ const handleMoreClick = () => {
* 处理活动标签点击
*/
const handleActivityLabelClick = async (labelId: number, index: number) => {
getPrompt()
if(!uni.getStorageSync('token')) return
currentActivityIndex.value = index
activityBooksSkeleton.value.reload()
}
@@ -404,6 +408,25 @@ const handleCategoryLevel2Click = async (labelId: number, index: number) => {
categoryBooksSkeleton.value.reload()
}
/**
* 登录提示语
*/
const getPrompt = () => {
if(!uni.getStorageSync('token')) {
uni.showModal({
title: '提示',
content: '请先登录后访问该页面',
confirmText: '去登录',
success: (res) => {
console.log(res , 'res');
if (res.confirm) uni.navigateTo({
url: '/pages/login/login'
});
}
});
}
}
/**
* 页面显示
*/

View File

@@ -457,17 +457,11 @@ const requestAll = async () => {
* 页面挂载
*/
onMounted(() => {
if(!userStore.token) {
uni.navigateTo({
url: '/pages/login/login'
});
}
// 重置分类索引
currentIndex.value = 0
// 请求所有数据
requestAll()
console.log('进来了2');
})
/**
@@ -485,7 +479,7 @@ onShow(() => {
// 刷新数据
// requestAll()
if(userStore.token){
if(uni.getStorageSync('token')){
getLearnCourse()
}
})

View File

@@ -1,5 +1,5 @@
<template>
<view class="user-page" :style="{ paddingTop: getNotchHeight() + 30 + 'px' }" v-if="userStore.token && uni.getStorageSync('token')">
<view class="user-page" :style="{ paddingTop: getNotchHeight() + 30 + 'px' }" v-if="tokenState">
<!-- 设置图标 -->
<view class="settings-icon" :style="{ top: getNotchHeight() + 30 + 'px' }" @click="goSettings">
<wd-icon name="setting1" size="24px" color="#666" />
@@ -165,6 +165,7 @@
])
// 湖分
const hufenData = ref()
const tokenState = ref(false)
/**
* 获取平台信息
@@ -273,9 +274,10 @@
url: '/pages/user/points/index'
})
}
onShow(() => {
if (uni.getStorageSync('token')) {
tokenState.value = true
getData()
}

View File

@@ -148,7 +148,7 @@
console.log('运行Android上')
} else {
isAndroid.value = false;
qudao.value = 'Google'
qudao.value = 'IOS'
console.log('运行iOS上')
}
getData()

View File

@@ -19,9 +19,9 @@
import { ref } from 'vue'
const menuItems = ref([
{
name: '分享APP'
},
// {
// name: '分享APP'
// },
{
name: '关于我们',
}