pages-index-login.DXhDRohc.js 6.2 KB

1
  1. import{r as e,T as a,v as s,U as l,o as r,s as t,V as n,t as o,W as i,X as c,a as u,b as d,x as m,f as p,w as g,F as f,e as _,g as h,j as b,u as y,y as v,d as U,z as x,Y as w,Z as k,i as V,k as I,K as E,O as M}from"./index-C8dnzfoT.js";import{c as O,m as R,_ as q}from"./phone-international-input.vue_vue_type_style_index_0_scoped_87b92f91_lang.DyghQp4d.js";import{_ as j,a as C,b as F,p as P}from"./phone-international-input.DHpI8MXY.js";import{_ as $}from"./_plugin-vue_export-helper.BCo6x5W8.js";import"./uni-icons.BuqvWexr.js";const S=$({__name:"login",setup($){const S=e(!!a("linkId")),B=(e,a)=>{L.model.mobile=e,L.mobileErrorMsg=a},L=s({verifyUsername:!1,usernameErrorMsg:"",mobileErrorMsg:"",openid:"",socialUsers:[],registerReqVO:{type:31,code:"",state:"",username:"",linkId:a("linkId")||void 0},isMobileEnd:!1,codeText:"获取验证码",model:{mobile:"",code:"",scene:1},rules:{code:O,mobile:R}}),T=e(!1),A=e(!1);function W(e){history.replaceState?(history.replaceState(null,document.title,e),history.go(0)):location.replace(e)}let z=e("");async function K(e){const a=e.detail.value;if(""==a||a==z.value)return!1;z.value=a;const{data:s}=await w.verifyUsername(a);console.log(s),s?(L.usernameErrorMsg="",L.verifyUsername=s):(L.usernameErrorMsg=o("account.username_exists"),L.verifyUsername=s)}async function X(){const{code:e}=await w.OfficialEnterLogin(L.model,L.registerReqVO);if(0===e){k();let e=a("returnUrl");e?(i("returnUrl"),W(e)):c({url:"/"})}}return l((async()=>{const e={};new URLSearchParams(location.search).forEach(((a,s)=>{e[s]=a})),L.registerReqVO.code=e.code,L.registerReqVO.state=e.state})),r((async e=>{new URLSearchParams(location.search).forEach(((a,s)=>{e[s]=a}));const s=e.event,l=e.code,r=e.state;if("login"===s){const e=await t.$platform.useProvider().login(l,r);if(console.log("login.vue的res",e),!e)return n({title:o("setting.prompt"),content:o("account.wechat_no_account"),confirmColor:"#0e932e",showCancel:!1,buttonText:o("common.confirm"),success:function(e){e.confirm&&t.$router.go("/pages/index/index")}}),!1;if(null!=e.data.socialUsers)return u=e.data.openid,d=e.data.socialUsers,A.value=!0,L.openid=u,L.socialUsers=d,console.log("updateSocialUsers条用了,这时state.socialUsers是",L.socialUsers),!1}else{if("register"===s)return await t.$platform.useProvider().register(l,r),T.value=!0,!1;"bind"===s&&await t.$platform.useProvider().bind(l,r)}var u,d;let m=a("returnUrl");m?(i("returnUrl"),W(m)):c({url:"/"})})),(e,s)=>{const l=V,r=I,n=E,k=u(d("su-popup"),q),O=u(d("uni-easyinput"),j),R=u(d("uni-forms-item"),C),$=u(d("uni-forms"),F),z=M;return _(),m(f,null,[p(l),p(k,{show:A.value,type:"center",round:"10",isMaskClick:!1},{default:g((()=>[p(l,{class:"head-nav"},{default:g((()=>[p(l,{class:"head-box"},{default:g((()=>[p(l,{class:"ss-flex ss-m-b-20"},{default:g((()=>[p(l,{class:"isActive head-title"},{default:g((()=>[h(b(y(o)("account.select_account_login")),1)])),_:1})])),_:1})])),_:1})])),_:1}),p(l,null,{default:g((()=>[p(n,{class:"side-menu-wrap","scroll-y":"",style:{height:"600rpx"}},{default:g((()=>[(_(!0),m(f,null,v(L.socialUsers,(e=>(_(),U(l,{key:e.username,class:"ss-flex",style:{padding:"20rpx",margin:"0 auto",width:"520rpx"},onClick:s=>async function(e){console.log(e);const{code:s}=await w.selectUsernameLogin({openId:L.openid,username:e});if(0===s){let e=a("returnUrl");e?(console.log(e),i("returnUrl"),W(e)):c({url:"/"})}}(e.username)},{default:g((()=>[p(r,{src:e.avatar,style:{width:"100rpx",height:"100rpx","border-radius":"50%","margin-right":"20rpx"}},null,8,["src"]),p(l,null,{default:g((()=>[h(b(e.username),1)])),_:2},1024)])),_:2},1032,["onClick"])))),128)),L.socialUsers.length?x("",!0):(_(),U(l,{key:0,style:{padding:"20rpx",width:"520rpx","text-align":"center","margin-top":"100rpx"}},{default:g((()=>[h(b(y(o)("account.wechat_no_bind")),1)])),_:1}))])),_:1})])),_:1})])),_:1},8,["show"]),p(k,{show:T.value,round:"10",isMaskClick:!1},{default:g((()=>[p(l,null,{default:g((()=>[p(l,{class:"head-box"},{default:g((()=>[p(l,{class:"ss-flex ss-m-b-20"},{default:g((()=>[p(l,{class:"isActive head-title"},{default:g((()=>[h(b(y(o)("account.wechat_register")),1)])),_:1})])),_:1})])),_:1}),p($,{modelValue:L.model,"onUpdate:modelValue":s[3]||(s[3]=e=>L.model=e),rules:L.rules,validateTrigger:"bind",labelWidth:"140",labelAlign:"center",class:"loginUniForm"},{default:g((()=>[p(R,{name:"username",label:y(o)("account.username"),class:"loginUniFormItem","error-message":L.usernameErrorMsg},{default:g((()=>[p(O,{placeholder:y(o)("account.enter_username"),modelValue:L.registerReqVO.username,"onUpdate:modelValue":s[0]||(s[0]=e=>L.registerReqVO.username=e),inputBorder:!1,clearable:!1,onBlur:K},{right:g((()=>[L.verifyUsername?(_(),U(l,{key:1,class:"icon"},{default:g((()=>[p(r,{src:y(t).$url.static("/static/images/chenggong.png")},null,8,["src"])])),_:1})):(_(),U(l,{key:0,class:"icon"},{default:g((()=>[p(r,{style:"",src:y(t).$url.static("/static/images/shibai.png")},null,8,["src"])])),_:1}))])),_:1},8,["placeholder","modelValue"])])),_:1},8,["label","error-message"]),p(R,{name:"mobile",label:y(o)("account.phone_number"),class:"mobile loginUniFormItem ss-p-t-10","error-message":L.mobileErrorMsg},{default:g((()=>[p(P,{"verify-username":L.verifyUsername,onInput:B},null,8,["verify-username"])])),_:1},8,["label","error-message"]),p(R,{name:"code",label:y(o)("account.verification_code"),class:"loginUniFormItem"},{default:g((()=>[p(O,{placeholder:y(o)("account.enter_verification_code"),modelValue:L.model.code,"onUpdate:modelValue":s[1]||(s[1]=e=>L.model.code=e),inputBorder:!1,type:"number",maxlength:"4"},null,8,["placeholder","modelValue"])])),_:1},8,["label"]),S.value?x("",!0):(_(),U(R,{key:0,name:"linkId",label:y(o)("account.link_id"),class:"loginUniFormItem"},{default:g((()=>[p(O,{placeholder:y(o)("account.enter_link_id"),modelValue:L.registerReqVO.linkId,"onUpdate:modelValue":s[2]||(s[2]=e=>L.registerReqVO.linkId=e),inputBorder:!1,type:"input"},null,8,["placeholder","modelValue"])])),_:1},8,["label"]))])),_:1},8,["modelValue","rules"]),p(l,{style:{display:"flex","justify-content":"space-between",padding:"40rpx","padding-bottom":"40rpx"}},{default:g((()=>[p(z,{class:"ss-reset-button login-btn-start",onClick:X},{default:g((()=>[h(b(y(o)("account.register")),1)])),_:1})])),_:1})])),_:1})])),_:1},8,["show"])],64)}}},[["__scopeId","data-v-9c20d981"]]);export{S as default};