index.5b575aa3.js 3.8 KB

1
  1. import{d as k,aV as A,ag as F,e as j,r as q,$ as E,bF as T,a_ as B,bG as V,c as s,q as r,F as w,a5 as m,f as c,ai as L,ak as N,m as g,b6 as C,k as d}from"./index.ffe80dbe.js";import{i as P}from"./icon-course.310d3f1d.js";import{h as x}from"./useFee.9e15c3ca.js";import{G,a as M}from"./index.72ca63b9.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=k({name:"lessonCourseware",setup(){const t=A();F();const p=j(),u=q({loading:!0,list:[]}),_=async()=>{if(u.loading=!0,t.query.courseScheduleId)try{const e=await g.post(c.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 g.post(c.platformApi+"/courseSchedule/myCoursewareDetail/"+t.query.id);Array.isArray(e==null?void 0:e.data)&&(u.list=p.isApp?await b(e.data):e.data)}catch{}u.loading=!1};E(()=>{_(),T("downloadCoursewareToCache",f)}),B(()=>{V("downloadCoursewareToCache",f)});const v=async e=>{if(!e.knowledgePointList){C({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(!x()||e.downloadStatus==1)return;if(e.downloadStatus==3){y(e);return}try{await C({message:"\u5F53\u524D\u8BFE\u7A0B\u6CA1\u6709\u7F13\u5B58,\u662F\u5426\u7F13\u5B58?"})}catch{h(e);return}y(e);return}h(e)},h=e=>{d({api:"openWebView",content:{url:`${location.origin}${location.pathname}/#/coursewarePlay?id=${e.lessonCoursewareDetailId}`,orientation:0,isHideTitle:!0,statusBarTextColor:!1,isOpenLight:!0,showLoadingAnim:!0}})},b=e=>new Promise(a=>{d({api:"checkCoursewareCache",content:{data:e}},n=>{var l;if((l=n==null?void 0:n.content)!=null&&l.data){a(n.content.data);return}return[]})}),y=async e=>p.isApp?await d({api:"downloadCoursewareToCache",content:{data:e}}):!0,f=e=>{var a;if((a=e==null?void 0:e.content)!=null&&a.lessonCoursewareDetailId){const{lessonCoursewareDetailId:n,downloadStatus:l,progress:I}=e.content,i=u.list.find(S=>S.lessonCoursewareDetailId==n);i&&(i.downloadStatus=l,i.progress=I,l==2&&(i.hasCache=1,i.progress=100))}},D=async e=>{try{(await g.post(c.platformApi+"/courseSchedule/setCoursewareDetail",{params:{courseScheduleId:t.query.courseScheduleId,coursewareDetailId:e.lessonCoursewareDetailId}})).code===200&&d({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]),!p.isStudent&&s("div",{class:o.subtitle},[r("\u5DF2\u4F7F\u7528 "),a.useNum,r(" \u6B21")])]),t.query.code!=="select"?s(w,null,[!!a.knowledgePointList&&s(w,null,[a.hasCache?s("div",{class:o.num},[r("\u67E5\u770B"),s(m,{name:"play-circle-o"},null)]):s(w,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"||c.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};