import{d as P,r,O as F,n as W,aL as z,s as J,a4 as h,N as e,h as w,c as S,a as o,y as g,z as y,t as c,u as s,e as l,w as n,i as B,I as T,R as M,B as X,U as Y,W as j,E as A,X as G,V as H,Y as K}from"./index-4dcc0234.js";/* empty css *//* empty css *//* empty css */import"./el-form-item-4ed993c7.js";/* empty css *//* empty css */import{g as Q}from"./weapp-4d690662.js";import{p as Z}from"./sys-8ead7f22.js";import{b as ee}from"./browser-a1ac24ac.js";const ae={class:"main-container w-[375px] mx-auto mt-[20px] mb-[40px] relative"},te={class:"flex full-container"},oe=["src"],se={class:"w-[375px] border border-slate-100 bg-body pt-[20px] px-[20px]"},le={class:"font-bold text-xl mb-[40px]"},ne={class:"mb-[20px] flex flex-col"},pe={class:"mb-[10px]"},re={key:0,class:"w-[400px] absolute bg-body top-[10%] -right-[450px]"},ce={class:"info-wrap mt-[20px]"},ie={class:"px-[20px] pb-[10px] font-bold"},ue={class:"px-[20px] pb-[10px] font-bold mt-[40px]"},de={class:"text-gray-400"},ke=P({__name:"preview",setup(me){const u=r(""),d=r(""),m=r(""),p=r(""),i=r(!1),_=r(!1),D=r(0),k=r(0),v=F();v.query.page=v.query.page||"",Z().then(a=>{u.value=a.data.wap_url,C()});const O=()=>{if(d.value.trim().length==0){h({type:"warning",message:`${e("wapDomainPlaceholder")}`});return}u.value=d.value+"/wap",C(),Y.set({key:"wap_domain",data:u.value}),i.value=!0,_.value=!1},C=()=>{v.query.page&&(p.value=`${u.value}${v.query.page}`,console.log(p.value),ee.toDataURL(p.value,{errorCorrectionLevel:"L",margin:0,width:100}).then(a=>{m.value=a}),D.value=new Date().getTime(),setTimeout(()=>{k.value==0&&E()},1e3*2))};window.addEventListener("message",a=>{try{const t=JSON.parse(a.data);if(["appOnLaunch","appOnReady"].indexOf(t.type)!=-1){_.value=!1,i.value=!0;const f=new Date().getTime();k.value=f-D.value}}catch(t){E(),console.log("后台接受数据错误",t)}},!1);const E=()=>{_.value=!0,i.value=!1,p.value="",m.value=""},b=W({qr_code:""});Q().then(a=>{if(a.code==1){const t=a.data;b.qr_code=t.qr_code}});const{copy:U,isSupported:R,copied:q}=z(),$=a=>{R.value||h({message:e("notSupportCopy"),type:"warning"}),U(a)};return J(q,()=>{q.value&&h({message:e("copySuccess"),type:"success"})}),(a,t)=>{const f=j,I=A,x=G,V=H,L=K;return w(),S("div",ae,[o("div",te,[g(o("iframe",{class:"w-[375px]",src:p.value,frameborder:"0",id:"previewIframe"},null,8,oe),[[y,i.value]]),g(o("div",se,[o("div",le,c(s(e)("developTitle")),1),o("div",ne,[o("text",pe,c(s(e)("wapDomain")),1),l(f,{modelValue:d.value,"onUpdate:modelValue":t[0]||(t[0]=N=>d.value=N),placeholder:s(e)("wapDomainPlaceholder"),clearable:""},null,8,["modelValue","placeholder"])]),l(I,{type:"primary",onClick:O},{default:n(()=>[B(c(s(e)("confirm")),1)]),_:1})],512),[[y,_.value]]),i.value?(w(),S("div",re,[o("div",ce,[o("div",ie,c(s(e)("h5")),1),l(L,{"label-width":"40px",class:"px-[20px]"},{default:n(()=>[g(l(x,{label:s(e)("link")},{default:n(()=>[l(f,{readonly:"",value:p.value},{append:n(()=>[l(I,{onClick:t[1]||(t[1]=N=>$(p.value)),class:"bg-primary copy"},{default:n(()=>[B(c(s(e)("copy")),1)]),_:1})]),_:1},8,["value"])]),_:1},8,["label"]),[[y,p.value]]),g(l(x,{label:" "},{default:n(()=>[l(V,{src:m.value},null,8,["src"])]),_:1},512),[[y,m.value]])]),_:1}),o("div",ue,c(s(e)("weapp")),1),l(L,{"label-width":"40px",class:"px-[20px]"},{default:n(()=>[b.qr_code?(w(),T(x,{key:0,label:" "},{default:n(()=>[l(V,{class:"w-[100px] h-[100px]",src:s(M)(b.qr_code)},null,8,["src"])]),_:1})):(w(),T(x,{key:1,label:" "},{default:n(()=>[o("span",de,c(s(e)("weappNotSet")),1)]),_:1}))]),_:1})])])):X("",!0)])])}}});export{ke as default};