1 |
- import{d as y,P as K,x as S,e as b,y as B,a as i,W as M,a2 as T,C as v,D as m,R as q}from"./index-521a9826.js";import{M as x}from"./index-c0ea6da9.js";import{s as u}from"./index.module-35f2589f.js";import{a as E,u as H}from"./index-fdaad3c0.js";const O=y({name:"unit-detail",setup(){const D=K(),{x:N,y:I}=E(),e=S({detailId:D.query.detailId,loading:!1,background:"transparent",color:"transparent",dataInfo:{},title:" ",listKnowledge:[],prevDetailId:"",nextDetailId:""}),p=async()=>{e.loading=!0;try{const{data:a}=await m.get("/edu-app/lessonCoursewareKnowledgeDetail/detail/"+e.detailId);e.dataInfo=a,e.title=a.name}catch(a){}e.loading=!1},L=async()=>{try{const a={lessonCoursewareId:D.query.lessonCoursewareId};q().ios&&(a.platform="iOS-STUDENT",a.verson=D.query.verson||"1.0.8");const{data:n}=await m.post("/edu-app/lessonCoursewareDetail/listKnowledge",{data:a});e.listKnowledge=n||[]}catch(a){}},h=b(()=>{var f,w,g;const a=e.listKnowledge||[];let n=a.findIndex(t=>{var s;return t.id===((s=e.dataInfo)==null?void 0:s.lessonCoursewareDetailId)});const l=a.find(t=>{var s;return t.id===((s=e.dataInfo)==null?void 0:s.lessonCoursewareDetailId)});if(!l)return!0;let d=(f=l==null?void 0:l.lessonCoursewareDetailKnowledgeDetailList)==null?void 0:f.findIndex(t=>t.id==e.detailId),c=!1,r="";for(;d>=0;){if(d--,d>=0){const t=(w=l==null?void 0:l.lessonCoursewareDetailKnowledgeDetailList)==null?void 0:w[d];t.id&&(c=!0,r=t.id)}if(c)break}if(c)return e.prevDetailId=r,!1;let o=!1;for(;n>=0;){n--;const t=((g=a[n])==null?void 0:g.lessonCoursewareDetailKnowledgeDetailList)||[];let s=t.length;for(;s>0&&(t[s-1]&&(o=!0,r=t[s-1].id),s--,!o););if(o)break}return o&&(e.prevDetailId=r),!o}),k=b(()=>{var f,w,g;const a=e.listKnowledge||[];let n=a.findIndex(t=>{var s;return t.id===((s=e.dataInfo)==null?void 0:s.lessonCoursewareDetailId)});const l=a.find(t=>{var s;return t.id===((s=e.dataInfo)==null?void 0:s.lessonCoursewareDetailId)});if(!l)return!0;let d=(f=l==null?void 0:l.lessonCoursewareDetailKnowledgeDetailList)==null?void 0:f.findIndex(t=>t.id==e.detailId),c=!1,r="";for(;d<(l==null?void 0:l.lessonCoursewareDetailKnowledgeDetailList.length)-1;){if(d++,d>=0){const t=(w=l==null?void 0:l.lessonCoursewareDetailKnowledgeDetailList)==null?void 0:w[d];t.id&&(c=!0,r=t.id)}if(c)break}if(c)return e.nextDetailId=r,!1;let o=!1;for(;n<=a.length-1;){n++;const t=((g=a[n])==null?void 0:g.lessonCoursewareDetailKnowledgeDetailList)||[];let s=0;for(;s<=t.length-1&&(t[s]&&(o=!0,r=t[s].id),s++,!o););if(o)break}return o&&(e.nextDetailId=r),!o}),C=async a=>{I.value=0,window.scrollTo(0,0),a==="up"?(e.detailId=e.prevDetailId,await p()):a==="down"&&(e.detailId=e.nextDetailId,await p())};return B(async()=>{H(document,"scroll",()=>{I.value>52?(e.background="#fff",e.color="#323333"):(e.background="transparent",e.color="transparent")}),await p(),await L()}),()=>{var a,n;return i("div",{class:u.knowledgeLibrary},[i(x,{position:"top"},{default:()=>[i(M,{border:!1,background:e.background,color:e.color,title:e.title},null)]}),i("div",{class:[u.containerSection,u.woringSection]},[((a=e.dataInfo)==null?void 0:a.desc)&&i("div",{class:u.woringContent,innerHTML:e.dataInfo.desc},null),!((n=e.dataInfo)!=null&&n.desc)&&!e.loading&&i("div",{class:u.woringContent},[i(T,{description:"暂无内容",style:{paddingTop:"40px"}},null)])]),i(x,{position:"bottom"},{default:()=>[i("div",{class:[u.stickBtnGroup]},[i(v,{round:!0,class:u.prevBtn,disabled:h.value,onClick:()=>C("up")},null),i(v,{round:!0,disabled:k.value,class:u.nextBtn,onClick:()=>C("down")},null)])]})])}}});export{O as default};
|