|
@@ -1,12 +1,13 @@
|
|
|
import request from '@/helpers/request';
|
|
|
import { state } from '@/state';
|
|
|
-import { Button, Cell, CellGroup, Popup } from 'vant';
|
|
|
+import { Button, Cell, CellGroup, Popup, showConfirmDialog } from 'vant';
|
|
|
import {
|
|
|
defineComponent,
|
|
|
onMounted,
|
|
|
reactive,
|
|
|
onUnmounted,
|
|
|
- TransitionGroup
|
|
|
+ TransitionGroup,
|
|
|
+ computed
|
|
|
} from 'vue';
|
|
|
import styles from './index.module.less';
|
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
@@ -17,11 +18,12 @@ import {
|
|
|
} from '@/helpers/native-message';
|
|
|
// import iconLook from './image/look.svg'
|
|
|
import iconCourse from './image/icon-course.png';
|
|
|
+import iconCachePoint from './image/icon-cache-point.png';
|
|
|
// import iconCourseLock from './image/icon-course-lock.png';
|
|
|
// import iconTip from './image/iconTip.png';
|
|
|
import { browser } from '@/helpers/utils';
|
|
|
import OEmpty from '@/components/o-empty';
|
|
|
-import { handleCheckVip } from '../hook/useFee';
|
|
|
+import { handleCheckVip, hasVip } from '../hook/useFee';
|
|
|
import iconList from './image/icon-list.png';
|
|
|
// import OSticky from '@/components/o-sticky';
|
|
|
import OHeader from '@/components/o-header';
|
|
@@ -68,88 +70,38 @@ export default defineComponent({
|
|
|
);
|
|
|
if (Array.isArray(res?.data)) {
|
|
|
data.list = 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;
|
|
|
+ res.data.forEach((item: any) => {
|
|
|
+ const { knowledgePointList, ...res } = item;
|
|
|
+ const tempK = knowledgePointList || [];
|
|
|
+ tempK.forEach((child: any) => {
|
|
|
+ child.materialList = [
|
|
|
+ ...(child.materialList || []),
|
|
|
+ ...getKnowledgeMaterials(child.children || [])
|
|
|
+ ];
|
|
|
+ child.children = null;
|
|
|
+ });
|
|
|
+ });
|
|
|
|
|
|
- console.log(data.list, 'list');
|
|
|
+ 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) {
|
|
|
//
|
|
|
}
|
|
|
- // if (route.query.courseScheduleId) {
|
|
|
- // try {
|
|
|
- // const res: any = await request.post(
|
|
|
- // state.platformApi + '/lessonCourseware/getLessonCoursewareDetail',
|
|
|
- // {
|
|
|
- // params: {
|
|
|
- // courseScheduleId: route.query.courseScheduleId,
|
|
|
- // coursewareId: route.query.id
|
|
|
- // }
|
|
|
- // }
|
|
|
- // );
|
|
|
- // if (Array.isArray(res?.data)) {
|
|
|
- // data.list = res.data;
|
|
|
- // }
|
|
|
- // } catch (error) {
|
|
|
- // //
|
|
|
- // }
|
|
|
- // } else {
|
|
|
- // try {
|
|
|
- // const res: any = await request.post(
|
|
|
- // state.platformApi +
|
|
|
- // '/courseSchedule/myCoursewareDetail/' +
|
|
|
- // route.query.id
|
|
|
- // );
|
|
|
- // if (Array.isArray(res?.data)) {
|
|
|
- // res.data.forEach((item: any) => {
|
|
|
- // const { knowledgePointList, ...res } = item;
|
|
|
- // const tempK = knowledgePointList || [];
|
|
|
- // tempK.forEach((child: any) => {
|
|
|
- // child.materialList = [
|
|
|
- // ...(child.materialList || []),
|
|
|
- // ...getKnowledgeMaterials(child.children || [])
|
|
|
- // ];
|
|
|
- // child.children = null;
|
|
|
- // });
|
|
|
- // });
|
|
|
-
|
|
|
- // 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) {
|
|
|
- // //
|
|
|
- // }
|
|
|
- // }
|
|
|
data.loading = false;
|
|
|
};
|
|
|
// 获取子节点数据
|
|
@@ -167,6 +119,11 @@ export default defineComponent({
|
|
|
return tempList;
|
|
|
};
|
|
|
|
|
|
+ // 去购买
|
|
|
+ const onGoVip = () => {
|
|
|
+ window.location.href = location.origin + '/#/member';
|
|
|
+ };
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
getDetail();
|
|
|
getList();
|
|
@@ -177,22 +134,23 @@ export default defineComponent({
|
|
|
});
|
|
|
|
|
|
const handleClick = async (item: any) => {
|
|
|
- // if (!item.knowledgePointList) {
|
|
|
- // showConfirmDialog({
|
|
|
- // message: '该课件暂无知识点'
|
|
|
- // });
|
|
|
- // return;
|
|
|
- // }
|
|
|
+ if (!item.knowledgePointList) {
|
|
|
+ showConfirmDialog({
|
|
|
+ message: '该课件暂无知识点'
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
if (!item.hasCache) {
|
|
|
- const hasFree = String(item.accessScope) === '0';
|
|
|
- if (!hasFree) {
|
|
|
- const hasVip = handleCheckVip();
|
|
|
- if (!hasVip) return;
|
|
|
- }
|
|
|
+ // const hasFree = String(item.accessScope) === '0';
|
|
|
+ // if (!hasFree) {
|
|
|
+ const isVip = handleCheckVip();
|
|
|
+ if (!isVip) return;
|
|
|
|
|
|
// 下载中不提示
|
|
|
if (item.downloadStatus == 1) {
|
|
|
+ // 取消下载
|
|
|
+ postMessage({ api: 'cancelDownloadCourseware' });
|
|
|
return;
|
|
|
}
|
|
|
// 重新下载
|
|
@@ -351,9 +309,17 @@ export default defineComponent({
|
|
|
<div class={styles.periodItem}>
|
|
|
<div class={styles.periodItemModel}>
|
|
|
<img src={iconCourse} />
|
|
|
- {/* {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>
|
|
|
),
|
|
@@ -363,20 +329,22 @@ export default defineComponent({
|
|
|
<>
|
|
|
{item.hasCache ? (
|
|
|
<Button
|
|
|
+ disabled={!hasVip()}
|
|
|
class={[styles.baseBtn, styles.look]}>
|
|
|
查看
|
|
|
</Button>
|
|
|
) : (
|
|
|
<Button
|
|
|
+ disabled={!hasVip()}
|
|
|
class={[
|
|
|
styles.baseBtn,
|
|
|
styles.down,
|
|
|
- item.downloadStatus
|
|
|
+ item.downloadStatus == 1
|
|
|
? styles.downing
|
|
|
: ''
|
|
|
]}>
|
|
|
{item.downloadStatus === 1
|
|
|
- ? `${item.progress || 0}%`
|
|
|
+ ? `取消下载`
|
|
|
: item.downloadStatus === 2
|
|
|
? '成功'
|
|
|
: item.downloadStatus === 3
|
|
@@ -402,13 +370,15 @@ export default defineComponent({
|
|
|
{data.loading && <OLoading />}
|
|
|
{!data.loading && !data.list.length && <OEmpty tips="暂无内容" />}
|
|
|
|
|
|
- <OSticky position="bottom">
|
|
|
- <div class={styles.btnGroup}>
|
|
|
- <Button round block type="primary">
|
|
|
- 开通会员即可查看所有课件
|
|
|
- </Button>
|
|
|
- </div>
|
|
|
- </OSticky>
|
|
|
+ {!hasVip() && (
|
|
|
+ <OSticky position="bottom">
|
|
|
+ <div class={styles.btnGroup}>
|
|
|
+ <Button round block type="primary" onClick={onGoVip}>
|
|
|
+ 开通会员即可查看所有课件
|
|
|
+ </Button>
|
|
|
+ </div>
|
|
|
+ </OSticky>
|
|
|
+ )}
|
|
|
|
|
|
<Popup
|
|
|
v-model:show={data.catchStatus}
|