niucloud-admin/niucloud/public/wap/assets/pages-auth-login.fbbe2e36.js
全栈小学生 ce1e7ad77a 1
2023-06-01 19:38:09 +08:00

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-854481f8.js";import{_ as U}from"./u-input.2687cb8f.js";import{_ as q,a as A}from"./u-form.47bf330a.js";import{_ as C}from"./sms-code.vue_vue_type_script_setup_true_lang.7333f692.js";import{_ as L}from"./app-link.vue_vue_type_script_setup_true_lang.b7a1fad9.js";import{_ as S}from"./u-button.7ae2995f.js";import"./u-icon.cd6e256c.js";import"./_plugin-vue_export-helper.1b428a4d.js";import"./u-line.e47e8cd8.js";import"./u-modal.d4001524.js";import"./u-loading-icon.45575251.js";import"./u-popup.4d9841e3.js";import"./u-transition.6dcd1331.js";import"./u-safe-bottom.a8c13903.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(),D=o(!1),E=o(""),F=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")}),E.value=e[0]?e[0].type:"",e})),G=s((()=>({username:{type:"string",required:"username"==E.value,message:P("usernamePlaceholder"),trigger:["blur","change"]},password:{type:"string",required:"username"==E.value,message:P("passwordPlaceholder"),trigger:["blur","change"]},mobile:[{type:"string",required:"mobile"==E.value,message:P("mobilePlaceholder"),trigger:["blur","change"]},{validator:(e,l)=>"mobile"!=E.value||uni.$u.test.mobile(l),message:P("mobileError"),trigger:["change","blur"]}],mobile_code:{type:"string",required:"mobile"==E.value,message:P("codePlaceholder"),trigger:["blur","change"]}}))),K=o(null),M=()=>{K.value.validate().then((()=>{if(D.value)return;D.value=!0;("username"==E.value?y:h)(R).then((e=>{B.setToken(e.data.token),v().handleLoginBack()})).catch((()=>{D.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(F).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(F),((e,l)=>(t(),c(g,null,[d(a,{class:T({"text-gray-300":e.type!=E.value}),onClick:l=>E.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(G),ref_key:"formRef",ref:K},{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"==E.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"==E.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:D.value,loadingText:p(P)("logining"),onClick:M},{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};