import{C as e,a,r as t,o as s,a2 as o,K as l,t as r,b as i,d as n,e as u,f as c,w as d,g as m,v as f,l as p,m as h,j as _,b4 as g,p as y,a1 as b,y as v,aj as w,an as x}from"./index-DVkgSHpn.js";import{_ as $}from"./el-navbar.DVIyjZEN.js";import{_ as k,b as T,a as j}from"./el-layout._U-vZTft.js";import{_ as C}from"./el-checkbox.DqvOzTsU.js";const U=k({__name:"register",setup(k){const U=e(),V=a().getApp();t(V.avatar);const z=t(1),q=t(1);let B=t(!1);s((e=>{if(o().isWechat&&null!=e.code&&!l(e.code)){let a={scene:"wechat",code:e.code};uni.$http.post("wechat.auth/login",a).then((e=>{U.login(e.data.token),U.getUser(),e.data.is_bind?r("pages/user/bind"):r("pages/index/ucenter")}))}}));const W=()=>{r(uni.$config.get("tabBar.defaultHome","pages/index/index"))},A=async e=>{if(!B.value)return uni.$layer.showToast("请勾选已阅读并同意《服务协议》和《隐私协议》"),!1;let a=e.detail.value;if(a.username.length<=0)return uni.$layer.showToast("请输入帐号名称"),!1;if(a.password.length<=0)return uni.$layer.showToast("请输入密码"),!1;if(a.confirm_password.length<=0)return uni.$layer.showToast("请输入确认密码"),!1;let t=uni.$storage.get("uid",0);t>0&&(a.uid=t),uni.$http.post("user/register",a).then((e=>{e.code?o().isWechat?uni.$http.get("wechat.auth/config").then((e=>{e.code&&(location.href=`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${e.data.appid}&redirect_uri=${e.data.domain}/pages/user/login&response_type=code&scope=snsapi_base&state=${e.data.state}#wechat_redirect`)})):o().isMini?g({success:function(e){let a={scene:"miniprogram",code:e.code};uni.$http.post("wechat.auth/login",a).then((e=>{e.code?(U.login(e.data.token),U.getUser(),e.data.is_bind?r("pages/user/bind"):r("pages/index/ucenter")):uni.$layer.showToast(e.msg)}))},fail:function(e){uni.$layer.showToast("微信登录失败")}}):(U.login(e.data),U.getUser(),r("pages/index/ucenter")):uni.$layer.showToast(e.msg)}))};return(e,a)=>{const t=i(n("el-navbar"),$),s=y,o=b,l=i(n("uni-icons"),T),g=i(n("el-checkbox"),C),k=v,U=w,H=x,I=i(n("el-layout"),j);return u(),c(I,null,{default:d((()=>[m(t,{placeholder:!0,fixed:!0,autoBack:!1,border:!0,title:"会员注册",onLeft:W}),m(s,{class:"the-form"},{default:d((()=>[m(H,{onSubmit:A},{default:d((()=>[m(s,{class:"form-item"},{default:d((()=>[m(s,{class:"form-item-body form-item-border"},{default:d((()=>[m(s,{class:"form-item-icon"},{default:d((()=>[f(" 帐号名称 ")])),_:1}),m(s,{class:"form-item-input"},{default:d((()=>[m(o,{type:"text",name:"username",placeholder:"请输入帐号名称","placeholder-class":"form-item-placeholder"})])),_:1})])),_:1})])),_:1}),m(s,{class:"form-item"},{default:d((()=>[m(s,{class:"form-item-body form-item-border"},{default:d((()=>[m(s,{class:"form-item-icon"},{default:d((()=>[f(" 设置密码 ")])),_:1}),m(s,{class:"form-item-input"},{default:d((()=>[m(o,{type:1==z.value?"password":"text",name:"password",placeholder:"请输入密码","placeholder-class":"form-item-placeholder"},null,8,["type"])])),_:1}),m(s,{class:"form-item-right"},{default:d((()=>[m(l,{type:1==z.value?"eye":"eye-slash",size:"20",color:"#9fa3ab",onClick:a[0]||(a[0]=e=>z.value=1==z.value?0:1)},null,8,["type"])])),_:1})])),_:1})])),_:1}),m(s,{class:"form-item"},{default:d((()=>[m(s,{class:"form-item-body form-item-border"},{default:d((()=>[m(s,{class:"form-item-icon"},{default:d((()=>[f(" 确认密码 ")])),_:1}),m(s,{class:"form-item-input"},{default:d((()=>[m(o,{type:1==q.value?"password":"text",name:"confirm_password",placeholder:"请输入确认密码","placeholder-class":"form-item-placeholder"},null,8,["type"])])),_:1}),m(s,{class:"form-item-right"},{default:d((()=>[m(l,{type:1==q.value?"eye":"eye-slash",size:"20",color:"#9fa3ab",onClick:a[1]||(a[1]=e=>q.value=1==q.value?0:1)},null,8,["type"])])),_:1})])),_:1})])),_:1}),1==p(V).users_agree?(u(),c(s,{key:0,class:"form-item"},{default:d((()=>[m(s,{class:"form-item-body"},{default:d((()=>[m(s,{class:"form-item-text"},{default:d((()=>[m(g,{modelValue:p(B),"onUpdate:modelValue":a[2]||(a[2]=e=>h(B)?B.value=e:B=e),shape:"circle",activeColor:"var(--ui-bg-color)"},null,8,["modelValue"]),m(s,{class:"agreement-box"},{default:d((()=>[f(" 已阅读并同意 "),m(k,{onClick:a[3]||(a[3]=e=>p(r)("pages/user/agreement?type=service"))},{default:d((()=>[f("《服务协议》")])),_:1}),f(" 和 "),m(k,{onClick:a[4]||(a[4]=e=>p(r)("pages/user/agreement?type=privacy"))},{default:d((()=>[f("《隐私协议》")])),_:1})])),_:1})])),_:1})])),_:1})])),_:1})):_("",!0),m(s,{class:"form-item"},{default:d((()=>[m(s,{class:"form-item-body"},{default:d((()=>[m(U,{class:"form-item-button","form-type":"submit"},{default:d((()=>[f("注 册")])),_:1})])),_:1})])),_:1})])),_:1})])),_:1})])),_:1})}}},[["__scopeId","data-v-1a8d27d1"]]);export{U as default};
//# sourceMappingURL=pages-user-register.DMMsIS3V.js.map
