mirror of
https://gitee.com/niucloud-team/niucloud-admin.git
synced 2026-01-25 12:38:10 +00:00
2 lines
5.5 KiB
JavaScript
2 lines
5.5 KiB
JavaScript
import{d as e,a as l,R as a,W as r,r as o,c as s,e as t,f as u,w as n,h as d,A as i,B as m,j as p,K as c,L as b,M as g,C as _,i as f,v as x,X as y,Y as h,V as v,m as j,k,l as V,F as w,G as P,D as T}from"./index-6ae98f60.js";import{_ as U}from"./u-input.69643db3.js";import{_ as q,a as A}from"./u-form.49a2088a.js";import{_ as C}from"./sms-code.vue_vue_type_script_setup_true_lang.9b8b5b3d.js";import{_ as L}from"./app-link.vue_vue_type_script_setup_true_lang.2459127b.js";import{_ as S}from"./u-button.2696b0f8.js";import"./u-icon.b8554ea8.js";import"./_plugin-vue_export-helper.1b428a4d.js";import"./u-line.4b08f62d.js";import"./u-modal.3c7ec96d.js";import"./u-loading-icon.04545e1a.js";import"./u-popup.461051d8.js";import"./u-transition.092585d8.js";import"./u-safe-bottom.7a092736.js";const R=e({__name:"login",setup(e){const R=l({username:"",password:"",mobile:"",mobile_code:"",mobile_key:""});uni.getStorageSync("openid")&&Object.assign(R,{openid:uni.getStorageSync("openid")});const B=a(),W=r(),$=o(!1),D=o(""),E=s((()=>{const e=[];return W.login.is_username&&e.push({type:"username",title:P("usernameLogin")}),W.login.is_mobile&&e.push({type:"mobile",title:P("mobileLogin")}),D.value=e[0]?e[0].type:"",e})),F=s((()=>({username:{type:"string",required:"username"==D.value,message:P("usernamePlaceholder"),trigger:["blur","change"]},password:{type:"string",required:"username"==D.value,message:P("passwordPlaceholder"),trigger:["blur","change"]},mobile:[{type:"string",required:"mobile"==D.value,message:P("mobilePlaceholder"),trigger:["blur","change"]},{validator:(e,l)=>"mobile"!=D.value||uni.$u.test.mobile(l),message:P("mobileError"),trigger:["change","blur"]}],mobile_code:{type:"string",required:"mobile"==D.value,message:P("codePlaceholder"),trigger:["blur","change"]}}))),G=o(null),K=()=>{G.value.validate().then((()=>{if($.value)return;$.value=!0;("username"==D.value?y:h)(R).then((e=>{B.setToken(e.data.token),v().handleLoginBack()})).catch((()=>{$.value=!1}))}))};return(e,l)=>{const a=j,r=k(V("u-input"),U),o=k(V("u-form-item"),q),s=k(V("sms-code"),C),y=w,h=k(V("app-link"),L),v=k(V("u-button"),S),B=k(V("u-form"),A);return t(),u(a,{class:"w-screen h-screen flex flex-col"},{default:n((()=>[d(a,{class:"flex-1"},{default:n((()=>[d(a,{class:"h-[100rpx]"}),d(a,{class:"px-[60rpx] pt-[100rpx] mb-[100rpx]"},{default:n((()=>[d(a,{class:"font-bold text-xl"},{default:n((()=>[i(m(p(P)("login")),1)])),_:1})])),_:1}),p(E).length>1?(t(),u(a,{key:0,class:"px-[60rpx] text-sm flex mb-[50rpx] font-bold leading-none"},{default:n((()=>[(t(!0),c(g,null,b(p(E),((e,l)=>(t(),c(g,null,[d(a,{class:T({"text-gray-300":e.type!=D.value}),onClick:l=>D.value=e.type},{default:n((()=>[i(m(e.title),1)])),_:2},1032,["class","onClick"]),f(d(a,{class:"mx-[30rpx] border-solid border-0 border-r-[2px] border-gray-300"},null,512),[[x,0==l]])],64)))),256))])),_:1})):_("",!0),d(a,{class:"px-[60rpx]"},{default:n((()=>[d(B,{labelPosition:"left",model:R,errorType:"toast",rules:p(F),ref_key:"formRef",ref:G},{default:n((()=>[f(d(a,null,{default:n((()=>[d(o,{label:"",prop:"username","border-bottom":!0},{default:n((()=>[d(r,{modelValue:R.username,"onUpdate:modelValue":l[0]||(l[0]=e=>R.username=e),border:"none",clearable:"",placeholder:p(P)("usernamePlaceholder")},null,8,["modelValue","placeholder"])])),_:1}),d(a,{class:"mt-[40rpx]"},{default:n((()=>[d(o,{label:"",prop:"password","border-bottom":!0},{default:n((()=>[d(r,{modelValue:R.password,"onUpdate:modelValue":l[1]||(l[1]=e=>R.password=e),border:"none",type:"password",clearable:"",placeholder:p(P)("passwordPlaceholder")},null,8,["modelValue","placeholder"])])),_:1})])),_:1})])),_:1},512),[[x,"username"==D.value]]),f(d(a,null,{default:n((()=>[d(o,{label:"",prop:"mobile","border-bottom":!0},{default:n((()=>[d(r,{modelValue:R.mobile,"onUpdate:modelValue":l[2]||(l[2]=e=>R.mobile=e),border:"none",clearable:"",placeholder:p(P)("mobilePlaceholder")},null,8,["modelValue","placeholder"])])),_:1}),d(a,{class:"mt-[40rpx]"},{default:n((()=>[d(o,{label:"",prop:"mobile_code","border-bottom":!0},{default:n((()=>[d(r,{modelValue:R.mobile_code,"onUpdate:modelValue":l[4]||(l[4]=e=>R.mobile_code=e),border:"none",type:"password",clearable:"",placeholder:p(P)("codePlaceholder")},{suffix:n((()=>[d(s,{mobile:R.mobile,type:"login",modelValue:R.mobile_key,"onUpdate:modelValue":l[3]||(l[3]=e=>R.mobile_key=e)},null,8,["mobile","modelValue"])])),_:1},8,["modelValue","placeholder"])])),_:1})])),_:1})])),_:1},512),[[x,"mobile"==D.value]]),d(a,{class:"flex text-xs justify-between mt-[20rpx] text-gray-400"},{default:n((()=>[d(h,{url:"/pages/auth/register"},{default:n((()=>[i(m(p(P)("noAccount"))+" ",1),d(y,{class:"text-primary"},{default:n((()=>[i(m(p(P)("toRegister")),1)])),_:1})])),_:1}),d(h,{url:"/pages/auth/resetpwd"},{default:n((()=>[i(m(p(P)("resetpwd")),1)])),_:1})])),_:1}),d(a,{class:"mt-[80rpx]"},{default:n((()=>[d(v,{type:"primary",loading:$.value,loadingText:p(P)("logining"),onClick:K},{default:n((()=>[i(m(p(P)("login")),1)])),_:1},8,["loading","loadingText"])])),_:1})])),_:1},8,["model","rules"])])),_:1})])),_:1}),p(W).login.agreement_show?(t(),u(a,{key:0,class:"text-xs py-[50rpx] flex justify-center w-full"},{default:n((()=>[i(m(p(P)("agreeTips"))+" ",1),d(h,{url:"/pages/auth/agreement?key=service"},{default:n((()=>[d(y,{class:"text-primary"},{default:n((()=>[i(m(p(P)("userAgreement")),1)])),_:1})])),_:1}),i(" "+m(p(P)("and"))+" ",1),d(h,{url:"/pages/auth/agreement?key=privacy"},{default:n((()=>[d(y,{class:"text-primary"},{default:n((()=>[i(m(p(P)("privacyAgreement")),1)])),_:1})])),_:1})])),_:1})):_("",!0)])),_:1})}}});export{R as default};
|