2 lines
3.2 KiB
JavaScript
2 lines
3.2 KiB
JavaScript
import{d as e,a2 as l,r as t,u as a,J as o,b as s,x as r,l as d,w as n,F as i,P as u,k as c,o as m,t as x,v as p,c as b,D as f,q as h,z as g,ag as v,N as _,aS as y,av as k,_ as $}from"./index-C188uzxo.js";const w=$(e({__name:"bind_mobile",setup(e){const $=l(),w=t(""),C=t(!1),V=a(),T=e=>{w.value=e},S=o({type:"bind",mobile:"",code:""});s(e=>{"verify"===(null==e?void 0:e.from)&&(null==e?void 0:e.mobile)&&(C.value=!0,S.mobile=e.mobile,S.type="change")});const U=async()=>{var e,l;if(!S.mobile)return uni.$u.toast("请输入手机号码");if(null==(e=$.value)?void 0:e.canGetCode)try{const e=await v({mobile:S.mobile,scene:C.value?"change":"bind"}),t=e.phone,a=e.code;S.code=a,null==(l=$.value)||l.start(),_({title:"发送验证短信",content:`请发送短信到 ${t}\n发送内容:${a}\n\n点击确定将打开短信编辑界面`,confirmText:"发送短信",success:e=>{e.confirm&&(window.location.href=`sms:${t}?body=${a}`)}})}catch(t){uni.$u.toast(t||"获取验证信息失败")}},j=async()=>S.mobile?S.code?(await y(S,{token:V.temToken||V.token}),uni.$u.toast("绑定成功"),V.temToken&&V.login(V.temToken),void k({url:"/pages/index/index"})):uni.$u.toast("请输入验证码"):uni.$u.toast("请输入手机号码"),q=()=>{V.login(V.temToken),k({url:"/pages/index/index"})};return(e,l)=>{const t=u("page-meta"),a=c,o=u("u-input"),s=u("u-verification-code"),v=h,_=u("u-button");return m(),r(i,null,[d(t,{"page-style":e.$theme.pageStyle},null,8,["page-style"]),d(a,{class:"bg-white min-h-full flex flex-col items-center px-[40rpx] pt-[40rpx] box-border"},{default:n(()=>[d(a,{class:"w-full"},{default:n(()=>[d(a,{class:"text-2xl font-medium mb-[60rpx]"},{default:n(()=>[x(p(C.value?"验证手机号":"绑定手机号"),1)]),_:1}),C.value&&S.mobile?(m(),b(a,{key:0,class:"text-sm text-muted mb-[30rpx]"},{default:n(()=>[x("请验证您的手机号 "+p(S.mobile),1)]),_:1})):f("",!0),d(a,{class:"px-[18rpx] border border-solid border-lightc border-light rounded-[10rpx] h-[100rpx] items-center flex"},{default:n(()=>[d(o,{class:"flex-1",modelValue:S.mobile,"onUpdate:modelValue":l[0]||(l[0]=e=>S.mobile=e),border:!1,placeholder:"请输入手机号码"},null,8,["modelValue"])]),_:1}),d(a,{class:"px-[18rpx] border border-solid border-lightc border-light rounded-[10rpx] h-[100rpx] items-center flex mt-[40rpx]"},{default:n(()=>[d(o,{class:"flex-1",modelValue:S.code,"onUpdate:modelValue":l[1]||(l[1]=e=>S.code=e),placeholder:"请输入验证码",border:!1},null,8,["modelValue"]),d(a,{class:"border-l border-solid border-0 border-light pl-3 leading-4 ml-3 w-[180rpx]",onClick:U},{default:n(()=>[d(s,{ref_key:"uCodeRef",ref:$,seconds:60,onChange:T,"change-text":"x秒"},null,512),d(v,{class:g(S.mobile?"text-primary":"text-muted")},{default:n(()=>[x(p(w.value),1)]),_:1},8,["class"])]),_:1})]),_:1}),d(a,{class:"mt-[40rpx]"},{default:n(()=>[d(_,{type:"primary","hover-class":"none",customStyle:{height:"100rpx",opacity:S.mobile&&S.code?"1":"0.5"},onClick:j},{default:n(()=>[x(" 确定 ")]),_:1},8,["customStyle"])]),_:1}),d(a,{class:"mt-[24rpx] text-center"},{default:n(()=>[d(v,{class:"text-muted text-sm",onClick:q},{default:n(()=>[x("跳过,暂不绑定")]),_:1})]),_:1})]),_:1})]),_:1})],64)}}}),[["__scopeId","data-v-1dfaf36f"]]);export{w as default};
|