index.d2cab9ac.js 5.6 KB

1
  1. import{d as A,Q as T,S as U,U as k,V as d,W as S,X as j,g as R,j as t,Y as B,Z as E,B as o,$ as O,a0 as x,w as y}from"./index.c8a33855.js";import{C as f}from"./index.89b19a2f.js";import{I as u}from"./index.5da3180f.js";import"./index.e91b3eaf.js";import"./index.3dff5bed.js";import{T as M,a as w}from"./index.42df2d54.js";import{I as D,a as F,b as V}from"./icon_level3.5bff162c.js";import{i as m}from"./icon_teacher.40b6f077.js";import"./use-id.c5c54d4f.js";import"./use-tab-status.9eeb64d0.js";import"./use-refs.ef9788ce.js";const N="_headImg_1lc9z_1",$="_tabs_1lc9z_4",q="_tabContent_1lc9z_27",H="_hasUser_1lc9z_35",P="_itemContent_1lc9z_38",Q="_item_1lc9z_38",W="_left_1lc9z_51",X="_center_1lc9z_57",Y="_right_1lc9z_61",Z="_fraction_1lc9z_65",G="_time_1lc9z_71",J="_user_1lc9z_82",K="_userContent_1lc9z_85",tt="_name_1lc9z_90",et="_tag_1lc9z_99",at="_times_1lc9z_107",st="_activeUser_1lc9z_111",rt="_avator_1lc9z_131",nt="_btn_1lc9z_136",it="_num_1lc9z_142";var e={headImg:N,tabs:$,tabContent:q,hasUser:H,itemContent:P,item:Q,left:W,center:X,right:Y,fraction:Z,time:G,user:J,userContent:K,name:tt,tag:et,times:at,activeUser:st,avator:rt,btn:nt,num:it},ct="./assets/icon-emtry.76ea3a6a.png";function ot(l){return typeof l=="function"||Object.prototype.toString.call(l)==="[object Object]"&&!x(l)}var Ct=A({name:"leaderboard",setup(){const l=T();U();const a=k({tabIndex:0,musicList:[],isSignup:!1,isChallenge:!1,rankingMethod:"",score:0}),z=async()=>{try{const{data:s}=await y.post(`/api-student/open/activity/info/${l.query.id}`);a.rankingMethod=s.rankingMethod;const r=s.rankingMethod==="TOTAL_SCORE"?s.subjectInfos:s.activityMusicVoList;Array.isArray(r)&&(a.musicList=r.map(n=>(n.rankingList=[],n)),a.isChallenge=!!r.filter(n=>n.join).length),p.value=s.subjectUrl,a.isSignup=!!s.join}catch{}},h=async()=>{try{const{data:s}=await y.get("/api-student/open/activityEvaluationRecord/queryRankingList",{params:{activityPlanId:l.query.id,activityEvaluationId:a.rankingMethod==="TOTAL_SCORE"?a.musicList[a.tabIndex].subjectId:a.musicList[a.tabIndex].evaluationId,limit:10}});Array.isArray(s.rankingList)&&(a.musicList[a.tabIndex].rankingList=s.rankingList),s.userActivityRankingVo&&(a.score=s.userActivityRankingVo.score)}catch{}},p=d(),b=d(!1),C=d(100);S(async()=>{await z(),await h()});const i=j(()=>{var v,L;if(!a.musicList[a.tabIndex])return{};const s=R.user.data;if(!s.userId)return{};const r=a.musicList[a.tabIndex],n=(v=r==null?void 0:r.rankingList)==null?void 0:v.find(g=>g.userId==s.userId);let c=(L=r==null?void 0:r.rankingList)==null?void 0:L.findIndex(g=>g.userId==s.userId);return c=c>-1?c+1:0,{join:r.join,score:(n==null?void 0:n.score)||0,isTop:!!n,heardUrl:s.heardUrl,username:s.username,userId:s.userId,step:c}}),I=d(),_=d();return()=>{let s;return t("div",{class:e.leaderboard},[t("div",{class:e.container},[t("div",{class:e.headImg,ref:I},[t(u,{width:"100%",fit:"cover",src:p.value,onLoad:r=>{B(()=>{const{height:n}=E(I);b.value=!0,C.value=n||100})},onError:r=>{console.log(r)}},null)]),b.value&&t(M,{active:a.tabIndex,"onUpdate:active":r=>a.tabIndex=r,class:e.tabs,animated:!0,swipeable:!0,titleInactiveColor:"rgba(153,152,155,1)",titleActiveColor:"#fff",onChange:r=>h()},ot(s=a.musicList.map(r=>t(w,{title:a.rankingMethod==="TOTAL_SCORE"?r.subjectName:r.musicSheetName},{default:()=>[t("div",{class:[e.tabContent,i.value.userId&&(!a.isSignup||!a.isChallenge||i.value.join)?e.hasUser:null],style:{height:`calc(100vh - ${C.value}px)`}},[t("div",{class:e.itemContent},[t("div",{class:e.item},[t("div",{class:e.left},[o("\u6392\u540D")]),t("div",{class:e.center},[o("\u6635\u79F0")]),t("div",{class:e.right},[o("\u8BC4\u5206")])]),r.rankingList.map((n,c)=>{const v=(c+1).toString().padStart(2,"0");return t("div",{class:e.item},[t("div",{class:e.left},[c==0&&t(u,{src:D},null),c==1&&t(u,{src:F},null),c==2&&t(u,{src:V},null),c!=0&&c!=1&&c!=2&&v]),t("div",{class:e.center},[t(u,{width:"38px",height:"38px",fit:"cover",round:!0,src:n.userAvatar||m},null),t("div",{class:e.user},[t("div",{class:e.userContent},[t("span",{class:e.name},[n.username]),t("span",{class:e.tag},[n.userSubject])]),t("div",{class:e.times},[n.joinDate])])]),t("div",{class:e.right},[t("div",{class:e.fraction},[n.score,o("\u5206")]),a.rankingMethod!=="TOTAL_SCORE"&&t("div",{class:e.time},[o("\u7B2C "),n.times,o(" \u6B21\u8BC4\u6D4B")])])])}),!r.rankingList.length&&t(O,{image:ct,description:`\u8BE5${a.rankingMethod==="TOTAL_SCORE"?"\u58F0\u90E8":"\u66F2\u76EE"}\u6682\u65E0\u6392\u540D\u5594\uFF5E`},null)]),t("div",{class:"van-safe-area-bottom"},null)])]})))?s:{default:()=>[s]}),i.value.userId&&(a.isSignup?a.isChallenge?i.value.join?t("div",{ref:_,class:[e.activeUser,"van-safe-area-bottom"]},[t(f,{center:!0,title:i.value.username},{icon:()=>t(u,{class:e.avator,fit:"cover",round:!0,src:i.value.heardUrl||m},null),label:()=>i.value.isTop?t("div",null,[o("\u60A8\u7684\u8BC4\u6D4B\u5DF2\u4E0A\u699C! \u5F53\u524D\u6392\u540D"),t("span",{style:{color:"#FA6400"}},[" ",i.value.step])]):t("div",null,[o("\u60A8\u7684\u8BC4\u6D4B\u6682\u672A\u4E0A\u699C\uFF0C\u5FEB\u53BB\u6311\u6218\u5427\uFF01")]),value:()=>{if(!(!i.value.score&&!a.score))return t("span",{class:e.num},[i.value.score||a.score,o("\u5206")])}})]):null:t("div",{ref:_,class:[e.activeUser,"van-safe-area-bottom"]},[t(f,{center:!0,title:i.value.username,label:"\u60A8\u5C1A\u672A\u8BC4\u6D4B\u54E6!"},{icon:()=>t(u,{class:e.avator,fit:"cover",round:!0,src:i.value.heardUrl||m},null)})]):t("div",{ref:_,class:[e.activeUser,"van-safe-area-bottom"]},[t(f,{center:!0,title:i.value.username,label:"\u60A8\u5C1A\u672A\u62A5\u540D\u53C2\u8D5B"},{icon:()=>t(u,{class:e.avator,fit:"cover",round:!0,src:i.value.heardUrl||m},null)})]))])])}}});export{Ct as default};