|
@@ -16,7 +16,7 @@ import {
|
|
|
SkeletonImage,
|
|
|
Space
|
|
|
} from 'vant'
|
|
|
-import { defineComponent, onMounted, reactive, onUnmounted } from 'vue'
|
|
|
+import { defineComponent, onMounted, reactive, onUnmounted, nextTick, Transition, TransitionGroup } from 'vue'
|
|
|
import styles from './index.module.less'
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
import {
|
|
@@ -34,6 +34,8 @@ import { handleCheckVip } from '../hook/useFee'
|
|
|
import iconList from './image/icon-list.png'
|
|
|
import OSticky from '@/components/o-sticky'
|
|
|
import OHeader from '@/components/o-header'
|
|
|
+import { useEventListener } from '@vant/use'
|
|
|
+import OLoading from '@/components/o-loading'
|
|
|
export default defineComponent({
|
|
|
name: 'courseList',
|
|
|
setup() {
|
|
@@ -42,6 +44,7 @@ export default defineComponent({
|
|
|
const browserInfo = browser()
|
|
|
// const catchList = store
|
|
|
const data = reactive({
|
|
|
+ titleOpacity: 0,
|
|
|
loading: true,
|
|
|
detail: {
|
|
|
cover: '',
|
|
@@ -85,17 +88,21 @@ export default defineComponent({
|
|
|
state.platformApi + '/courseSchedule/myCoursewareDetail/' + route.query.id
|
|
|
)
|
|
|
if (Array.isArray(res?.data)) {
|
|
|
- const _list = await checkCoursewareCache(res.data)
|
|
|
- data.list = browserInfo.isApp ? res.data.map((item: any) => {
|
|
|
- const _item = _list.find((n: any) => n.lessonCoursewareDetailId == item.lessonCoursewareDetailId)
|
|
|
- const n = {
|
|
|
- ...item
|
|
|
- }
|
|
|
- if (_item){
|
|
|
- n.hasCache = _item.hasCache
|
|
|
- }
|
|
|
- return n
|
|
|
- }) : res.data
|
|
|
+ const _list = await checkCoursewareCache(res.data)
|
|
|
+ data.list = browserInfo.isApp
|
|
|
+ ? res.data.map((item: any) => {
|
|
|
+ const _item = _list.find(
|
|
|
+ (n: any) => n.lessonCoursewareDetailId == item.lessonCoursewareDetailId
|
|
|
+ )
|
|
|
+ const n = {
|
|
|
+ ...item
|
|
|
+ }
|
|
|
+ if (_item) {
|
|
|
+ n.hasCache = _item.hasCache
|
|
|
+ }
|
|
|
+ return n
|
|
|
+ })
|
|
|
+ : res.data
|
|
|
}
|
|
|
} catch (error) {}
|
|
|
}
|
|
@@ -231,108 +238,125 @@ export default defineComponent({
|
|
|
}
|
|
|
} catch (error) {}
|
|
|
}
|
|
|
+
|
|
|
+ useEventListener('scroll', (e: Event) => {
|
|
|
+ const height = window.scrollY || window.pageYOffset || document.documentElement.scrollTop
|
|
|
+ data.titleOpacity = height > 100 ? 1 : height / 100
|
|
|
+ })
|
|
|
return () => (
|
|
|
<div class={styles.courseList}>
|
|
|
- <OSticky
|
|
|
- onGetHeight={(height: number) => {
|
|
|
- document.documentElement.style.setProperty('--header-height', height + 'px')
|
|
|
- }}
|
|
|
- >
|
|
|
- <OHeader
|
|
|
- border={false}
|
|
|
- background="transparent"
|
|
|
- color="rgba(124, 61, 18, 1)"
|
|
|
- title="教材详情"
|
|
|
- />
|
|
|
- </OSticky>
|
|
|
-
|
|
|
+ <OHeader
|
|
|
+ border={false}
|
|
|
+ background={`rgba(255,255,255, ${data.titleOpacity})`}
|
|
|
+ color="rgba(124, 61, 18, 1)"
|
|
|
+ title="教材详情"
|
|
|
+ />
|
|
|
<div class={styles.periodContent}>
|
|
|
- <Image class={styles.cover} src={data.detail.cover}>
|
|
|
- {{
|
|
|
- loading: () => <Loading />
|
|
|
- }}
|
|
|
- </Image>
|
|
|
- {/* <img class={styles.cover} src={data.detail.cover} /> */}
|
|
|
+ <div class={styles.cover}>
|
|
|
+ <img
|
|
|
+ src={data.detail.cover}
|
|
|
+ onLoad={(e: Event) => {
|
|
|
+ if (e.target) {
|
|
|
+ ;(e.target as any).style.opacity = 1
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
<div>
|
|
|
<div class={styles.contentTitle}>{data.detail.name}</div>
|
|
|
<div class={styles.contentLabel}>教学目标:{data.detail.des}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <div class={styles.periodTitle}>
|
|
|
- <img class={styles.pIcon} src={iconList} />
|
|
|
- <div class={styles.pTitle}>课程列表</div>
|
|
|
- <div class={styles.pNum}>共{data.list.length}课</div>
|
|
|
- </div>
|
|
|
+ <TransitionGroup name="van-fade">
|
|
|
+ {!data.loading && (
|
|
|
+ <>
|
|
|
+ <div key="periodTitle" class={styles.periodTitle}>
|
|
|
+ <img class={styles.pIcon} src={iconList} />
|
|
|
+ <div class={styles.pTitle}>课程列表</div>
|
|
|
+ <div class={styles.pNum}>共{data.list.length}课</div>
|
|
|
+ </div>
|
|
|
|
|
|
- <div class={styles.periodList}>
|
|
|
- <CellGroup inset>
|
|
|
- {data.list.map((item: any) => {
|
|
|
- const isLock =
|
|
|
- item.lockFlag ||
|
|
|
- ((route.query.code == 'select' || state.platformType == 'STUDENT') && !item.unlock)
|
|
|
+ <div key="list" class={styles.periodList}>
|
|
|
+ <CellGroup inset>
|
|
|
+ {data.list.map((item: any) => {
|
|
|
+ const isLock =
|
|
|
+ item.lockFlag ||
|
|
|
+ ((route.query.code == 'select' || state.platformType == 'STUDENT') &&
|
|
|
+ !item.unlock)
|
|
|
|
|
|
- const isSelect = route.query.code === 'select'
|
|
|
- return (
|
|
|
- <Cell
|
|
|
- border
|
|
|
- center
|
|
|
- title={item.coursewareDetailName}
|
|
|
- label={!browserInfo.isStudent ? `已使用${item.useNum || 0}次` : ''}
|
|
|
- onClick={() => !isLock && handleClick(item)}
|
|
|
- >
|
|
|
- {{
|
|
|
- icon: () => (
|
|
|
- <div class={styles.periodItem}>
|
|
|
- <div class={styles.periodItemModel}>
|
|
|
- <img src={isLock ? iconCourseLock : iconCourse} />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- ),
|
|
|
- value: () => (
|
|
|
- <>
|
|
|
- {isSelect ? (
|
|
|
- <Button
|
|
|
- disabled={isLock}
|
|
|
- class={[styles.baseBtn, isLock ? styles.disable : styles.look]}
|
|
|
- >
|
|
|
- 选择
|
|
|
- </Button>
|
|
|
- ) : item.knowledgePointList ? (
|
|
|
- <>
|
|
|
- {item.hasCache ? (
|
|
|
- <Button disabled={isLock} class={[styles.baseBtn, isLock ? styles.disable : styles.look]}>查看</Button>
|
|
|
- ) : (
|
|
|
- <Button
|
|
|
- disabled={isLock}
|
|
|
- class={[
|
|
|
- styles.baseBtn,
|
|
|
- isLock ? styles.disable : styles.down,
|
|
|
- item.downloadStatus ? styles.downing : ''
|
|
|
- ]}
|
|
|
- >
|
|
|
- {item.downloadStatus === 1
|
|
|
- ? `下载中 ${item.progress || 0}%`
|
|
|
- : item.downloadStatus === 2
|
|
|
- ? '下载成功'
|
|
|
- : item.downloadStatus === 3
|
|
|
- ? '重新下载'
|
|
|
- : '下载'}
|
|
|
- </Button>
|
|
|
- )}
|
|
|
- </>
|
|
|
- ) : (
|
|
|
- ''
|
|
|
- )}
|
|
|
- </>
|
|
|
+ const isSelect = route.query.code === 'select'
|
|
|
+ return (
|
|
|
+ <Cell
|
|
|
+ border
|
|
|
+ center
|
|
|
+ title={item.coursewareDetailName}
|
|
|
+ label={!browserInfo.isStudent ? `已使用${item.useNum || 0}次` : ''}
|
|
|
+ onClick={() => !isLock && handleClick(item)}
|
|
|
+ >
|
|
|
+ {{
|
|
|
+ icon: () => (
|
|
|
+ <div class={styles.periodItem}>
|
|
|
+ <div class={styles.periodItemModel}>
|
|
|
+ <img src={isLock ? iconCourseLock : iconCourse} />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ ),
|
|
|
+ value: () => (
|
|
|
+ <>
|
|
|
+ {isSelect ? (
|
|
|
+ <Button
|
|
|
+ disabled={isLock}
|
|
|
+ class={[styles.baseBtn, isLock ? styles.disable : styles.look]}
|
|
|
+ >
|
|
|
+ 选择
|
|
|
+ </Button>
|
|
|
+ ) : item.knowledgePointList ? (
|
|
|
+ <>
|
|
|
+ {item.hasCache ? (
|
|
|
+ <Button
|
|
|
+ disabled={isLock}
|
|
|
+ class={[
|
|
|
+ styles.baseBtn,
|
|
|
+ isLock ? styles.disable : styles.look
|
|
|
+ ]}
|
|
|
+ >
|
|
|
+ 查看
|
|
|
+ </Button>
|
|
|
+ ) : (
|
|
|
+ <Button
|
|
|
+ disabled={isLock}
|
|
|
+ class={[
|
|
|
+ styles.baseBtn,
|
|
|
+ isLock ? styles.disable : styles.down,
|
|
|
+ item.downloadStatus ? styles.downing : ''
|
|
|
+ ]}
|
|
|
+ >
|
|
|
+ {item.downloadStatus === 1
|
|
|
+ ? `下载中 ${item.progress || 0}%`
|
|
|
+ : item.downloadStatus === 2
|
|
|
+ ? '下载成功'
|
|
|
+ : item.downloadStatus === 3
|
|
|
+ ? '重新下载'
|
|
|
+ : '下载'}
|
|
|
+ </Button>
|
|
|
+ )}
|
|
|
+ </>
|
|
|
+ ) : (
|
|
|
+ ''
|
|
|
+ )}
|
|
|
+ </>
|
|
|
+ )
|
|
|
+ }}
|
|
|
+ </Cell>
|
|
|
)
|
|
|
- }}
|
|
|
- </Cell>
|
|
|
- )
|
|
|
- })}
|
|
|
- </CellGroup>
|
|
|
- </div>
|
|
|
-
|
|
|
+ })}
|
|
|
+ </CellGroup>
|
|
|
+ </div>
|
|
|
+ </>
|
|
|
+ )}
|
|
|
+ </TransitionGroup>
|
|
|
+ {data.loading && <OLoading />}
|
|
|
{!data.loading && !data.list.length && <OEmpty tips="暂无内容" />}
|
|
|
</div>
|
|
|
)
|