Compare commits
1 Commits
04e2196942
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 34d6cfdf9e |
22
App.vue
22
App.vue
@@ -3,31 +3,9 @@
|
||||
import update from "@/uni_modules/uni-upgrade-center-app/utils/check-update";
|
||||
|
||||
// #endif
|
||||
import { useUserStore } from '@/stores/user'
|
||||
export default {
|
||||
onLaunch: function() {
|
||||
const userStore = useUserStore()
|
||||
console.log('App Launch')
|
||||
// 保存原生 switchTab 方法
|
||||
const originalSwitchTab = uni.switchTab;
|
||||
uni.switchTab = (options) => {
|
||||
if (options.url.includes('/pages/book/index') && !uni.getStorageSync('token')) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '请先登录后访问该页面',
|
||||
confirmText: '去登录',
|
||||
success: (res) => {
|
||||
console.log(res, 'res');
|
||||
if (res.confirm) uni.navigateTo({
|
||||
url: '/pages/login/login'
|
||||
});
|
||||
}
|
||||
});
|
||||
return; // 拦截跳转
|
||||
}
|
||||
// 已登录/非拦截页 → 执行原生跳转
|
||||
originalSwitchTab.call(uni, options);
|
||||
}
|
||||
// 检测自动更新
|
||||
// #ifdef APP-PLUS
|
||||
update();
|
||||
|
||||
@@ -42,7 +42,7 @@ export const bookHomeApi = {
|
||||
*/
|
||||
getRecommendBooks() {
|
||||
return skeletonClient.request<IRecommendBooksResponse>({
|
||||
url: 'bookAbroad/home/getRecommendBooks',
|
||||
url: uni.getStorageSync('token') ? 'bookAbroad/home/getRecommendBooks' : 'visitor/bookAbroad/getRecommendBooks',
|
||||
method: 'POST',
|
||||
data: {}
|
||||
})
|
||||
@@ -54,7 +54,7 @@ export const bookHomeApi = {
|
||||
*/
|
||||
getBookLabelList(type: number) {
|
||||
return skeletonClient.request<ILabelListResponse>({
|
||||
url: 'bookAbroad/home/getBookAbroadLableList',
|
||||
url: uni.getStorageSync('token') ? 'bookAbroad/home/getBookAbroadLableList' : 'visitor/bookAbroad//getBookAbroadLableList',
|
||||
method: 'POST',
|
||||
data: { type }
|
||||
})
|
||||
@@ -66,7 +66,7 @@ export const bookHomeApi = {
|
||||
*/
|
||||
getSubLabelList(pid: number) {
|
||||
return skeletonClient.request<ILabelListResponse>({
|
||||
url: 'bookAbroad/home/getBookAbroadLableListByPid',
|
||||
url: uni.getStorageSync('token') ? 'bookAbroad/home/getBookAbroadLableListByPid' : 'visitor/bookAbroad//getBookAbroadLableListByPid',
|
||||
method: 'POST',
|
||||
data: { pid }
|
||||
})
|
||||
@@ -78,7 +78,7 @@ export const bookHomeApi = {
|
||||
*/
|
||||
getBooksByLabel(lableId: number) {
|
||||
return skeletonClient.request<IBookListResponse>({
|
||||
url: 'bookAbroad/home/getAbroadBookListByLable',
|
||||
url: uni.getStorageSync('token') ? 'bookAbroad/home/getAbroadBookListByLable' : 'visitor/bookAbroad/getAbroadBookListByLable',
|
||||
method: 'POST',
|
||||
data: { lableId }
|
||||
})
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
import { mainClient, skeletonClient } from '@/api/clients'
|
||||
import type { IApiResponse } from '@/api/types'
|
||||
import type { IAgreement } from '@/types/user'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
|
||||
export const commonApi = {
|
||||
/**
|
||||
@@ -37,9 +36,8 @@ export const commonApi = {
|
||||
* @returns 消息列表
|
||||
*/
|
||||
getMessageList(isBook: number, isMedical: number, isSociology: number) {
|
||||
const userStore = useUserStore()
|
||||
return skeletonClient.request<IApiResponse>({
|
||||
url: userStore.token ? 'common/message/listByPage' : '/visitor/listByPage',
|
||||
url: uni.getStorageSync('token') ? 'common/message/listByPage' : '/visitor/listByPage',
|
||||
method: 'POST',
|
||||
data: { isBook, isMedical, isSociology }
|
||||
})
|
||||
|
||||
@@ -13,7 +13,6 @@ import type {
|
||||
} from '@/types/course'
|
||||
import type { ISearchRequest, ISearchResponse } from '@/types/search'
|
||||
import type { ICommentListResponse, IAddCommentResponse, IComment } from '@/types/comment'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
|
||||
/**
|
||||
* 课程相关API
|
||||
@@ -55,9 +54,8 @@ export const courseApi = {
|
||||
page: number,
|
||||
limit: number
|
||||
}) {
|
||||
const userStore = useUserStore()
|
||||
return skeletonClient.request<IMarketCourseListResponse>({
|
||||
url: userStore.token ? 'medical/home/getMarketCourseList' : 'visitor/getMarketCourseList',
|
||||
url: uni.getStorageSync('token') ? 'medical/home/getMarketCourseList' : 'visitor/getMarketCourseList',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
|
||||
@@ -7,8 +7,6 @@ import type {
|
||||
IMarketCourseListResponse,
|
||||
ICourseMedicalLabelsResponse
|
||||
} from '@/types/course'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { skeletonClient } from '../clients'
|
||||
|
||||
|
||||
const client = createRequestClient({ baseURL: SERVICE_MAP.MAIN })
|
||||
@@ -23,9 +21,8 @@ export const courseSubjectClassificationApi = {
|
||||
* @returns 分类数据
|
||||
*/
|
||||
getCourseMedicalTree() {
|
||||
const userStore = useUserStore()
|
||||
return client.request<ICourseCategoryResponse>({
|
||||
url: userStore.token ? 'medical/home/getCourseMedicalTree' : '/visitor/getCourseMedicalTree',
|
||||
url: uni.getStorageSync('token') ? 'medical/home/getCourseMedicalTree' : '/visitor/getCourseMedicalTree',
|
||||
method: 'POST',
|
||||
data: {}
|
||||
})
|
||||
|
||||
@@ -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'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 页面显示
|
||||
*/
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@
|
||||
console.log('运行Android上')
|
||||
} else {
|
||||
isAndroid.value = false;
|
||||
qudao.value = 'Google'
|
||||
qudao.value = 'IOS'
|
||||
console.log('运行iOS上')
|
||||
}
|
||||
getData()
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
import { ref } from 'vue'
|
||||
|
||||
const menuItems = ref([
|
||||
{
|
||||
name: '分享APP'
|
||||
},
|
||||
// {
|
||||
// name: '分享APP'
|
||||
// },
|
||||
{
|
||||
name: '关于我们',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user