"use strict";const e=require("../../common/vendor.js"),o=require("../../common/assets.js"),a=require("../../api/index.js"),s=require("../../utils/fun.js"),l=require("../../uni_modules/wot-design-uni/components/composables/useCountDown.js");require("../../uni_modules/wot-design-uni/locale/index.js"),require("../../uni_modules/wot-design-uni/dayjs/index.js");const t=require("../../store/index.js");if(!Array){e.resolveComponent("wd-navbar")()}Math;const u=e.defineComponent({__name:"login",setup(u){const i=t.Store(),{start:r,pause:n,reset:v,current:d}=l.useCountDown({time:6e4,onChange(e){},onFinish(){w.value="重新发送"}}),c={mobile:"",password:"",code:"",inviteCode:"",passwordNew:""},p=e.ref({...c});e.onLoad((()=>{e.index.getStorageSync("inviteCode")?(p.value.inviteCode=e.index.getStorageSync("inviteCode"),console.log(p.value.inviteCode)):console.log("未取到邀请码")}));const g=e.ref("login"),w=e.ref("点击获取验证码"),m=e.ref("password"),f=e.ref({mobile:"",password:"",code:""}),b=e.ref(!1),C=()=>{e.index.navigateBack()},h=e=>{m.value=e,f.value={}},x=e=>{(f.value.mobile||1!=e)&&(p.value.mobile||2!=e)?d.value.seconds?s.toast("请等待倒计时结束"):a.api.smsCode({mobile:2==e?p.value.mobile:f.value.mobile,scene:1}).then((e=>{r(),s.toast("验证码发送成功")})).catch((e=>{console.log(e),s.toast("验证码发送失败")})):s.toast("请输入手机号")},_=()=>{if("register"==g.value){if(!p.value.mobile)return s.toast("请输入手机号码");if(!p.value.code)return s.toast("请输入验证码");if(!p.value.password)return s.toast("请输入密码");if(!p.value.passwordNew)return s.toast("请再次输入密码");if(p.value.password!=p.value.passwordNew)return s.toast("两次密码输入不一致");a.api.registerApi(p.value).then((o=>{e.index.showModal({title:"提示",content:"注册成功",showCancel:!1,success:e=>{g.value="login",p.value={...c}}})}))}else{if(!f.value.mobile)return s.toast("请输入手机号码");if("password"===m.value){if(!f.value.password)return s.toast("请输入登录密码");a.api.loginApi(f.value).then((o=>{e.index.setStorageSync("Authorization",o.accessToken),i.setUserId(o.userId),i.usersGetInfo(),C()}))}else{if(!f.value.code)return s.toast("请输入验证码");a.api.smsLoginApi(f.value).then((o=>{e.index.setStorageSync("Authorization",o.accessToken),i.setUserId(o.userId),i.usersGetInfo(),C()}))}}};return(a,s)=>e.e({a:o._imports_0$3,b:e.o(C),c:e.p({"left-arrow":!0,"custom-style":"background-color: transparent !important;",safeAreaInsetTop:!0}),d:"login"==g.value},"login"==g.value?e.e({e:"password"===m.value},(m.value,{}),{f:"password"===m.value?1:"",g:e.o((e=>h("password"))),h:"code"===m.value},(m.value,{}),{i:"code"===m.value?1:"",j:e.o((e=>h("code")))}):{},{k:"login"==g.value},"login"==g.value?e.e({l:f.value.mobile,m:e.o((e=>f.value.mobile=e.detail.value)),n:"password"===m.value},"password"===m.value?{o:f.value.password,p:e.o((e=>f.value.password=e.detail.value))}:{q:f.value.code,r:e.o((e=>f.value.code=e.detail.value)),s:e.t(e.unref(d).seconds||w.value),t:e.o((e=>x(1)))}):{},{v:"register"==g.value},"register"==g.value?{w:p.value.mobile,x:e.o((e=>p.value.mobile=e.detail.value)),y:p.value.code,z:e.o((e=>p.value.code=e.detail.value)),A:e.t(e.unref(d).seconds||w.value),B:e.o((e=>x(2))),C:p.value.password,D:e.o((e=>p.value.password=e.detail.value)),E:p.value.passwordNew,F:e.o((e=>p.value.passwordNew=e.detail.value)),G:p.value.inviteCode,H:e.o((e=>p.value.inviteCode=e.detail.value))}:{},{I:"register"==g.value},"register"==g.value?{J:e.o((e=>g.value="login"))}:{},{K:"login"==g.value},"login"==g.value?{L:e.o((e=>g.value="register"))}:{},{M:e.t("register"==g.value?"注册":"登录"),N:b.value,O:b.value,P:e.o(_)})}}),i=e._export_sfc(u,[["__scopeId","data-v-74a867ba"]]);wx.createPage(i);
