lex 1 年間 前
コミット
2b8d46b773

+ 1 - 1
src/helpers/request.ts

@@ -124,7 +124,7 @@ request.interceptors.response.use(
         showToast(msg);
       }
       const browserInfo = browser();
-      if (data.code === 5000) {
+      if (data.code === 5000 || data.code === 403) {
         msg += '5000';
         if (browserInfo.isApp) {
           postMessage({

BIN
src/views/courseList/image/icon-cache-point.png


+ 32 - 2
src/views/courseList/index.module.less

@@ -161,11 +161,16 @@
     }
 
     &.look {
-      background: linear-gradient(180deg, #FFAB71 0%, #FF6E45 100%);
+      background: linear-gradient(270deg, #4BE0A1 0%, #01C1B5 100%);
     }
 
     &.down {
-      background: linear-gradient(180deg, #80C6FF 0%, #4296FF 100%);
+      background: linear-gradient(270deg, #4BE0A1 0%, #01C1B5 100%);
+      ;
+    }
+
+    &.downing {
+      background: linear-gradient(270deg, #47CFE5 0%, #2FB3FF 100%);
     }
 
     &.disable {
@@ -210,6 +215,16 @@
 .periodItemModel {
   position: relative;
 
+  .iconCachePoint {
+    position: absolute;
+    right: 0;
+    bottom: 0;
+    display: block;
+    object-fit: contain;
+    width: 13px;
+    height: 13px;
+  }
+
   .periodTip {
     position: absolute;
     left: -7px;
@@ -218,6 +233,21 @@
     display: block;
     object-fit: contain;
   }
+
+  .downloading {
+    position: absolute;
+    left: 0;
+    right: 0;
+    bottom: 0;
+    top: 0;
+    background: rgba(0, 0, 0, 0.4);
+    font-size: 11px;
+    color: #fff;
+    border-radius: 9px;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+  }
 }
 
 .btnGroup {

+ 74 - 104
src/views/courseList/index.tsx

@@ -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}

+ 18 - 14
src/views/coursewarePlay/index.tsx

@@ -145,7 +145,7 @@ export default defineComponent({
           localPath: '',
           materialId: material.materialId,
           updateTime: material.updateTime,
-          type: material.type // SONG VIDEO IMAGE
+          type: material.typeCode // SONG VIDEO IMAGE
         }
       });
       // console.log('缓存路径返回', res)
@@ -178,7 +178,7 @@ export default defineComponent({
       for (let j = 0; j < materialList.length; j++) {
         const material = materialList[j];
         //请求本地缓存
-        if (browserInfo.isApp && ['VIDEO', 'IMG'].includes(material.type)) {
+        if (browserInfo.isApp && ['VIDEO', 'IMG'].includes(material.typeCode)) {
           const localData = await getCacheFilePath(material);
           if (localData?.content?.localPath) {
             material.url = material.content;
@@ -396,7 +396,7 @@ export default defineComponent({
       }
       console.log('视频暂停完成');
       data.itemList.forEach((item: any) => {
-        if (item.type === 'SONG') {
+        if (item.typeCode === 'SONG') {
           item.iframeRef?.contentWindow?.postMessage(
             { api: 'setPlayState' },
             '*'
@@ -444,7 +444,7 @@ export default defineComponent({
 
     // 双击
     const handleDbClick = () => {
-      if (activeVideoItem.value.type === 'VIDEO') {
+      if (activeVideoItem.value.typeCode === 'VIDEO') {
         const activeVideoRef = data.videoItemRef?.getVideoRef();
         if (activeVideoRef) {
           if (activeVideoRef.paused) {
@@ -538,7 +538,7 @@ export default defineComponent({
               popupData.itemActive = item.id;
               popupData.itemName = item.name;
               popupData.tabName = item.tabName;
-              if (item.type == 'SONG') {
+              if (item.typeCode == 'SONG') {
                 activeData.model = true;
               }
             }
@@ -547,7 +547,7 @@ export default defineComponent({
               effectIndex.value =
                 _effectIndex >= effects.length - 1 ? 0 : _effectIndex;
 
-              if (item && item.type === 'VIDEO') {
+              if (item && item.typeCode === 'VIDEO') {
                 // 自动播放下一个视频
                 clearTimeout(activeData.timer);
                 closeToast();
@@ -597,7 +597,7 @@ export default defineComponent({
     /** 弹窗关闭 */
     const handleClosePopup = () => {
       const item = data.itemList[popupData.activeIndex];
-      if (item?.type == 'VIDEO' && !item.videoEle?.paused) {
+      if (item?.typeCode == 'VIDEO' && !item.videoEle?.paused) {
         setModelOpen();
       }
     };
@@ -612,10 +612,10 @@ export default defineComponent({
     const openStudyTool = (item: ToolItem) => {
       const activeItem = data.itemList[popupData.activeIndex];
       // 暂停视频和曲谱的播放
-      if (activeItem.type === 'VIDEO' && activeItem.videoEle) {
+      if (activeItem.typeCode === 'VIDEO' && activeItem.videoEle) {
         activeItem.videoEle.pause();
       }
-      if (activeItem.type === 'SONG') {
+      if (activeItem.typeCode === 'SONG') {
         activeItem.iframeRef?.contentWindow?.postMessage(
           { api: 'setPlayState' },
           '*'
@@ -641,7 +641,11 @@ export default defineComponent({
     const activeVideoItem = computed(() => {
       console.log(data.itemList, ' data.itemList');
       const item = data.itemList[popupData.activeIndex];
-      if (item && item.type && item.type.toLocaleUpperCase() === 'VIDEO') {
+      if (
+        item &&
+        item.typeCode &&
+        item.typeCode.toLocaleUpperCase() === 'VIDEO'
+      ) {
         return item;
       }
       return {};
@@ -668,7 +672,7 @@ export default defineComponent({
           <div class={styles.wraps}>
             <div
               style={
-                activeVideoItem.value.type &&
+                activeVideoItem.value.typeCode &&
                 data.animationState === 'end' &&
                 data.videoState === 'play'
                   ? {
@@ -768,7 +772,7 @@ export default defineComponent({
                       </>
                     )} */}
                   <Transition name="van-fade">
-                    {m.type === 'VIDEO' &&
+                    {m.typeCode === 'VIDEO' &&
                       data.animationState !== 'end' &&
                       data.videoState != 'play' && (
                         <div class={styles.loadWrap}>
@@ -776,8 +780,8 @@ export default defineComponent({
                         </div>
                       )}
                   </Transition>
-                  {isRender && m.type === 'IMG' && <img src={m.content} />}
-                  {isRender && m.type === 'SONG' && (
+                  {isRender && m.typeCode === 'IMG' && <img src={m.content} />}
+                  {isRender && m.typeCode === 'SONG' && (
                     <MusicScore
                       activeModel={activeData.model}
                       data-vid={m.id}

+ 3 - 0
src/views/hook/useFee.ts

@@ -21,6 +21,9 @@ const gotoMemberCenter = () => {
 };
 
 /**验证是否是会员 */
+export const hasVip = () => {
+  return !state.user.data.student.memberRankSettingId ? false : true;
+};
 export const handleCheckVip = () => {
   // 学员端验证
   console.log(state.user);