2 lines
5.9 KiB
JavaScript
2 lines
5.9 KiB
JavaScript
import{d as e,bw as a,b4 as l,a$ as s,b5 as t,b6 as o,r as n,bk as c,bx as r,bt as i,F as u,a8 as d,ae as g,b2 as m,o as p,by as v,D as f,aB as _,c as y,l as h,m as w,ah as x,g as b,w as k,al as I,P as T,t as V,O as z,ak as $,bz as D,Q as S,an as j,bA as C,R as E,E as B,bB as F,e as K,bf as R}from"./index.pkwn57tR.js";import{E as G}from"./el-card.D7fC5_K-.js";import{E as U}from"./el-text.CI4Bws16.js";import{_ as q}from"./index.BKSTWofQ.js";import{a as A,c as L}from"./custom.BbAngxCA.js";const O={class:"login-container"},J={class:"absolute-lt flex-x-end p-3 w-full"},M={class:"text-center relative"},N={class:"flex-y-center w-full"},P={class:"flex-y-center w-full"},Q={class:"flex-y-center w-full"},W={key:1,class:"google-code-image-box"},H={style:{"text-align":"center","margin-bottom":"4px"}},X=R(e({__name:"index",setup(e){const{copy:R}=a({legacy:!0});l();const X=s(),Y=t(),Z=o();n(Y.theme===c.DARK);const ee=n(!0),ae=n(!1),le=n(!1),se=n(r),{height:te}=i(),oe=n(""),ne=n({user_name:"",password:"",google_code:""}),ce=n("");const re=u((()=>({})));function ie(){const e="/"+ge.value.active;m.push({path:e})}function ue(){se.value.validate((async e=>{if(e){ae.value=!0;const e=function(){let e=ne.value;return"customer"===ge.value.active&&(e={...ne.value,ms_name:ne.value.user_name}),e}(),a={username:e.user_name,password:e.password,google_code:e.google_code};ce.value="",await X.login(a).then((e=>{(null==e?void 0:e.qr_code_url)?ce.value=null==e?void 0:e.qr_code_url:(ce.value="",ie())})).catch((()=>{})).finally((()=>{ae.value=!1}))}}))}function de(e){e instanceof KeyboardEvent&&(le.value=e.getModifierState("CapsLock"))}n(""),d((()=>{te.value<600?ee.value=!1:ee.value=!0}));const ge=n({active:"",list:[{identity:"admin",name:"管理员平台"},{identity:"customer",name:"客户管理平台"}]});g({visible:!1,type:"user-form",width:400,title:"",leftBtnText:"确 定",rightBtnText:""});let me=JSON.parse(sessionStorage.getItem("loginInfo")||"{}");ge.value.active=me.loginType,oe.value&&oe.value!==ge.value.active&&!["admin","customer"].includes(ge.value.active)&&(localStorage.clear(),m.push({path:"/login",replace:!0})),oe.value=ge.value.active;localStorage.getItem(oe.value+"accessToken")&&ie();const pe=n("account_login"),ve=e=>{"account_login"===pe.value?(pe.value="tg_login",we()):(pe.value="account_login",clearInterval(xe))};p((()=>{"customer"==me.loginType&&(pe.value="tg_login",we())}));const fe=F((e=>{R(e).then((()=>{v.success("复制成功")}))}),300),_e=()=>{window.open("https://t.me/bfbf")},ye=n(""),he=n(""),we=()=>{A({}).then((e=>{ye.value=e.token,he.value=e.expires_at,be()})).catch((e=>{}))};let xe=null;const be=()=>{new Date(he.value).getTime()-Date.now()<=0?clearInterval(xe):(clearInterval(xe),xe=setInterval((()=>{L({token:ye.value}).then((e=>{e.logged_in?(localStorage.setItem("customeraccessToken",e.loginToken),ie(),clearInterval(xe)):e.valid||(v.warning("授权认证过期,请刷新界面重新获取认证"),clearInterval(xe))})).catch((e=>{clearInterval(xe)}))}),3e3))};return p((()=>{ge.value.active})),f((()=>Z.path),(e=>{e.startsWith("/login/")&&ge.value.active})),(e,a)=>{const l=I,s=q,t=$,o=D,n=j,c=C,i=r,u=U,d=_("Document"),g=B,m=G;return K(),y("div",O,[h("div",J,["customer"==b(ge).active?(K(),w(l,{key:0,size:"small",type:"primary",style:{"margin-right":"20px",width:"100px"},plain:"",round:"",onClick:ve},{default:k((()=>[T(V("tg_login"===b(pe)?"账号密码登录":"TG注册/登录"),1)])),_:1})):x("",!0)]),b(ge).active?(K(),w(m,{key:0,class:"login-input-container !border-none !bg-transparent !rounded-[4%] w-100 <sm:w-85"},{default:k((()=>{var r;return[h("div",M,[h("h2",null,V(null==(r=b(ge).list.find((e=>e.identity===b(ge).active)))?void 0:r.name),1)]),"account_login"===b(pe)?(K(),w(i,{key:0,ref_key:"loginFormRef",ref:se,model:b(ne),rules:b(re),class:"login-form"},{default:k((()=>[z(o,{prop:"user_name"},{default:k((()=>[h("div",N,[z(s,{"icon-class":"user",class:"mx-2"}),z(t,{ref:"user_name",modelValue:b(ne).user_name,"onUpdate:modelValue":a[0]||(a[0]=e=>b(ne).user_name=e),placeholder:e.$t("login.username"),name:"user_name",size:"large",class:"h-[48px]"},null,8,["modelValue","placeholder"])])])),_:1}),z(n,{visible:b(le),content:e.$t("login.capsLock"),placement:"right"},{default:k((()=>[z(o,{prop:"password"},{default:k((()=>[h("div",P,[z(s,{"icon-class":"lock",class:"mx-2"}),z(t,{modelValue:b(ne).password,"onUpdate:modelValue":a[1]||(a[1]=e=>b(ne).password=e),placeholder:e.$t("login.password"),type:"password",name:"password",onKeyup:[de,S(ue,["enter"])],size:"large",class:"h-[48px] pr-2","show-password":""},null,8,["modelValue","placeholder"])])])),_:1})])),_:1},8,["visible","content"]),"customer"!=b(ge).active?(K(),w(o,{key:0,prop:"google_code"},{default:k((()=>[h("div",Q,[z(s,{"icon-class":"captcha",class:"mx-2"}),z(t,{modelValue:b(ne).google_code,"onUpdate:modelValue":a[2]||(a[2]=e=>b(ne).google_code=e),"auto-complete":"off",size:"large",class:"flex-1",placeholder:"Google验证码,登录和重置密码首次请勿填写",onKeyup:S(ue,["enter"])},null,8,["modelValue"])])])),_:1})):x("",!0),b(ce)?(K(),y("div",W,[z(c,{class:"google-code-image",src:b(ce)},null,8,["src"])])):x("",!0),z(l,{loading:b(ae),type:"primary",size:"large",class:"w-full",onClick:E(ue,["prevent"])},{default:k((()=>[T(V(e.$t("login.login")),1)])),_:1},8,["loading"])])),_:1},8,["model","rules"])):(K(),w(i,{key:1,ref_key:"loginFormRef",ref:se,class:"login-form"},{default:k((()=>[h("div",H,[z(u,{type:"warning"},{default:k((()=>a[4]||(a[4]=[T("复制信息跳转八方官方机器人粘贴完成登录")]))),_:1,__:[4]})]),z(l,{type:"primary",plain:"",round:"",size:"large",class:"w-full tg_code",onClick:a[3]||(a[3]=e=>b(fe)(`/login ${b(ye)}`))},{default:k((()=>[h("span",null,V(`/login ${b(ye)}`),1),z(g,{style:{"margin-left":"10px"}},{default:k((()=>[z(d)])),_:1})])),_:1}),z(l,{type:"primary",class:"w-full",style:{"margin-top":"10px","margin-left":"0"},onClick:_e},{default:k((()=>a[5]||(a[5]=[T("跳转TG机器人")]))),_:1,__:[5]})])),_:1},512))]})),_:1})):x("",!0)])}}}),[["__scopeId","data-v-f20bbcfa"]]);export{X as default};
|