mirror of
https://gitee.com/niucloud-team/niucloud-admin.git
synced 2026-02-23 16:50:26 +00:00
2 lines
5.5 KiB
JavaScript
2 lines
5.5 KiB
JavaScript
import{d as e,a as l,Y as a,a1 as r,r as o,c as s,i as t,j as u,w as n,k as d,K as i,L as p,n as m,F as c,H as b,G as g,m as _,l as f,v as x,a2 as y,a3 as h,a0 as v,x as j,q as k,t as w,N as V,Z as P,I as U}from"./index-35472543.js";import{_ as q,a as S,b as T}from"./u-form.18ce977f.js";import{_ as L}from"./sms-code.vue_vue_type_script_setup_true_lang.c50383e0.js";import{_ as A}from"./app-link.vue_vue_type_script_setup_true_lang.0d2463e2.js";import{_ as C}from"./u-button.88f4eaa2.js";import"./u-icon.19e9e781.js";import"./_plugin-vue_export-helper.1b428a4d.js";import"./u-line.0a0acc57.js";import"./u-modal.c14cb23b.js";import"./u-loading-icon.8685138b.js";import"./u-popup.42937664.js";import"./u-transition.d55ca602.js";import"./u-safe-bottom.9de05a20.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 Y=a(),Z=r(),$=o(!1),B=o(""),E=s((()=>{const e=[];return Z.login.is_username&&e.push({type:"username",title:P("usernameLogin")}),Z.login.is_mobile&&e.push({type:"mobile",title:P("mobileLogin")}),B.value=e[0]?e[0].type:"",e})),F=s((()=>({username:{type:"string",required:"username"==B.value,message:P("usernamePlaceholder"),trigger:["blur","change"]},password:{type:"string",required:"username"==B.value,message:P("passwordPlaceholder"),trigger:["blur","change"]},mobile:[{type:"string",required:"mobile"==B.value,message:P("mobilePlaceholder"),trigger:["blur","change"]},{validator:(e,l)=>"mobile"!=B.value||uni.$u.test.mobile(l),message:P("mobileError"),trigger:["change","blur"]}],mobile_code:{type:"string",required:"mobile"==B.value,message:P("codePlaceholder"),trigger:["blur","change"]}}))),G=o(null),H=()=>{G.value.validate().then((()=>{if($.value)return;$.value=!0;("username"==B.value?y:h)(R).then((e=>{Y.setToken(e.data.token),v().handleLoginBack()})).catch((()=>{$.value=!1}))}))};return(e,l)=>{const a=j,r=k(w("u-input"),q),o=k(w("u-form-item"),S),s=k(w("sms-code"),L),y=V,h=k(w("app-link"),A),v=k(w("u-button"),C),Y=k(w("u-form"),T);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(p(m(P)("login")),1)])),_:1})])),_:1}),m(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(m(E),((e,l)=>(t(),c(g,null,[d(a,{class:U({"text-gray-300":e.type!=B.value}),onClick:l=>B.value=e.type},{default:n((()=>[i(p(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})):_("v-if",!0),d(a,{class:"px-[60rpx]"},{default:n((()=>[d(Y,{labelPosition:"left",model:R,errorType:"toast",rules:m(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:m(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:m(P)("passwordPlaceholder")},null,8,["modelValue","placeholder"])])),_:1})])),_:1})])),_:1},512),[[x,"username"==B.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:m(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:m(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"==B.value]]),d(a,{class:"flex text-xs justify-between mt-[20rpx] text-gray-400"},{default:n((()=>[d(h,{url:"/app/pages/auth/register"},{default:n((()=>[i(p(m(P)("noAccount"))+" ",1),d(y,{class:"text-primary"},{default:n((()=>[i(p(m(P)("toRegister")),1)])),_:1})])),_:1}),d(h,{url:"/app/pages/auth/resetpwd"},{default:n((()=>[i(p(m(P)("resetpwd")),1)])),_:1})])),_:1}),d(a,{class:"mt-[80rpx]"},{default:n((()=>[d(v,{type:"primary",loading:$.value,loadingText:m(P)("logining"),onClick:H},{default:n((()=>[i(p(m(P)("login")),1)])),_:1},8,["loading","loadingText"])])),_:1})])),_:1},8,["model","rules"])])),_:1})])),_:1}),m(Z).login.agreement_show?(t(),u(a,{key:0,class:"text-xs py-[50rpx] flex justify-center w-full"},{default:n((()=>[i(p(m(P)("agreeTips"))+" ",1),d(h,{url:"/app/pages/auth/agreement?key=service"},{default:n((()=>[d(y,{class:"text-primary"},{default:n((()=>[i(p(m(P)("userAgreement")),1)])),_:1})])),_:1}),i(" "+p(m(P)("and"))+" ",1),d(h,{url:"/app/pages/auth/agreement?key=privacy"},{default:n((()=>[d(y,{class:"text-primary"},{default:n((()=>[i(p(m(P)("privacyAgreement")),1)])),_:1})])),_:1})])),_:1})):_("v-if",!0)])),_:1})}}});export{R as default};
|