更新:课程首页增加骨架屏
This commit is contained in:
@@ -7,7 +7,7 @@ export const ENV = process.env.NODE_ENV || 'development';
|
|||||||
*/
|
*/
|
||||||
const BASE_URL_MAP = {
|
const BASE_URL_MAP = {
|
||||||
development: {
|
development: {
|
||||||
//MAIN: 'http://192.168.110.100:9300/pb/', // 张川川
|
// MAIN: 'http://192.168.110.100:9300/pb/', // 张川川
|
||||||
MAIN: 'https://global.nuttyreading.com/', // 线上
|
MAIN: 'https://global.nuttyreading.com/', // 线上
|
||||||
// PAYMENT: 'https://dev-pay.example.com', // 暂时用不到
|
// PAYMENT: 'https://dev-pay.example.com', // 暂时用不到
|
||||||
// CDN: 'https://cdn-dev.example.com', // 暂时用不到
|
// CDN: 'https://cdn-dev.example.com', // 暂时用不到
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
// api/modules/common.ts
|
// api/modules/common.ts
|
||||||
import { mainClient } from '@/api/clients/main'
|
import { mainClient, skeletonClient } from '@/api/clients'
|
||||||
import type { IApiResponse } from '@/api/types'
|
import type { IApiResponse } from '@/api/types'
|
||||||
import type { IAgreement } from '@/types/user'
|
import type { IAgreement } from '@/types/user'
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const commonApi = {
|
export const commonApi = {
|
||||||
/**
|
/**
|
||||||
* 发送邮箱验证码
|
* 发送邮箱验证码
|
||||||
@@ -40,7 +38,7 @@ export const commonApi = {
|
|||||||
*/
|
*/
|
||||||
getMessageList(isBook: number, isMedical: number, isSociology: number) {
|
getMessageList(isBook: number, isMedical: number, isSociology: number) {
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
return mainClient.request<IMessageListResponse>({
|
return skeletonClient.request<IApiResponse>({
|
||||||
url: userStore.token ? 'common/message/listByPage' : '/visitor/listByPage',
|
url: userStore.token ? 'common/message/listByPage' : '/visitor/listByPage',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: { isBook, isMedical, isSociology }
|
data: { isBook, isMedical, isSociology }
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export const courseApi = {
|
|||||||
* @returns 观看记录列表
|
* @returns 观看记录列表
|
||||||
*/
|
*/
|
||||||
getUserLateCourseList() {
|
getUserLateCourseList() {
|
||||||
return mainClient.request<IUserLateCourseListResponse>({
|
return skeletonClient.request<IUserLateCourseListResponse>({
|
||||||
url: 'medical/home/getUserLateCourseList',
|
url: 'medical/home/getUserLateCourseList',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: {}
|
data: {}
|
||||||
@@ -56,7 +56,7 @@ export const courseApi = {
|
|||||||
limit: number
|
limit: number
|
||||||
}) {
|
}) {
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
return mainClient.request<IMarketCourseListResponse>({
|
return skeletonClient.request<IMarketCourseListResponse>({
|
||||||
url: userStore.token ? 'medical/home/getMarketCourseList' : 'visitor/getMarketCourseList',
|
url: userStore.token ? 'medical/home/getMarketCourseList' : 'visitor/getMarketCourseList',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data
|
data
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import type {
|
|||||||
ICourseMedicalLabelsResponse
|
ICourseMedicalLabelsResponse
|
||||||
} from '@/types/course'
|
} from '@/types/course'
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
|
import { skeletonClient } from '../clients'
|
||||||
|
|
||||||
|
|
||||||
const client = createRequestClient({ baseURL: SERVICE_MAP.MAIN })
|
const client = createRequestClient({ baseURL: SERVICE_MAP.MAIN })
|
||||||
@@ -36,7 +37,7 @@ export const courseSubjectClassificationApi = {
|
|||||||
* @returns 分类数据
|
* @returns 分类数据
|
||||||
*/
|
*/
|
||||||
getCourseSoulTree() {
|
getCourseSoulTree() {
|
||||||
return client.request<ICourseCategoryResponse>({
|
return skeletonClient.request<ICourseCategoryResponse>({
|
||||||
url: 'psyche/home/getPsycheLabels',
|
url: 'psyche/home/getPsycheLabels',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: { id: 0 }
|
data: { id: 0 }
|
||||||
@@ -49,7 +50,7 @@ export const courseSubjectClassificationApi = {
|
|||||||
* @returns 分类数据
|
* @returns 分类数据
|
||||||
*/
|
*/
|
||||||
getCourseSociologyTree() {
|
getCourseSociologyTree() {
|
||||||
return client.request<ICourseCategoryResponse>({
|
return skeletonClient.request<ICourseCategoryResponse>({
|
||||||
url: 'sociology/home/getSociologyLabels',
|
url: 'sociology/home/getSociologyLabels',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: { id: 0 }
|
data: { id: 0 }
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ import LineList from './templates/LineList.vue'
|
|||||||
import BookCard from './templates/BookCard.vue'
|
import BookCard from './templates/BookCard.vue'
|
||||||
import ImageCard from './templates/ImageCard.vue'
|
import ImageCard from './templates/ImageCard.vue'
|
||||||
import BookInfo from './templates/BookInfo.vue'
|
import BookInfo from './templates/BookInfo.vue'
|
||||||
|
import Menu from './templates/Menu.vue'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 注册组件
|
// 注册组件
|
||||||
const components = {
|
const components = {
|
||||||
@@ -28,6 +31,7 @@ const components = {
|
|||||||
'image-card': ImageCard,
|
'image-card': ImageCard,
|
||||||
'book-card': BookCard,
|
'book-card': BookCard,
|
||||||
'book-info': BookInfo,
|
'book-info': BookInfo,
|
||||||
|
'menu': Menu
|
||||||
}
|
}
|
||||||
|
|
||||||
type RequestFn = () => Promise<any>
|
type RequestFn = () => Promise<any>
|
||||||
|
|||||||
33
components/Skeleton/templates/Menu.vue
Normal file
33
components/Skeleton/templates/Menu.vue
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<template>
|
||||||
|
<view class="menu-box">
|
||||||
|
<wd-skeleton :row-col="grid" animation="gradient" />
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
const props = defineProps<{
|
||||||
|
size?: any[],
|
||||||
|
count: number
|
||||||
|
}>()
|
||||||
|
const list = Array.from({ length: props.count }, (_, index) => (props.size || []))
|
||||||
|
|
||||||
|
const grid = [
|
||||||
|
[
|
||||||
|
{ width: '96rpx', height: '96rpx' },
|
||||||
|
{ width: '96rpx', height: '96rpx' },
|
||||||
|
{ width: '96rpx', height: '96rpx' },
|
||||||
|
{ width: '96rpx', height: '96rpx' }
|
||||||
|
]
|
||||||
|
]
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.menu-box {
|
||||||
|
padding: 40rpx 80rpx;
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
|
||||||
|
:deep(.wd-skeleton) {
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -31,80 +31,87 @@
|
|||||||
>{{ item }}</view>
|
>{{ item }}</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 医学 -->
|
<!-- 医学 -->
|
||||||
<view v-if="selectedFirstLevel === '医学'" class="newLeve2">
|
<Skeleton
|
||||||
<view class="home_nar nomargin" style="padding: 0; background-color: #fff">
|
v-if="selectedFirstLevel === '医学'"
|
||||||
<view class="flexbox">
|
ref="medicineMenuSkeletonRef"
|
||||||
|
theme="menu"
|
||||||
|
:request="getMedicineMenus"
|
||||||
|
@success="getMedicineMenusSuccess"
|
||||||
|
>
|
||||||
|
<template #content>
|
||||||
|
<view v-if="selectedFirstLevel === '医学'" class="newLeve2">
|
||||||
|
<view class="home_nar nomargin" style="padding: 0; background-color: #fff">
|
||||||
|
<view class="flexbox">
|
||||||
|
<view
|
||||||
|
:class="['hn_cl_tit', currentIndex == index ? 'active' : '']"
|
||||||
|
@click="curseClick(item, index)"
|
||||||
|
v-for="(item, index) in curseTagList"
|
||||||
|
:key="item.id"
|
||||||
|
>
|
||||||
|
<image :src="item.icon" mode="aspectFit"></image>
|
||||||
|
<text>{{ item.title }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
<view
|
<view
|
||||||
:class="['hn_cl_tit', currentIndex == index ? 'active' : '']"
|
class="fourBox"
|
||||||
@click="curseClick(item, index)"
|
style="padding: 0; padding-bottom: 8rpx"
|
||||||
v-for="(item, index) in curseTagList"
|
v-if="sbuMedicalTagsList?.length > 0"
|
||||||
:key="item.id"
|
|
||||||
>
|
>
|
||||||
<image :src="item.icon" mode="aspectFit"></image>
|
<view
|
||||||
<text>{{ item.title }}</text>
|
class="childrenBox fourIcon flexbox"
|
||||||
|
style="justify-content: space-around"
|
||||||
|
>
|
||||||
|
<view
|
||||||
|
class="item flexbox"
|
||||||
|
@click="curseClickJump(item)"
|
||||||
|
v-for="(item, index) in sbuMedicalTagsList"
|
||||||
|
:key="item.id"
|
||||||
|
>
|
||||||
|
<image
|
||||||
|
:src="item.icon"
|
||||||
|
mode="aspectFit"
|
||||||
|
v-if="item.icon != '' && item.icon != null"
|
||||||
|
></image>
|
||||||
|
<text>{{ item.title }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</template>
|
||||||
<view
|
</Skeleton>
|
||||||
class="fourBox"
|
<!-- 心理学和国学 -->
|
||||||
style="padding: 0; padding-bottom: 8rpx"
|
<Skeleton
|
||||||
v-if="sbuMedicalTagsList?.length > 0"
|
v-if="selectedFirstLevel === '心理学' || selectedFirstLevel === '国学'"
|
||||||
>
|
ref="menuSkeletonRef"
|
||||||
|
theme="menu"
|
||||||
|
:request="getMenus"
|
||||||
|
>
|
||||||
|
<template #content="{ data }">
|
||||||
<view
|
<view
|
||||||
class="childrenBox fourIcon flexbox"
|
v-if="data.labels.length > 0"
|
||||||
style="justify-content: space-around"
|
:class="[
|
||||||
|
{'sociology_cate_box': selectedFirstLevel === '国学'},
|
||||||
|
{'soul_cate_box': selectedFirstLevel === '心理学'}
|
||||||
|
]"
|
||||||
>
|
>
|
||||||
<view
|
|
||||||
class="item flexbox"
|
|
||||||
@click="curseClickJump(item)"
|
|
||||||
v-for="(item, index) in sbuMedicalTagsList"
|
|
||||||
:key="item.id"
|
|
||||||
>
|
|
||||||
<image
|
|
||||||
:src="item.icon"
|
|
||||||
mode="aspectFit"
|
|
||||||
v-if="item.icon != '' && item.icon != null"
|
|
||||||
></image>
|
|
||||||
<text>{{ item.title }}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<!-- 心理学 -->
|
|
||||||
<view v-if="selectedFirstLevel === '心理学'" class="soul_cate_box">
|
|
||||||
<scroll-view scroll-x="true">
|
|
||||||
<view class="cate_list" v-if="soulCateList.length > 0">
|
|
||||||
<view
|
<view
|
||||||
class="cate_item_box"
|
class="cate_item_box"
|
||||||
v-for="(item, index) in soulCateList"
|
v-for="item in data.labels"
|
||||||
:key="index"
|
|
||||||
@click="curseClickJump(item)"
|
@click="curseClickJump(item)"
|
||||||
>
|
>
|
||||||
<view class="cate_item_border">
|
<view class="cate_item_border">
|
||||||
<image :src="item.icon"></image>
|
<image
|
||||||
|
:src="item.icon"
|
||||||
|
mode="aspectFill"
|
||||||
|
style="width: 49rpx; height: 49rpx"
|
||||||
|
></image>
|
||||||
</view>
|
</view>
|
||||||
<view class="cate_item_name">{{ item.title }}</view>
|
<view class="cate_item_name">{{ item.title }}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</template>
|
||||||
</view>
|
</Skeleton>
|
||||||
<!-- 国学 -->
|
|
||||||
<view v-if="selectedFirstLevel === '国学' && sociologyCateList.length > 0" class="sociology_cate_box">
|
|
||||||
<view
|
|
||||||
class="cate_item_box"
|
|
||||||
v-for="(v, i) in sociologyCateList"
|
|
||||||
@click="curseClickJump(v)"
|
|
||||||
>
|
|
||||||
<view class="cate_item_border">
|
|
||||||
<image
|
|
||||||
:src="v.icon"
|
|
||||||
mode="aspectFill"
|
|
||||||
style="width: 49rpx; height: 49rpx"
|
|
||||||
></image>
|
|
||||||
</view>
|
|
||||||
<view class="cate_item_name">{{ v.title }}</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 观看记录区域 -->
|
<!-- 观看记录区域 -->
|
||||||
<view class="learnBox" v-if="learnList.length > 0">
|
<view class="learnBox" v-if="learnList.length > 0">
|
||||||
@@ -143,7 +150,7 @@
|
|||||||
<view class="newscoll">
|
<view class="newscoll">
|
||||||
<swiper
|
<swiper
|
||||||
class="swiper"
|
class="swiper"
|
||||||
interval="5000"
|
:interval="5000"
|
||||||
circular
|
circular
|
||||||
autoplay
|
autoplay
|
||||||
vertical
|
vertical
|
||||||
@@ -163,40 +170,50 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 精彩试听区域 -->
|
<!-- 精彩试听区域 -->
|
||||||
<view class="learnBox" v-if="tryListenList.length > 0">
|
<view class="learnBox">
|
||||||
<view class="titleBox flexbox">
|
<view class="titleBox flexbox">
|
||||||
<image src="../../static/course/try_listen.png" mode="aspectFit"></image>
|
<image src="../../static/course/try_listen.png" mode="aspectFit"></image>
|
||||||
<text>{{ $t('courseHome.tryListen') }}</text>
|
<text>{{ $t('courseHome.tryListen') }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="learn flexbox shiting">
|
<Skeleton
|
||||||
<view
|
theme="image-card"
|
||||||
class="item"
|
class=""
|
||||||
v-for="(item, index) in tryListenList"
|
:size="Array(2).fill({ width: '48%', height: '260rpx' })"
|
||||||
:key="item.id"
|
:count="3"
|
||||||
@click="onPageJump('/pages/course/details/course', item.id, item.title)"
|
:request="getTryListenList"
|
||||||
>
|
>
|
||||||
<view class="imgcontainer">
|
<template #content="{ data }">
|
||||||
<image
|
<view v-if="data.courseList.records.length > 0" class="learn flexbox shiting">
|
||||||
v-if="item.image == '' || !item.image"
|
<view
|
||||||
src="../../static/course/nobg.jpg"
|
class="item"
|
||||||
mode="aspectFit"
|
v-for="(item, index) in data.courseList.records"
|
||||||
|
:key="item.id"
|
||||||
|
@click="onPageJump('/pages/course/details/course', item.id, item.title)"
|
||||||
>
|
>
|
||||||
</image>
|
<view class="imgcontainer">
|
||||||
<image v-else :src="item.image"></image>
|
<image
|
||||||
</view>
|
v-if="item.image == '' || !item.image"
|
||||||
<view class="buyItems flexbox">
|
src="../../static/course/nobg.jpg"
|
||||||
<view class="txt555">
|
mode="aspectFit"
|
||||||
{{ item.title }}
|
>
|
||||||
</view>
|
</image>
|
||||||
<view class="buybtn">
|
<image v-else :src="item.image"></image>
|
||||||
<span>{{ $t('courseHome.buy') }}</span>
|
</view>
|
||||||
|
<view class="buyItems flexbox">
|
||||||
|
<view class="txt555">
|
||||||
|
{{ item.title }}
|
||||||
|
</view>
|
||||||
|
<view class="buybtn">
|
||||||
|
<span>{{ $t('courseHome.buy') }}</span>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
<view class="moreBox shiting">
|
||||||
</view>
|
<text @click="onPageJump('/pages/course/list/tryListen', 1, $t('courseHome.tryListen'))">{{ $t('courseHome.moreTryListen') }}</text>
|
||||||
<view class="moreBox shiting">
|
</view>
|
||||||
<text @click="onPageJump('/pages/course/list/tryListen', 1, $t('courseHome.tryListen'))">{{ $t('courseHome.moreTryListen') }}</text>
|
</template>
|
||||||
</view>
|
</Skeleton>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -236,34 +253,18 @@ const currentItem = ref<IMedicalTag | null>(null) // 当前选中的一级
|
|||||||
|
|
||||||
// 学科数据
|
// 学科数据
|
||||||
const firstLevelCategories = ref<string[]>(['医学', '心理学', '国学'])
|
const firstLevelCategories = ref<string[]>(['医学', '心理学', '国学'])
|
||||||
const selectedFirstLevel = ref<number>('医学') // 当前选中的一级分类索引
|
const selectedFirstLevel = ref('医学') // 当前选中的一级分类索引
|
||||||
/**
|
|
||||||
* 学科点击处理
|
|
||||||
*/
|
|
||||||
const handleFirstLevelClick = (item: string) => {
|
|
||||||
getPrompt()
|
|
||||||
if(!uni.getStorageSync('token')) return
|
|
||||||
selectedFirstLevel.value = item
|
|
||||||
switch (item) {
|
|
||||||
case '医学':
|
|
||||||
getMedicalTags()
|
|
||||||
break
|
|
||||||
case '心理学':
|
|
||||||
getSoulCateList()
|
|
||||||
break
|
|
||||||
case '国学':
|
|
||||||
getSociologyCateList()
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* 医学
|
* 医学
|
||||||
* 获取课程分类数据
|
* 获取课程分类数据
|
||||||
*/
|
*/
|
||||||
const getMedicalTags = async () => {
|
const medicineMenuSkeletonRef = ref()
|
||||||
|
const getMedicineMenus = () => {
|
||||||
sbuMedicalTagsList.value = []
|
sbuMedicalTagsList.value = []
|
||||||
const res = await courseSubjectClassificationApi.getCourseMedicalTree()
|
return courseSubjectClassificationApi.getCourseMedicalTree()
|
||||||
|
}
|
||||||
|
const getMedicineMenusSuccess = (res: any) => {
|
||||||
if (res && res.code === 0) {
|
if (res && res.code === 0) {
|
||||||
if (res.labels && res.labels.length > 0) {
|
if (res.labels && res.labels.length > 0) {
|
||||||
curseTagList.value = res.labels
|
curseTagList.value = res.labels
|
||||||
@@ -304,27 +305,46 @@ const curseClick = (item: IMedicalTag, index: number) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 心理学
|
* 菜单
|
||||||
* 获取课程分类数据
|
* 获取课程分类数据
|
||||||
*/
|
*/
|
||||||
const soulCateList = ref<IMedicalTag[]>([])
|
const menuSkeletonRef = ref()
|
||||||
const getSoulCateList = async () => {
|
const getMenus = () => {
|
||||||
const res = await courseSubjectClassificationApi.getCourseSoulTree()
|
switch (selectedFirstLevel.value) {
|
||||||
if (res.labels&&res.labels.length>0) {
|
// case '医学':
|
||||||
soulCateList.value = res.labels;
|
// return getMedicalTags()
|
||||||
|
case '心理学':
|
||||||
|
return courseSubjectClassificationApi.getCourseSoulTree()
|
||||||
|
case '国学':
|
||||||
|
return courseSubjectClassificationApi.getCourseSociologyTree()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 国学
|
* 学科点击处理
|
||||||
* 获取课程分类数据
|
|
||||||
*/
|
*/
|
||||||
const sociologyCateList = ref<IMedicalTag[]>([])
|
const handleFirstLevelClick = (item: string) => {
|
||||||
const getSociologyCateList = async () => {
|
getPrompt()
|
||||||
const res = await courseSubjectClassificationApi.getCourseSociologyTree()
|
if(!uni.getStorageSync('token')) return
|
||||||
if (res.labels&&res.labels.length>0) {
|
selectedFirstLevel.value = item
|
||||||
sociologyCateList.value = res.labels;
|
if (item === '医学') {
|
||||||
|
medicineMenuSkeletonRef.value.reload()
|
||||||
|
} else {
|
||||||
|
menuSkeletonRef.value?.reload()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// switch (item) {
|
||||||
|
// case '医学':
|
||||||
|
// getMedicalTags()
|
||||||
|
// break
|
||||||
|
// case '心理学':
|
||||||
|
// getSoulCateList()
|
||||||
|
// break
|
||||||
|
// case '国学':
|
||||||
|
// getSociologyCateList()
|
||||||
|
// break
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -399,24 +419,10 @@ const newsClick = (item: INews) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 精彩试听
|
// 精彩试听
|
||||||
const tryListenList = ref<ICourse[]>([]) // 试听课程列表
|
|
||||||
/**
|
/**
|
||||||
* 获取试听课程列表
|
* 获取试听课程列表
|
||||||
*/
|
*/
|
||||||
const getTryListenList = async () => {
|
const getTryListenList = () => courseApi.getMarketCourseList({ page: 1, limit: 6, id: 1 })
|
||||||
const res = await courseApi.getMarketCourseList({
|
|
||||||
page: 1,
|
|
||||||
limit: 6,
|
|
||||||
id: 1
|
|
||||||
})
|
|
||||||
if (res && res.code === 0) {
|
|
||||||
if (res.courseList && res.courseList.records && res.courseList.records.length > 0) {
|
|
||||||
tryListenList.value = res.courseList.records
|
|
||||||
} else {
|
|
||||||
tryListenList.value = []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录提示语
|
* 登录提示语
|
||||||
@@ -444,8 +450,7 @@ const getTryListenList = async () => {
|
|||||||
const requestAll = async () => {
|
const requestAll = async () => {
|
||||||
if(uni.getStorageSync('token')){
|
if(uni.getStorageSync('token')){
|
||||||
getLearnCourse()
|
getLearnCourse()
|
||||||
}
|
}
|
||||||
getMedicalTags()
|
|
||||||
getTryListenList()
|
getTryListenList()
|
||||||
getNewsList()
|
getNewsList()
|
||||||
}
|
}
|
||||||
@@ -472,16 +477,19 @@ onMounted(() => {
|
|||||||
*/
|
*/
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
// 检查是否有固定的分类选择状态
|
// 检查是否有固定的分类选择状态
|
||||||
const fixed = uni.getStorageSync('fixed')
|
// const fixed = uni.getStorageSync('fixed')
|
||||||
if (fixed && currentItem.value) {
|
// if (fixed && currentItem.value) {
|
||||||
curseClick(currentItem.value, currentIndex.value)
|
// curseClick(currentItem.value, currentIndex.value)
|
||||||
} else {
|
// } else {
|
||||||
currentIndex.value = 0
|
// currentIndex.value = 0
|
||||||
currentItem.value = null
|
// currentItem.value = null
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 刷新数据
|
// 刷新数据
|
||||||
requestAll()
|
// requestAll()
|
||||||
|
if(userStore.token){
|
||||||
|
getLearnCourse()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -673,42 +681,47 @@ $border-color: #eeeeee;
|
|||||||
box-shadow: 0rpx 0rpx 6rpx 0rpx #f9f6ea;
|
box-shadow: 0rpx 0rpx 6rpx 0rpx #f9f6ea;
|
||||||
border-radius: 10rpx;
|
border-radius: 10rpx;
|
||||||
margin: 0 10rpx;
|
margin: 0 10rpx;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-around;
|
||||||
|
.cate_item_box {
|
||||||
|
width: 20%;
|
||||||
|
padding: 40rpx 0 30rpx;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
.cate_list {
|
.cate_item_border {
|
||||||
display: flex;
|
width: 60rpx;
|
||||||
align-items: center;
|
height: 60rpx;
|
||||||
justify-content: space-around;
|
background-size: 100% 100%;
|
||||||
|
background-image: url("@/static/soul/cate_bg.png");
|
||||||
|
border-radius: 4rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin: 0 auto;
|
||||||
|
|
||||||
.cate_item_box {
|
image {
|
||||||
width: 20%;
|
width: 46rpx;
|
||||||
padding: 40rpx 0 30rpx;
|
height: 46rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.cate_item_name {
|
||||||
|
margin-top: 15rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
line-height: 34rpx;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
color: #fff;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
.cate_item_border {
|
.child-menu {
|
||||||
width: 60rpx;
|
display: none;
|
||||||
height: 60rpx;
|
background-color: #000;
|
||||||
background-size: 100% 100%;
|
box-shadow: 0 4rpx 12rpx rgba(51, 97, 165, 0.08);
|
||||||
background-image: url("@/static/soul/cate_bg.png");
|
border-radius: 0 0 20rpx 20rpx;
|
||||||
border-radius: 4rpx;
|
padding: 10rpx 0;
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
margin: 0 auto;
|
|
||||||
|
|
||||||
image {
|
|
||||||
width: 46rpx;
|
|
||||||
height: 46rpx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.cate_item_name {
|
|
||||||
margin-top: 15rpx;
|
|
||||||
font-size: 24rpx;
|
|
||||||
line-height: 34rpx;
|
|
||||||
text-align: center;
|
|
||||||
color: #fff;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -890,7 +903,6 @@ $border-color: #eeeeee;
|
|||||||
|
|
||||||
.learn {
|
.learn {
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin-top: 20rpx;
|
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|
||||||
.item {
|
.item {
|
||||||
@@ -917,6 +929,7 @@ $border-color: #eeeeee;
|
|||||||
|
|
||||||
.titleBox {
|
.titleBox {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
|
||||||
image {
|
image {
|
||||||
width: 50rpx;
|
width: 50rpx;
|
||||||
|
|||||||
139
pages/index.vue
Normal file
139
pages/index.vue
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
<template>
|
||||||
|
<div class="menu-container">
|
||||||
|
|
||||||
|
<!-- 一级导航 -->
|
||||||
|
<div class="menu-level-1">
|
||||||
|
<div
|
||||||
|
v-for="item in level1"
|
||||||
|
:key="item.id"
|
||||||
|
class="menu-item"
|
||||||
|
:class="{ active: selectedParentId === item.id }"
|
||||||
|
@click="selectParent(item)"
|
||||||
|
>
|
||||||
|
{{ item.name }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 二级导航区域 -->
|
||||||
|
<transition name="fade">
|
||||||
|
<div
|
||||||
|
v-if="childList.length"
|
||||||
|
class="menu-level-2"
|
||||||
|
:style="{ gridRowStart: childRowIndex }"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-for="child in childList"
|
||||||
|
:key="child.id"
|
||||||
|
class="menu-item child"
|
||||||
|
>
|
||||||
|
{{ child.name }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</transition>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref, computed } from "vue"
|
||||||
|
|
||||||
|
// 模拟接口返回的一级导航
|
||||||
|
const level1 = ref([
|
||||||
|
{ id: 1, name: "导航1", children: [] },
|
||||||
|
{ id: 2, name: "导航2", children: [
|
||||||
|
{ id: 21, name: "子2-1" },
|
||||||
|
{ id: 22, name: "子2-2" },
|
||||||
|
{ id: 23, name: "子2-3" }
|
||||||
|
]},
|
||||||
|
{ id: 3, name: "导航3", children: [] },
|
||||||
|
{ id: 4, name: "导航4", children: [
|
||||||
|
{ id: 41, name: "子4-1" },
|
||||||
|
{ id: 42, name: "子4-2" }
|
||||||
|
]},
|
||||||
|
{ id: 5, name: "导航5", children: [] },
|
||||||
|
{ id: 6, name: "导航6", children: [
|
||||||
|
{ id: 61, name: "子6-1" },
|
||||||
|
{ id: 62, name: "子6-2" },
|
||||||
|
{ id: 63, name: "子6-3" },
|
||||||
|
{ id: 64, name: "子6-4" },
|
||||||
|
]},
|
||||||
|
{ id: 7, name: "导航7", children: [] },
|
||||||
|
{ id: 8, name: "导航8", children: [] }
|
||||||
|
])
|
||||||
|
|
||||||
|
// 选择的一级导航
|
||||||
|
const selectedParentId = ref(null)
|
||||||
|
|
||||||
|
// 当前一级导航的子级
|
||||||
|
const childList = computed(() => {
|
||||||
|
const parent = level1.value.find(i => i.id === selectedParentId.value)
|
||||||
|
return parent ? parent.children : []
|
||||||
|
})
|
||||||
|
|
||||||
|
// 计算二级导航应该显示在哪一行(每行 4 个)
|
||||||
|
const childRowIndex = computed(() => {
|
||||||
|
if (!selectedParentId.value) return 3
|
||||||
|
const index = level1.value.findIndex(i => i.id === selectedParentId.value)
|
||||||
|
return Math.floor(index / 4) + 2 // 第一行 row=1,二级导航从 row=2 或 row=3
|
||||||
|
})
|
||||||
|
|
||||||
|
const selectParent = (item) => {
|
||||||
|
// 点击同一个时关闭
|
||||||
|
if (selectedParentId.value === item.id) {
|
||||||
|
selectedParentId.value = null
|
||||||
|
} else {
|
||||||
|
selectedParentId.value = item.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.menu-container {
|
||||||
|
display: grid;
|
||||||
|
grid-template-rows: auto auto auto;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 一级导航:4列布局 */
|
||||||
|
.menu-level-1 {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(4, 1fr);
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-item {
|
||||||
|
padding: 12px;
|
||||||
|
text-align: center;
|
||||||
|
background: #4a90e2;
|
||||||
|
color: white;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-item.active {
|
||||||
|
background: #2d73c7;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 二级导航:自动换行 */
|
||||||
|
.menu-level-2 {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(4, 1fr);
|
||||||
|
gap: 8px;
|
||||||
|
background: #2d73c7;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-item.child {
|
||||||
|
background: #1e4f8a;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 动画 */
|
||||||
|
.fade-enter-active, .fade-leave-active {
|
||||||
|
transition: all .2s ease;
|
||||||
|
}
|
||||||
|
.fade-enter-from, .fade-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(-5px);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -217,18 +217,9 @@
|
|||||||
.mt-2 {
|
.mt-2 {
|
||||||
margin-top: calc(var(--spacing) * 2);
|
margin-top: calc(var(--spacing) * 2);
|
||||||
}
|
}
|
||||||
.mt-2\! {
|
|
||||||
margin-top: calc(var(--spacing) * 2) !important;
|
|
||||||
}
|
|
||||||
.mt-2\.5\! {
|
|
||||||
margin-top: calc(var(--spacing) * 2.5) !important;
|
|
||||||
}
|
|
||||||
.mt-3 {
|
.mt-3 {
|
||||||
margin-top: calc(var(--spacing) * 3);
|
margin-top: calc(var(--spacing) * 3);
|
||||||
}
|
}
|
||||||
.mt-3\! {
|
|
||||||
margin-top: calc(var(--spacing) * 3) !important;
|
|
||||||
}
|
|
||||||
.mt-5 {
|
.mt-5 {
|
||||||
margin-top: calc(var(--spacing) * 5);
|
margin-top: calc(var(--spacing) * 5);
|
||||||
}
|
}
|
||||||
@@ -238,27 +229,12 @@
|
|||||||
.mt-20 {
|
.mt-20 {
|
||||||
margin-top: calc(var(--spacing) * 20);
|
margin-top: calc(var(--spacing) * 20);
|
||||||
}
|
}
|
||||||
.mt-20\! {
|
|
||||||
margin-top: calc(var(--spacing) * 20) !important;
|
|
||||||
}
|
|
||||||
.mt-\[20rpx\]\! {
|
.mt-\[20rpx\]\! {
|
||||||
margin-top: 20rpx !important;
|
margin-top: 20rpx !important;
|
||||||
}
|
}
|
||||||
.mr-\[20rpx\] {
|
|
||||||
margin-right: 20rpx;
|
|
||||||
}
|
|
||||||
.mr-\[20rpx\]\! {
|
|
||||||
margin-right: 20rpx !important;
|
|
||||||
}
|
|
||||||
.mb-1 {
|
.mb-1 {
|
||||||
margin-bottom: calc(var(--spacing) * 1);
|
margin-bottom: calc(var(--spacing) * 1);
|
||||||
}
|
}
|
||||||
.mb-1\! {
|
|
||||||
margin-bottom: calc(var(--spacing) * 1) !important;
|
|
||||||
}
|
|
||||||
.mb-1\.5\! {
|
|
||||||
margin-bottom: calc(var(--spacing) * 1.5) !important;
|
|
||||||
}
|
|
||||||
.mb-2 {
|
.mb-2 {
|
||||||
margin-bottom: calc(var(--spacing) * 2);
|
margin-bottom: calc(var(--spacing) * 2);
|
||||||
}
|
}
|
||||||
@@ -283,12 +259,6 @@
|
|||||||
.ml-2\.5\! {
|
.ml-2\.5\! {
|
||||||
margin-left: calc(var(--spacing) * 2.5) !important;
|
margin-left: calc(var(--spacing) * 2.5) !important;
|
||||||
}
|
}
|
||||||
.ml-\[20rpx\] {
|
|
||||||
margin-left: 20rpx;
|
|
||||||
}
|
|
||||||
.ml-\[20rpx\]\! {
|
|
||||||
margin-left: 20rpx !important;
|
|
||||||
}
|
|
||||||
.block {
|
.block {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
@@ -362,9 +332,6 @@
|
|||||||
.p-2 {
|
.p-2 {
|
||||||
padding: calc(var(--spacing) * 2);
|
padding: calc(var(--spacing) * 2);
|
||||||
}
|
}
|
||||||
.p-2\.5 {
|
|
||||||
padding: calc(var(--spacing) * 2.5);
|
|
||||||
}
|
|
||||||
.p-3 {
|
.p-3 {
|
||||||
padding: calc(var(--spacing) * 3);
|
padding: calc(var(--spacing) * 3);
|
||||||
}
|
}
|
||||||
@@ -374,9 +341,6 @@
|
|||||||
.p-\[20rpx\] {
|
.p-\[20rpx\] {
|
||||||
padding: 20rpx;
|
padding: 20rpx;
|
||||||
}
|
}
|
||||||
.p-\[20rpx\]\! {
|
|
||||||
padding: 20rpx !important;
|
|
||||||
}
|
|
||||||
.p-\[30rpx\] {
|
.p-\[30rpx\] {
|
||||||
padding: 30rpx;
|
padding: 30rpx;
|
||||||
}
|
}
|
||||||
|
|||||||
5
types/course.d.ts
vendored
5
types/course.d.ts
vendored
@@ -50,11 +50,6 @@ export interface IMarketCourseListResponse extends IApiResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 消息列表响应 */
|
|
||||||
export interface IMessageListResponse extends IApiResponse {
|
|
||||||
messages: INews[] // 消息列表
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 课程详情 */
|
/** 课程详情 */
|
||||||
export interface ICourseDetail {
|
export interface ICourseDetail {
|
||||||
id: number
|
id: number
|
||||||
|
|||||||
Reference in New Issue
Block a user