test_lgq/niucloud/public/wap/assets/app-pages-auth-login.b142d06b.js
2024-01-24 17:36:08 +08:00

2 lines
5.6 KiB
JavaScript

import{d as e,a as l,X as a,a1 as r,r as o,c as t,h as s,i as u,w as i,j as n,J as p,K as d,m,E as c,G as g,F as b,l as _,k as f,v as x,a2 as y,a3 as h,a0 as v,t as j,p as k,q as w,M as V,Y as P,H as S}from"./index-849cf30e.js";import{_ as q}from"./u-input.46b72faa.js";import{_ as T,a as U}from"./u-form.4f9a45b5.js";import{_ as A}from"./sms-code.vue_vue_type_script_setup_true_lang.55fd252c.js";import{_ as C}from"./app-link.vue_vue_type_script_setup_true_lang.d62f9cf3.js";import{_ as L}from"./u-button.9fa3f2a0.js";import"./u-icon.e3aa4770.js";import"./_plugin-vue_export-helper.1b428a4d.js";import"./u-line.19eb5c40.js";import"./u-modal.081e9589.js";import"./u-loading-icon.d012ecbf.js";import"./u-popup.e01742d2.js";import"./u-transition.75065529.js";import"./u-safe-bottom.2f6af56c.js";const E=e({__name:"login",setup(e){const E=l({username:"",password:"",mobile:"",mobile_code:"",mobile_key:""});uni.getStorageSync("openid")&&Object.assign(E,{openid:uni.getStorageSync("openid")}),uni.getStorageSync("pid")&&Object.assign(E,{pid:uni.getStorageSync("pid")});const O=a(),R=r(),X=o(!1),Y=o(""),B=t((()=>{const e=[];return R.login.is_username&&e.push({type:"username",title:P("usernameLogin")}),R.login.is_mobile&&e.push({type:"mobile",title:P("mobileLogin")}),Y.value=e[0]?e[0].type:"",e})),F=t((()=>({username:{type:"string",required:"username"==Y.value,message:P("usernamePlaceholder"),trigger:["blur","change"]},password:{type:"string",required:"username"==Y.value,message:P("passwordPlaceholder"),trigger:["blur","change"]},mobile:[{type:"string",required:"mobile"==Y.value,message:P("mobilePlaceholder"),trigger:["blur","change"]},{validator:(e,l)=>"mobile"!=Y.value||uni.$u.test.mobile(l),message:P("mobileError"),trigger:["change","blur"]}],mobile_code:{type:"string",required:"mobile"==Y.value,message:P("codePlaceholder"),trigger:["blur","change"]}}))),G=o(null),H=()=>{G.value.validate().then((()=>{if(X.value)return;X.value=!0;("username"==Y.value?y:h)(E).then((e=>{O.setToken(e.data.token),v().handleLoginBack()})).catch((()=>{X.value=!1}))}))};return(e,l)=>{const a=j,r=k(w("u-input"),q),o=k(w("u-form-item"),T),t=k(w("sms-code"),A),y=V,h=k(w("app-link"),C),v=k(w("u-button"),L),O=k(w("u-form"),U);return s(),u(a,{class:"w-screen h-screen flex flex-col"},{default:i((()=>[n(a,{class:"flex-1"},{default:i((()=>[n(a,{class:"h-[100rpx]"}),n(a,{class:"px-[60rpx] pt-[100rpx] mb-[100rpx]"},{default:i((()=>[n(a,{class:"font-bold text-xl"},{default:i((()=>[p(d(m(P)("login")),1)])),_:1})])),_:1}),m(B).length>1?(s(),u(a,{key:0,class:"px-[60rpx] text-sm flex mb-[50rpx] font-bold leading-none"},{default:i((()=>[(s(!0),c(b,null,g(m(B),((e,l)=>(s(),c(b,null,[n(a,{class:S({"text-gray-300":e.type!=Y.value}),onClick:l=>Y.value=e.type},{default:i((()=>[p(d(e.title),1)])),_:2},1032,["class","onClick"]),f(n(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),n(a,{class:"px-[60rpx]"},{default:i((()=>[n(O,{labelPosition:"left",model:E,errorType:"toast",rules:m(F),ref_key:"formRef",ref:G},{default:i((()=>[f(n(a,null,{default:i((()=>[n(o,{label:"",prop:"username","border-bottom":!0},{default:i((()=>[n(r,{modelValue:E.username,"onUpdate:modelValue":l[0]||(l[0]=e=>E.username=e),border:"none",clearable:"",placeholder:m(P)("usernamePlaceholder")},null,8,["modelValue","placeholder"])])),_:1}),n(a,{class:"mt-[40rpx]"},{default:i((()=>[n(o,{label:"",prop:"password","border-bottom":!0},{default:i((()=>[n(r,{modelValue:E.password,"onUpdate:modelValue":l[1]||(l[1]=e=>E.password=e),border:"none",type:"password",clearable:"",placeholder:m(P)("passwordPlaceholder")},null,8,["modelValue","placeholder"])])),_:1})])),_:1})])),_:1},512),[[x,"username"==Y.value]]),f(n(a,null,{default:i((()=>[n(o,{label:"",prop:"mobile","border-bottom":!0},{default:i((()=>[n(r,{modelValue:E.mobile,"onUpdate:modelValue":l[2]||(l[2]=e=>E.mobile=e),border:"none",clearable:"",placeholder:m(P)("mobilePlaceholder")},null,8,["modelValue","placeholder"])])),_:1}),n(a,{class:"mt-[40rpx]"},{default:i((()=>[n(o,{label:"",prop:"mobile_code","border-bottom":!0},{default:i((()=>[n(r,{modelValue:E.mobile_code,"onUpdate:modelValue":l[4]||(l[4]=e=>E.mobile_code=e),border:"none",type:"password",clearable:"",placeholder:m(P)("codePlaceholder")},{suffix:i((()=>[n(t,{mobile:E.mobile,type:"login",modelValue:E.mobile_key,"onUpdate:modelValue":l[3]||(l[3]=e=>E.mobile_key=e)},null,8,["mobile","modelValue"])])),_:1},8,["modelValue","placeholder"])])),_:1})])),_:1})])),_:1},512),[[x,"mobile"==Y.value]]),n(a,{class:"flex text-xs justify-between mt-[20rpx] text-gray-400"},{default:i((()=>[n(h,{url:"/app/pages/auth/register"},{default:i((()=>[p(d(m(P)("noAccount"))+" ",1),n(y,{class:"text-primary"},{default:i((()=>[p(d(m(P)("toRegister")),1)])),_:1})])),_:1}),n(h,{url:"/app/pages/auth/resetpwd"},{default:i((()=>[p(d(m(P)("resetpwd")),1)])),_:1})])),_:1}),n(a,{class:"mt-[80rpx]"},{default:i((()=>[n(v,{type:"primary",loading:X.value,loadingText:m(P)("logining"),onClick:H},{default:i((()=>[p(d(m(P)("login")),1)])),_:1},8,["loading","loadingText"])])),_:1})])),_:1},8,["model","rules"])])),_:1})])),_:1}),m(R).login.agreement_show?(s(),u(a,{key:0,class:"text-xs py-[50rpx] flex justify-center w-full"},{default:i((()=>[p(d(m(P)("agreeTips"))+" ",1),n(h,{url:"/app/pages/auth/agreement?key=service"},{default:i((()=>[n(y,{class:"text-primary"},{default:i((()=>[p(d(m(P)("userAgreement")),1)])),_:1})])),_:1}),p(" "+d(m(P)("and"))+" ",1),n(h,{url:"/app/pages/auth/agreement?key=privacy"},{default:i((()=>[n(y,{class:"text-primary"},{default:i((()=>[p(d(m(P)("privacyAgreement")),1)])),_:1})])),_:1})])),_:1})):_("v-if",!0)])),_:1})}}});export{E as default};