import{_ as e,u as a,s as o,g as l,a as s,b as r,r as t,U as n,c as i,d as u,e as d,f as m,w as c,i as f,o as g,h as p,j as y,k as N,n as _,t as b,l as h,m as v,p as V}from"./index-DHnrKYrL.js";import{_ as x,a as k,b as D}from"./uni-forms.BIj7AkU3.js";import"./uni-icons.DhPZCKE1.js";const F=e({data:()=>({loginForm:{terminal:1,userName:"",password:"",uuid:a().deviceUuid},rules:{userName:{rules:[{required:!0,errorMessage:"请输入用户名"}]},password:{rules:[{required:!0,errorMessage:"请输入密码"}]}},key:"636778cc92cd1d2a948e69b03c5f0d78",loginWay:2,codeNum:60,formData:{userName:"",code:"",terminal:"0"},btnText:"获取验证码",rules1:{userName:{rules:[{required:!0,errorMessage:"请输入手机号"}]},code:{rules:[{required:!0,errorMessage:"请输入验证码"}]}}}),methods:{submit(){let e=this;e.$http({url:1==e.loginWay?"/login":"/loginBySMS",data:1==e.loginWay?e.loginForm:e.formData,method:"POST"}).then((a=>{console.log("登录成功,自动跳转到聊天页面...",e.loginForm),1==e.loginWay?(o("userName",e.loginForm.userName),o("password",e.loginForm.password)):o("phone",e.formData.userName),o("loginInfo",a),l().$vm.init(),s({url:"/pages/chat/chat"})}))},async getCode(){let e=this;if(""===e.formData.userName)return void r({title:"请输入手机号",icon:"none"});if(!uni.$u.test.mobile(e.formData.userName))return void r({icon:"none",title:"请输入正确的手机号"});if(e.codeNum<60&&0!==e.codeNum)return void r({icon:"none",title:"请稍后点击"});let a=60;t({url:n.BASE_URL+"/base/SySMSLoginMsg?mobiles="+e.formData.userName,method:"GET",success(o){var l,s,t;if(200!==(null==(l=null==o?void 0:o.data)?void 0:l.code))return void r({icon:"none",title:(null==(s=null==o?void 0:o.data)?void 0:s.message)||"短信发送失败！"});let n=setInterval((function(){e.codeNum=a,e.codeNum--,e.btnText=--a+"s",e.is_none="none",0===a&&(e.btnText="获取验证码",e.is_none="",e.codeNum=60,clearInterval(n))}),1e3);r({icon:"none",title:null==(t=null==o?void 0:o.data)?void 0:t.message})}})}},onLoad(){this.loginForm.userName=i("userName"),this.loginForm.password=i("password"),this.formData.userName=i("phone")},onReady(){}},[["render",function(e,a,o,l,s,r){const t=f,n=u(d("uni-easyinput"),x),i=u(d("uni-forms-item"),k),F=h,w=v,C=u(d("uni-forms"),D),W=V;return g(),m(t,{class:"page login"},{default:c((()=>[p(t,{class:"title"},{default:c((()=>[y("通讯助手")])),_:1}),1===s.loginWay?(g(),m(C,{key:0,class:"form",modelValue:s.loginForm,rules:s.rules,"validate-trigger":"bind"},{default:c((()=>[p(i,{name:"userName"},{default:c((()=>[p(n,{type:"text",modelValue:s.loginForm.userName,"onUpdate:modelValue":a[0]||(a[0]=e=>s.loginForm.userName=e),"prefix-icon":"person",placeholder:"请输入用户名"},null,8,["modelValue"])])),_:1}),p(i,{name:"password"},{default:c((()=>[p(n,{type:"password",modelValue:s.loginForm.password,"onUpdate:modelValue":a[1]||(a[1]=e=>s.loginForm.password=e),"prefix-icon":"locked",placeholder:"请输入密码"},null,8,["modelValue"])])),_:1}),p(t,{class:"login_code"},{default:c((()=>[p(F,{onClick:a[2]||(a[2]=e=>s.loginWay=2)},{default:c((()=>[y("短信验证码登录")])),_:1})])),_:1}),p(w,{class:"btn-submit",onClick:r.submit,type:"primary"},{default:c((()=>[y("登录")])),_:1},8,["onClick"])])),_:1},8,["modelValue","rules"])):N("",!0),2===s.loginWay?(g(),m(C,{key:1,class:"form",modelValue:s.formData,rules:s.rules1,"validate-trigger":"bind"},{default:c((()=>[p(i,{name:"userName"},{default:c((()=>[p(n,{type:"text",modelValue:s.formData.userName,"onUpdate:modelValue":a[3]||(a[3]=e=>s.formData.userName=e),"prefix-icon":"person",placeholder:"请输入手机号"},null,8,["modelValue"])])),_:1}),p(i,{name:"code"},{default:c((()=>[p(t,{class:"code-box"},{default:c((()=>[p(n,{type:"text",modelValue:s.formData.code,"onUpdate:modelValue":a[4]||(a[4]=e=>s.formData.code=e),"prefix-icon":"locked",placeholder:"请输入验证码",clearable:!1},null,8,["modelValue"]),p(W,{onClick:a[5]||(a[5]=e=>r.getCode()),class:"btnText",style:_({color:60===s.codeNum?"#999":"#496bc3"})},{default:c((()=>[y(b(s.btnText),1)])),_:1},8,["style"])])),_:1})])),_:1}),p(t,{class:"login_code"},{default:c((()=>[p(F,{onClick:a[6]||(a[6]=e=>s.loginWay=1)},{default:c((()=>[y("用户名/密码登录")])),_:1})])),_:1}),p(w,{class:"btn-submit",onClick:r.submit,type:"primary"},{default:c((()=>[y("登录")])),_:1},8,["onClick"])])),_:1},8,["modelValue","rules"])):N("",!0)])),_:1})}],["__scopeId","data-v-3477b41a"]]);export{F as default};
