1 |
- import{d as S,aV as q,ag as A,e as F,r as j,$ as E,bF as T,a_ as B,bG as V,c as s,q as r,F as g,a5 as m,f as d,ai as L,ak as N,m as w,b6 as f,k as p}from"./index.83786b38.js";import{i as P}from"./icon-course.310d3f1d.js";import{h as x}from"./useFee.8fdfcfb4.js";import{G,a as M}from"./index.e79bbb95.js";const O="_grid_ijbys_1",$="_gridItem_ijbys_8",R="_cover_ijbys_15",U="_title_ijbys_27",H="_subtitle_ijbys_33",W="_num_ijbys_37",z="_look_ijbys_52";var o={grid:O,gridItem:$,cover:R,title:U,subtitle:H,num:W,look:z},J="./assets/look.aaa3d432.svg";function K(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!N(t)}var ee=S({name:"lessonCourseware",setup(){const t=q();A();const c=F(),u=j({loading:!0,list:[]}),C=async()=>{if(u.loading=!0,t.query.courseScheduleId)try{const e=await w.post(d.platformApi+"/courseSchedule/getCoursewareDetail",{params:{courseScheduleId:t.query.courseScheduleId,coursewareId:t.query.id}});Array.isArray(e==null?void 0:e.data)&&(u.list=e.data)}catch{}else try{const e=await w.post(d.platformApi+"/courseSchedule/myCoursewareDetail/"+t.query.id);Array.isArray(e==null?void 0:e.data)&&(u.list=c.isApp?await _(e.data):e.data)}catch{}u.loading=!1};E(()=>{C(),T("downloadCoursewareToCache",h)}),B(()=>{V("downloadCoursewareToCache",h)});const v=async e=>{if(!e.knowledgePointList){f({message:"\u8BE5\u8BFE\u4EF6\u6682\u65E0\u77E5\u8BC6\u70B9"});return}if(t.query.code==="select"){console.log("\u9009\u62E9\u8BFE\u65F6"),D(e);return}if(!e.hasCache){if(c.isStudent||t.query.isdev){if(!x())return;try{await f({message:"\u5F53\u524D\u8BFE\u7A0B\u6CA1\u6709\u7F13\u5B58,\u662F\u5426\u7F13\u5B58?"})}catch{y(e);return}}b(e);return}y(e)},y=e=>{p({api:"openWebView",content:{url:`${location.origin}${location.pathname}/#/coursewarePlay?id=${e.lessonCoursewareDetailId}`,orientation:0,isHideTitle:!0,statusBarTextColor:!1,isOpenLight:!0,showLoadingAnim:!0}})},_=e=>new Promise(a=>{p({api:"checkCoursewareCache",content:{data:e}},n=>{var i;if((i=n==null?void 0:n.content)!=null&&i.data){a(n.content.data);return}return[]})}),b=async e=>c.isApp?await p({api:"downloadCoursewareToCache",content:{data:e}}):!0,h=e=>{var a;if((a=e==null?void 0:e.content)!=null&&a.lessonCoursewareDetailId){const{lessonCoursewareDetailId:n,downloadStatus:i,progress:I}=e.content,l=u.list.find(k=>k.lessonCoursewareDetailId==n);l&&(l.downloadStatus=i,l.progress=I,i==2&&(l.hasCache=1,l.progress=100))}},D=async e=>{try{(await w.post(d.platformApi+"/courseSchedule/setCoursewareDetail",{params:{courseScheduleId:t.query.courseScheduleId,coursewareDetailId:e.lessonCoursewareDetailId}})).code===200&&p({api:"back"})}catch{}};return()=>{let e;return s("div",{style:{paddingTop:"14px"}},[s(G,{gutter:14,columnNum:3,class:o.grid},K(e=u.list.map(a=>s(M,null,{default:()=>[s("div",{class:o.gridItem,onClick:()=>v(a)},[s("img",{src:P,class:o.cover},null),s("div",{class:o.title},[s("div",{class:"van-multi-ellipsis--l2"},[a.coursewareDetailName]),!c.isStudent&&s("div",{class:o.subtitle},[r("\u5DF2\u4F7F\u7528 "),a.useNum,r(" \u6B21")])]),t.query.code!=="select"?s(g,null,[!!a.knowledgePointList&&s(g,null,[a.hasCache?s("div",{class:o.num},[r("\u67E5\u770B"),s(m,{name:"play-circle-o"},null)]):s(g,null,[a.downloadStatus===1?s("div",{class:o.num},[r("\u4E0B\u8F7D\u4E2D "),a.progress||0,r("%")]):a.downloadStatus===2?s("div",{class:o.num},[r("\u4E0B\u8F7D\u6210\u529F")]):a.downloadStatus===3?s("div",{class:o.num},[r("\u91CD\u65B0\u4E0B\u8F7D")]):s("div",{class:o.num},[r("\u4E0B\u8F7D")])])])]):s("div",{class:o.num},[r("\u9009\u62E9")]),(t.query.code=="select"||d.platformType=="STUDENT")&&!a.unlock&&s("div",{class:o.look,onClick:n=>n.stopPropagation()},[s(m,{name:J},null),r(" \u672A\u89E3\u9501")])])]})))?e:{default:()=>[e]}),!u.loading&&!u.list.length&&s(L,{tips:"\u6682\u65E0\u5185\u5BB9"},null)])}}});export{ee as default};
|