var b=(O,d,i)=>new Promise((I,n)=>{var h=l=>{try{r(i.next(l))}catch(_){n(_)}},s=l=>{try{r(i.throw(l))}catch(_){n(_)}},r=l=>l.done?I(l.value):Promise.resolve(l.value).then(h,s);r((i=i.apply(O,d)).next())});import{d as w,l as x,g as j}from"./index-3caa89ed.js";import{d as M,r as a,a as S,c as v,b as t,e as c,n as E,f as L,t as T,w as f,g as U,h as $,i as H,j as g,u as P,o as u,k as z,E as K,l as J}from"./index-90c78f99.js";const W={key:0,class:"login h-screen"},X={class:"flex flex-col justify-center items-center"},Y={class:"login-box"},Z={class:"flex justify-between"},ee={key:0,class:"qrcodeBox"},oe={class:"qrcode"},te=["src"],se={class:"mt-40 text-info"},le={key:1,class:"mt-50"},ae={key:1,class:"itemBlue"},ne=t("div",{class:"text-center"},[t("p",{class:"text-12 text-white opacity-80"}," 主办单位：柯桥区大数据发展管理中心 "),t("p",{class:"text-12 text-white opacity-80"}," 建议使用1366*768分辨率/Chrome浏览器访问达到最佳效果 ")],-1),ue=M({__name:"index",setup(O){const d=P(),i="浙政钉",I="https://login-pro.ding.zj.gov.cn/oauth2/auth.htm?response_type=code&client_id=KBSD_dingoa&redirect_uri=https://kbsd.kq.gov.cn/&scope=get_user_info&authType=QRCODE&embedMode=true",n=a("DING_QR_LOGIN"),h=o=>{n.value=o},s=a({phoneNum:"",verifyCode:""}),r=a(),l={phoneNum:[{required:!0,message:"请输入手机号",trigger:"blur"}],verifyCode:[{required:!0,message:"请输入验证码",trigger:"blur"}]},_=o=>b(this,null,function*(){o&&(yield o.validate(e=>{e?x({credential:s.value.verifyCode,identifier:s.value.phoneNum,loginType:"PHONE_VERIFICATION_CODE_LOGIN"}).then(()=>{y.value=!0,d.replace("/")}):console.log("error submit!")}))}),k=60,m=a(),N=a(),C=a(!0),R=()=>b(this,null,function*(){yield j({mobile:s.value.phoneNum,verificationType:"LOGIN"}),K.success("验证码已发送"),N.value||(m.value=k,C.value=!1,N.value=setInterval(()=>{m.value>0&&m.value<=k?m.value--:(C.value=!0,clearInterval(N.value),N.value=null)},1e3))}),y=a(!1),D=a(!0),B=()=>{w?w.getAuthCode({}).then(o=>{o&&(o.code||o.auth_code)&&x({credential:o.code||o.auth_code,loginType:"DING_AC_LOGIN"}).then(e=>{console.log(e,"res"),e.code===200&&(console.log(o,"result"),y.value=!0,d.push("/home"))})}).catch(()=>{D.value=!1,(()=>{window.addEventListener("message",function(e){!y.value&&e.data.code&&x({credential:e.data.code,identifier:"",loginType:"DING_QR_LOGIN"}).then(()=>{y.value=!0,d.replace("/")})})})()}):console.log("未找到ddApi")};return S(()=>{console.log("ceshi"),B()}),(o,e)=>{const Q=g("svg-icon"),G=g("el-input"),V=g("el-form-item"),q=g("el-form"),A=g("el-button"),F=J("debounce");return D.value?H("",!0):(u(),v("div",W,[t("div",X,[c(Q,{name:"logo",class:"logo"}),t("div",Y,[t("div",Z,[t("span",{class:E(`tabItem mr-32 ${n.value==="DING_QR_LOGIN"?"itemBlue":""}`),onClick:e[0]||(e[0]=p=>h("DING_QR_LOGIN"))}," 扫码登录 ",2),t("span",{class:E(["tabItem",`tabItem ${n.value==="PHONE_VERIFICATION_CODE_LOGIN"?"itemBlue":""}`]),onClick:e[1]||(e[1]=p=>h("PHONE_VERIFICATION_CODE_LOGIN"))}," 短信验证码登录 ",2)]),n.value==="DING_QR_LOGIN"?(u(),v("div",ee,[t("div",oe,[t("iframe",{width:"200",height:"430",src:L(I),frameborder:"0"},null,8,te)]),t("p",se,"请使用"+T(L(i))+"扫描二维码登陆",1)])):(u(),v("div",le,[c(q,{ref_key:"formRef",ref:r,model:s.value,rules:l,"label-width":"auto","status-icon":""},{default:f(()=>[c(V,{label:"",prop:"phoneNum"},{default:f(()=>[c(G,{modelValue:s.value.phoneNum,"onUpdate:modelValue":e[2]||(e[2]=p=>s.value.phoneNum=p),"prefix-icon":"UserFilled",placeholder:"请输入手机号"},null,8,["modelValue"])]),_:1}),c(V,{label:"",prop:"verifyCode"},{default:f(()=>[c(G,{modelValue:s.value.verifyCode,"onUpdate:modelValue":e[3]||(e[3]=p=>s.value.verifyCode=p),"prefix-icon":"Lock",placeholder:"请输入验证码"},{suffix:f(()=>[C.value?(u(),v("span",{key:0,class:"text-primary cursor-pointer",onClick:R}," 获取验证码 ")):(u(),v("span",ae,T(m.value)+"s",1))]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["model"]),U((u(),$(A,{class:"w-full mt-40",type:"primary"},{default:f(()=>[z(" 登录 ")]),_:1})),[[F,()=>_(r.value)]])]))])]),ne]))}}});export{ue as default};
