|
@@ -11,7 +11,9 @@ import {
|
|
|
Icon,
|
|
|
Image,
|
|
|
Loading,
|
|
|
+ Popup,
|
|
|
showConfirmDialog,
|
|
|
+ showLoadingToast,
|
|
|
showToast,
|
|
|
Skeleton,
|
|
|
SkeletonImage,
|
|
@@ -35,6 +37,7 @@ import {
|
|
|
removeListenerMessage
|
|
|
} from '@/helpers/native-message'
|
|
|
import iconLook from './image/look.svg'
|
|
|
+import iconCachePoint from './image/icon-cache-point.png'
|
|
|
import iconCourse from './image/icon-course.png'
|
|
|
import iconCourseLock from './image/icon-course-lock.png'
|
|
|
import iconTip from './image/iconTip.png'
|
|
@@ -63,7 +66,8 @@ export default defineComponent({
|
|
|
name: '',
|
|
|
des: ''
|
|
|
},
|
|
|
- list: [] as any
|
|
|
+ list: [] as any,
|
|
|
+ isDownloading: false // 是否在下载资源
|
|
|
})
|
|
|
|
|
|
/** 获取课件详情 */
|
|
@@ -171,13 +175,26 @@ export default defineComponent({
|
|
|
|
|
|
if (!item.hasCache) {
|
|
|
const hasFree = String(item.accessScope) === '0'
|
|
|
- if (!hasFree){
|
|
|
+ if (!hasFree) {
|
|
|
const hasVip = handleCheckVip()
|
|
|
if (!hasVip) return
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 下载中不提示
|
|
|
if (item.downloadStatus == 1) {
|
|
|
+ // 取消下载
|
|
|
+ postMessage({ api: 'cancelDownloadCourseware' })
|
|
|
+ setTimeout(() => {
|
|
|
+ postMessage({ api: 'cancelDownloadCourseware' })
|
|
|
+ item.downloadStatus = 0
|
|
|
+ data.isDownloading = false
|
|
|
+ }, 1000)
|
|
|
+ showLoadingToast({
|
|
|
+ message: '取消中...',
|
|
|
+ forbidClick: false,
|
|
|
+ loadingType: 'spinner',
|
|
|
+ duration: 1000
|
|
|
+ })
|
|
|
return
|
|
|
}
|
|
|
// 重新下载
|
|
@@ -187,6 +204,17 @@ export default defineComponent({
|
|
|
}
|
|
|
data.catchStatus = true
|
|
|
data.catchItem = item
|
|
|
+ // 下载中不提示
|
|
|
+ // if (item.downloadStatus == 1) {
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // // 重新下载
|
|
|
+ // if (item.downloadStatus == 3) {
|
|
|
+ // downCatch(item)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // data.catchStatus = true
|
|
|
+ // data.catchItem = item
|
|
|
// try {
|
|
|
// await showConfirmDialog({
|
|
|
// message: '当前课程没有缓存,是否缓存?',
|
|
@@ -202,6 +230,7 @@ export default defineComponent({
|
|
|
}
|
|
|
// 去课件播放
|
|
|
const gotoPlay = (item: any) => {
|
|
|
+ data.catchStatus = false
|
|
|
postMessage({
|
|
|
api: 'openWebView',
|
|
|
content: {
|
|
@@ -240,6 +269,8 @@ export default defineComponent({
|
|
|
// 下载缓存
|
|
|
const downCatch = async (item: any) => {
|
|
|
if (browserInfo.isApp) {
|
|
|
+ data.catchStatus = false
|
|
|
+ data.isDownloading = true
|
|
|
const res = await postMessage({
|
|
|
api: 'downloadCoursewareToCache',
|
|
|
content: {
|
|
@@ -254,6 +285,9 @@ export default defineComponent({
|
|
|
// 下载缓存进度
|
|
|
const getProgress = (res: any) => {
|
|
|
// console.log('🚀 ~ res', res)
|
|
|
+ if (!data.isDownloading) {
|
|
|
+ return
|
|
|
+ }
|
|
|
if (res?.content?.lessonCoursewareDetailId) {
|
|
|
const { lessonCoursewareDetailId, downloadStatus, progress } = res.content
|
|
|
const course = data.list.find(
|
|
@@ -265,6 +299,8 @@ export default defineComponent({
|
|
|
if (downloadStatus == 2) {
|
|
|
course.hasCache = 1
|
|
|
course.progress = 100
|
|
|
+ // 下载完成
|
|
|
+ data.isDownloading = false
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -328,7 +364,8 @@ export default defineComponent({
|
|
|
<div key="list" class={styles.periodList}>
|
|
|
<CellGroup inset>
|
|
|
{data.list.map((item: any) => {
|
|
|
- let isLock = item.lockFlag ||
|
|
|
+ const isLock =
|
|
|
+ item.lockFlag ||
|
|
|
((route.query.code == 'select' || state.platformType == 'STUDENT') &&
|
|
|
!item.unlock)
|
|
|
const isSelect = route.query.code === 'select'
|
|
@@ -344,8 +381,19 @@ export default defineComponent({
|
|
|
icon: () => (
|
|
|
<div class={styles.periodItem}>
|
|
|
<div class={styles.periodItemModel}>
|
|
|
- <img src={ isLock ? iconCourseLock : iconCourse} />
|
|
|
- {!isLock && String(item.accessScope) === '0' && <img class={styles.periodTip} src={iconTip} />}
|
|
|
+ <img src={isLock ? iconCourseLock : iconCourse} />
|
|
|
+ {!isLock && String(item.accessScope) === '0' && (
|
|
|
+ <img class={styles.periodTip} src={iconTip} />
|
|
|
+ )}
|
|
|
+
|
|
|
+ {item.hasCache ? (
|
|
|
+ <img class={styles.iconCachePoint} src={iconCachePoint} />
|
|
|
+ ) : (
|
|
|
+ ''
|
|
|
+ )}
|
|
|
+ {item.downloadStatus === 1 && (
|
|
|
+ <div class={styles.downloading}>{`${item.progress || 0}%`}</div>
|
|
|
+ )}
|
|
|
</div>
|
|
|
</div>
|
|
|
),
|
|
@@ -362,7 +410,6 @@ export default defineComponent({
|
|
|
<>
|
|
|
{item.hasCache ? (
|
|
|
<Button
|
|
|
- disabled={isLock}
|
|
|
class={[
|
|
|
styles.baseBtn,
|
|
|
isLock ? styles.disable : styles.look
|
|
@@ -372,20 +419,13 @@ export default defineComponent({
|
|
|
</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
|
|
|
- ? '重试'
|
|
|
- : '下载'}
|
|
|
+ {item.downloadStatus === 1 ? `取消下载` : '查看'}
|
|
|
</Button>
|
|
|
)}
|
|
|
</>
|
|
@@ -406,29 +446,23 @@ export default defineComponent({
|
|
|
{data.loading && <OLoading />}
|
|
|
{!data.loading && !data.list.length && <OEmpty tips="暂无内容" />}
|
|
|
|
|
|
- <Dialog
|
|
|
- v-model:show={data.catchStatus}
|
|
|
- showCancelButton
|
|
|
- message={'当前课程没有缓存,是否缓存?'}
|
|
|
- closeOnClickOverlay
|
|
|
- class={styles.courseDialog}
|
|
|
- onConfirm={() => {
|
|
|
- downCatch(data.catchItem)
|
|
|
- }}
|
|
|
- onCancel={() => {
|
|
|
- gotoPlay(data.catchItem)
|
|
|
- }}
|
|
|
- >
|
|
|
- {{
|
|
|
- title: () => (
|
|
|
- <Icon
|
|
|
- name="cross"
|
|
|
- class={styles.iconCross}
|
|
|
- onClick={() => (data.catchStatus = false)}
|
|
|
- />
|
|
|
- )
|
|
|
- }}
|
|
|
- </Dialog>
|
|
|
+ <Popup v-model:show={data.catchStatus} round class={styles.courseDialog}>
|
|
|
+ <i class={styles.iconClose} onClick={() => (data.catchStatus = false)}></i>
|
|
|
+ <div class={styles.title}>下载提醒</div>
|
|
|
+
|
|
|
+ <div class={styles.content}>
|
|
|
+ 您尚未下载课件内容,为了更加流畅的学习体验,推荐您下载后观看课件。
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class={styles.popupBtnGroup}>
|
|
|
+ <Button round onClick={() => gotoPlay(data.catchItem)}>
|
|
|
+ 直接观看
|
|
|
+ </Button>
|
|
|
+ <Button round type="primary" onClick={() => downCatch(data.catchItem)}>
|
|
|
+ 下载课件
|
|
|
+ </Button>
|
|
|
+ </div>
|
|
|
+ </Popup>
|
|
|
</div>
|
|
|
)
|
|
|
}
|