| 1 |
- import"./index-c1f44820.js";import{B as $}from"./index-8c362873.js";import{a as j,u as B,C as q}from"./index-9c8f373e.js";import{F as z,C as F}from"./index-6474ea80.js";import{I as L}from"./index-12acba36.js";import"./index-b8adef18.js";import{F as M}from"./index-edccefc2.js";import{T as K}from"./index-1410084d.js";import{M as N,d as T,r as m,o as E,b as G,e as O,f as t,c as l,h as _,u as A,l as v,p as D,j as H,_ as J}from"./index-ebd06049.js";import"./use-expose-cd5a8a20.js";const Q=N("userInfo",{state:()=>({mobile:"",username:"",password:"",token:"",roles:[],isLogin:!1,isRememberMe:!1}),persist:{enabled:!0,encryptionKey:"userInfo",storage:localStorage}}),h=Q(),x=j.create({baseURL:"/forward-service",timeout:1e4}),W=function(r,i,s){const{url:c,data:e}=r;x.post(c,e,{headers:{token:h.token}}).then(a=>{const u=a.data;u.code==0?i&&i(u):u.code==3?h.isLogin=!1:s&&s(u.msg)},a=>{s&&s(a.message)}).catch(a=>{console.log(a)})},X=function(r){const{url:i,data:s}=r;return x.post(i,s,{headers:{token:h.token}}).then(c=>{const e=c.data;if(e.code==0)return Promise.resolve(e);if(e.code!=3)return Promise.reject(e.msg)},c=>Promise.reject(c.message))},k=r=>(D("data-v-e047f600"),r=r(),H(),r),Y={style:{height:"100vh",overflow:"hidden",display:"flex","flex-direction":"column"}},Z={style:{"background-image":"url('static/images/bg-login.png')","background-repeat":"no-repeat","background-position-y":"0px","background-size":"100%"}},ee={style:{padding:"100px 16px 30px 16px",display:"flex","justify-content":"space-between","align-items":"center"}},oe={style:{color:"#5C677C","margin-top":"4px"}},te=k(()=>t("div",{style:{"font-size":"1.1rem","font-weight":"bold"}},[t("span",null,"驼人物联网平台")],-1)),se={style:{"margin-top":"60px"}},ae={style:{padding:"16px"}},ne={style:{margin:"16px"}},le=k(()=>t("div",null,[t("a",null,"忘记密码?")],-1)),re=T({__name:"Index",setup(r){const i=A(),s=B(),c=m(),e=m(""),a=m(""),u=m(""),p=m(!0),y=m(""),b=()=>{W({url:"/open/getCaptcha"},n=>{console.log(n.data.captchaImg),y.value=n.data.captchaImg,u.value=n.data.captchaKey})},w=n=>{console.log(n),b()},V=()=>{i.replace("/register")};E(()=>{console.log("onMounted"),b(),p.value=s.$state.rememberPassword,p.value&&(e.value=s.$state.username,a.value=s.$state.password)});const I=()=>{var n;(n=c.value)==null||n.validate().then(()=>{s.$patch({rememberPassword:p.value}),p.value&&s.$patch({username:e.value,password:a.value}),X({url:"/user/login",data:{username:e.value,password:a.value}}).then(({data:o})=>{console.log(o),o.code==0&&(s.$patch(f=>{f.token=o.data.token}),i.push("/"))})}).catch(o=>{console.log(o)})};return(n,o)=>{const f=K,g=M,C=L,S=F,P=q,R=$,U=z;return G(),O("div",Y,[t("div",Z,[t("div",ee,[t("div",null,[t("div",oe,[l(f,{type:"primary",size:"large"},{default:_(()=>[v("欢迎登录")]),_:1})]),te])]),t("div",se,[l(U,{ref_key:"formRef",ref:c,onSubmit:I},{default:_(()=>[l(P,{inset:""},{default:_(()=>[l(g,{modelValue:e.value,"onUpdate:modelValue":o[0]||(o[0]=d=>e.value=d),name:"username",label:"账号","label-width":"70",placeholder:"请输入账号",rules:[{required:!0,message:"请填写账号"}]},null,8,["modelValue"]),l(g,{modelValue:a.value,"onUpdate:modelValue":o[1]||(o[1]=d=>a.value=d),name:"password",center:"",clearable:"",label:"密码","label-width":"70",type:"password",placeholder:"请输入密码",rules:[{required:!0,message:"请输入密码"}]},null,8,["modelValue"]),l(g,{style:{"align-items":"center"},modelValue:e.value,"onUpdate:modelValue":o[2]||(o[2]=d=>e.value=d),name:"username",label:"验证码","label-width":"70",placeholder:"请输入账号",rules:[{required:!0,message:"请填写账号"}]},{button:_(()=>[l(C,{width:"100",height:"30",fit:"contain",src:y.value,onClick:w},null,8,["src"])]),_:1},8,["modelValue"]),t("div",ae,[l(S,{modelValue:p.value,"onUpdate:modelValue":o[3]||(o[3]=d=>p.value=d),shape:"square"},{default:_(()=>[v("记住密码")]),_:1},8,["modelValue"])])]),_:1}),t("div",ne,[l(R,{round:"",block:"",type:"primary",size:"large","native-type":"submit"},{default:_(()=>[v("登录")]),_:1})]),t("div",{style:{padding:"0px 16px",display:"flex","justify-content":"space-between"}},[le,t("div",null,[t("a",{onClick:V},"注册账号")])])]),_:1},512)])])])}}});const he=J(re,[["__scopeId","data-v-e047f600"]]);export{he as default};
|