tg_web_dist/js/index.BOyDfYkr.js
2025-07-08 17:28:05 +08:00

2 lines
5.5 KiB
JavaScript

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