var v=(e,r,s)=>new Promise((d,o)=>{var n=i=>{try{u(s.next(i))}catch(m){o(m)}},t=i=>{try{u(s.throw(i))}catch(m){o(m)}},u=i=>i.done?d(i.value):Promise.resolve(i.value).then(n,t);u((s=s.apply(e,r)).next())});import{_ as C,c as f,w as a,R as x,P as k,aB as B,ap as H,r as z,f as S,o as c,k as l,j as I,B as g,L as p,Q as _,p as h,t as w,a1 as P,M as T,i as M,q as b,a6 as D}from"./index-CZJgrp0v.js";import{c as U}from"./eventJava.C13-6nEn.js";import{h as W}from"./common.D2w6zaJ1.js";import{g as L}from"./htmlPreviewTransfer.DE5baVnN.js";const N={regulation:"eventRegulationContent",program:"eventProgramContent"},O={regulation:"eventRegulationAttachment",program:"eventProgramAttachment"},y=794,R={name:"htmlPreview",data(){return{eventId:"",type:"regulation",title:"",htmlContent:"",downloadUrl:"",loading:!0,statusBarHeight:20,navBarHeight:44,screenWidth:375,fitScale:.5,scale:1,contentH:0}},computed:{headerHeight(){return this.statusBarHeight+this.navBarHeight},pageTitle(){return this.title||(this.type==="program"?"秩序册":"竞赛规程")},effScale(){return this.fitScale*this.scale},canvasStyle(){return{width:y+"px",transform:`scale(${this.effScale})`,transformOrigin:"0 0"}},scalerStyle(){return{width:y*this.effScale+"px",height:this.contentH*this.effScale+"px"}},zoomPercent(){return Math.round(this.scale*100)}},methods:{goBack(){B().length>1?H():z({url:"/pages/tabbar/home/index"})},applyPayload(e){this.title=e.title||this.title,this.htmlContent=e.content||"",this.downloadUrl=e.downloadUrl||"",this.measure()},fetchContent(){return v(this,null,function*(){if(!this.eventId){this.loading=!1;return}try{const e=yield U(this.eventId);if(e.code!==0){k({title:e.msg||"获取失败",icon:"none"});return}const r=e.data||{},s=N[this.type],d=O[this.type];this.htmlContent=s&&r[s]||"",this.downloadUrl=d&&r[d]||"",this.measure()}catch(e){console.error("htmlPreview fetch error",e),k({title:"获取内容失败",icon:"none"})}finally{this.loading=!1}})},measure(){this.$nextTick(()=>{const e=document&&document.querySelector(".doc-canvas");e&&(this.contentH=e.scrollHeight||e.offsetHeight||0)})},zoomIn(){this.scale=Math.min(this.scale*1.2,4),this.measure()},zoomOut(){this.scale=Math.max(this.scale/1.2,.3),this.measure()},zoomReset(){this.scale=1},handleDownload(){this.downloadUrl&&W(this.downloadUrl,this.pageTitle)}},onLoad(e){this.eventId=e.eventId||"",this.type=e.type||"regulation",this.title=e.title?decodeURIComponent(e.title):"";try{const s=x();this.statusBarHeight=s.statusBarHeight||20,this.screenWidth=s.windowWidth||s.screenWidth||375}catch(s){this.statusBarHeight=20,this.screenWidth=375}this.fitScale=this.screenWidth/y;const r=L();r?(this.applyPayload(r),this.loading=!1):this.fetchContent()}};function A(e,r,s,d,o,n){const t=I,u=b,i=D,m=S("layout-default-uni");return c(),f(m,null,{default:a(()=>[l(t,{class:"preview-page"},{default:a(()=>[l(t,{class:"nav-bar",style:g({paddingTop:o.statusBarHeight+"px"})},{default:a(()=>[l(t,{class:"nav-bar-inner",style:g({height:o.navBarHeight+"px"})},{default:a(()=>[l(t,{class:"nav-back",onClick:n.goBack},{default:a(()=>[(c(),p("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"none",stroke:"#303133","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[_("path",{d:"M15 18l-6-6 6-6"})]))]),_:1},8,["onClick"]),l(t,{class:"nav-title"},{default:a(()=>[h(w(n.pageTitle),1)]),_:1}),l(t,{class:P(["nav-download",{"is-disabled":!o.downloadUrl}]),onClick:n.handleDownload},{default:a(()=>[(c(),p("svg",{viewBox:"0 0 24 24",width:"22",height:"22",fill:"none",stroke:"#0067c0","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[_("path",{d:"M12 3v12"}),_("path",{d:"M7 10l5 5 5-5"}),_("path",{d:"M5 19h14"})]))]),_:1},8,["class","onClick"])]),_:1},8,["style"])]),_:1},8,["style"]),l(t,{class:"preview-body",style:g({paddingTop:n.headerHeight+"px"})},{default:a(()=>[o.loading?(c(),f(t,{key:0,class:"preview-loading"},{default:a(()=>[h("加载中...")]),_:1})):(c(),p(T,{key:1},[o.htmlContent?(c(),f(t,{key:0,class:"doc-scroll"},{default:a(()=>[l(t,{class:"doc-scaler",style:g(n.scalerStyle)},{default:a(()=>[l(t,{class:"doc-canvas",style:g(n.canvasStyle),innerHTML:o.htmlContent},null,8,["style","innerHTML"])]),_:1},8,["style"])]),_:1})):M("",!0),o.htmlContent?(c(),f(t,{key:1,class:"zoom-bar"},{default:a(()=>[l(t,{class:"zoom-btn",onClick:n.zoomOut},{default:a(()=>[h("－")]),_:1},8,["onClick"]),l(u,{class:"zoom-val",onClick:n.zoomReset},{default:a(()=>[h(w(n.zoomPercent)+"%",1)]),_:1},8,["onClick"]),l(t,{class:"zoom-btn",onClick:n.zoomIn},{default:a(()=>[h("＋")]),_:1},8,["onClick"]),l(t,{class:"zoom-fit",onClick:n.zoomReset},{default:a(()=>[h("适应宽度")]),_:1},8,["onClick"])]),_:1})):(c(),f(i,{key:2}))],64))]),_:1},8,["style"])]),_:1})]),_:1})}const Q=C(R,[["render",A],["__scopeId","data-v-a59ad033"]]);export{Q as default};
