1import{bp as e,c as t,w as s,cH as n,N as o,r as a,q as i,o as r,a as l,i as d,n as h,j as c,e as u,t as p,a6 as f,a7 as w,g as y,F as b,f as g,x as m,k as C,h as _,dv as k}from"./index-DEpBscAf.js";import{_ as v}from"./back-btn.C6S0SBZD.js";import{r as A}from"./uni-app.es.DCMxoOwQ.js";import{_ as E}from"./lazy-image.CJo0AQX9.js";import{_ as I}from"./layout-page.54DLubJQ.js";import{_ as P}from"./content-layout.A4K2ggmy.js";import{c as N}from"./countryCode.Bwo12eni.js";import{_ as x}from"./_plugin-vue_export-helper.BCo6x5W8.js";import"./chevron-left.Da9ti6ri.js";async function S(t,s){let n;try{n=await e({funcName:t,params:s,showLoading:!1,showError:!1,sensitive:!0})}catch(o){throw Object.assign(new Error("ç¨æ·æªç»å½"===(null==o?void 0:o.message)?"请å
ç»å½åç»§ç»":"ç½ç»æéªè¯æå¡ææ¶ä¸å¯ç¨ï¼è¯·ç¨åéè¯"),{code:"PHONE_CHANGE_UNAVAILABLE"})}if(!(null==n?void 0:n.data)||n.errMsg){const e=new Error((null==n?void 0:n.errMsg)||"请æ±å¤±è´¥ï¼è¯·ç¨åéè¯");throw Object.assign(e,{code:(null==n?void 0:n.errCode)||"PHONE_CHANGE_UNAVAILABLE"}),e}return n.data}const O=e=>S("function-user-changephone",{...e,action:"query"}),D=e=>S("function-user-changephone",{...e,action:"change"});function T(){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}const K=x({data:()=>({countries:N,info:null,flow:{},phoneNumber:"",countryCode:"86",verifyCode:"",sentTarget:"",busy:!1,busyAction:"",error:"",done:!1,pending:!1,showFeedback:!1,resultPhone:"",currentPhoneChanged:!1,currentPhoneMasked:"",now:Date.now(),timer:null,requestVersion:0,alive:!0}),computed:{step(){return this.done||["old_verified","committing"].includes(this.flow.stage)?"new":"old"},target(){return"86"===this.countryCode?this.phoneNumber.trim():"+"+this.countryCode+this.phoneNumber.trim()},waitSeconds(){return Math.max(0,Math.ceil(((this.flow.resendAt||0)-this.now)/1e3))},expired(){return!!this.flow.expiresAt&&this.flow.expiresAt<=this.now},cooldown(){var e;return((null==(e=this.info)?void 0:e.nextChangeAt)||0)>this.now},canSend(){var e;return"old"===this.step||!("86"!==this.countryCode&&!(null==(e=this.info)?void 0:e.hasPassword))&&("86"===this.countryCode?/^1\d{10}$/.test(this.target):/^\+[1-9]\d{6,14}$/.test(this.target)&&/^\d+$/.test(this.phoneNumber))},canSubmit(){return!!this.flow.challengeId&&/^\d{6}$/.test(this.verifyCode)&&("old"===this.step||this.sentTarget===this.target)},userId(){var e;return(null==(e=this.$store.state.user.userInfo)?void 0:e._id)||""}},onLoad(){this.load(),this.timer=setInterval((()=>{this.now=Date.now()}),1e3)},onUnload(){this.alive=!1,this.requestVersion++,clearInterval(this.timer),this.verifyCode=""},methods:{storageKey(){return"phone-change-flow:"+this.userId},remember(){try{this.flow.flowId?sessionStorage.setItem(this.storageKey(),this.flow.flowId):sessionStorage.removeItem(this.storageKey())}catch{}},forget(){try{sessionStorage.removeItem(this.storageKey())}catch{}},async run(e,t){if(this.busy)return;this.busy=!0,this.busyAction=e,this.error="";const s=++this.requestVersion;try{await t((()=>this.alive&&this.requestVersion===s))}catch(n){if(!this.alive||s!==this.requestVersion||"CAPTCHA_CANCELLED"===n.code)return;this.error=n.message||"ç½ç»å¼å¸¸ï¼è¯·ç¨åéè¯",["CODE_LOCKED","WRONG_STAGE"].includes(n.code)&&(this.flow={...this.flow,stage:"locked"}),["FLOW_EXPIRED","ACCOUNT_CHANGED"].includes(n.code)&&(this.flow={...this.flow,expiresAt:1},this.pending=!1),"commit"===e&&["PHONE_OCCUPIED","PASSWORD_REQUIRED","SAME_PHONE","PHONE_NOT_ALLOWED"].includes(n.code)&&(this.flow={...this.flow,stage:"old_verified",challengeId:""},this.verifyCode="",this.sentTarget="",this.pending=!1),"commit"!==e||["CODE_INVALID","CODE_EXPIRED","PHONE_OCCUPIED","SAME_PHONE","PASSWORD_REQUIRED","PHONE_NOT_ALLOWED","CODE_LOCKED","WRONG_STAGE","FLOW_EXPIRED","ACCOUNT_CHANGED","CHANGE_COOLDOWN","ACCOUNT_UNAVAILABLE"].includes(n.code)||(this.pending=!0)}finally{this.alive&&s===this.requestVersion&&(this.busy=!1,this.busyAction="",this.now=Date.now())}},async load(e=!1){await this.run("load",(async t=>{let s=this.$store.state.user.userInfo;if(!0===e||!(null==s?void 0:s._id)||null==s.phoneChangeNextAt){try{await this.$store.dispatch("fetchCurrentUserInfo")}catch{throw new Error(this.$t("user.phoneChange.profileUnavailable"))}s=this.$store.state.user.userInfo}if(!t())return;if(this.info=null,!(null==s?void 0:s._id))throw new Error(this.$t("user.phoneChange.loginRequired"));if(-1===s.status||s.isAdmin&&s.outer_uid)throw new Error(this.$t("user.phoneChange.accountUnavailable"));if("number"!=typeof s.phoneChangeNextAt||!Number.isFinite(s.phoneChangeNextAt))throw new Error(this.$t("user.phoneChange.profileUnavailable"));const n=String(s.phoneNumber||"");this.info={hasPhone:!!n,hasPassword:!!s.password,oldPhoneMasked:n.length>7?n.slice(0,n.startsWith("+")?4:3)+" **** "+n.slice(-4):"",nextChangeAt:s.phoneChangeNextAt};let o="";try{o=sessionStorage.getItem(this.storageKey())||""}catch{}if(o){this.flow={flowId:o};try{const e=await O({flowId:o});if(!t())return;this.applyStatus(e)}catch(a){if(!t())return;if(!["FLOW_EXPIRED","ACCOUNT_CHANGED"].includes(a.code))throw this.pending=!0,a;this.forget(),this.flow={}}}}))},applyStatus(e){if("boolean"==typeof e.hasPhone){const{hasPhone:t,hasPassword:s,oldPhoneMasked:n,nextChangeAt:o}=e;this.info={hasPhone:t,hasPassword:s,oldPhoneMasked:n,nextChangeAt:o}}e.completed?this.finish(e):(this.flow={...e},this.pending="committing"===e.stage,"new"!==this.step||this.sentTarget||this.pending||(this.flow.challengeId=""),this.remember())},targetChanged(){this.verifyCode="",this.sentTarget="",this.flow={...this.flow,challengeId:""}},async sendCode(){!this.canSend||this.waitSeconds||this.expired||this.pending||await this.run("send",(async e=>{const t=this.target,s=this.step,n=await new Promise(((e,t)=>{const s=window.TencentCaptcha;s?new s("197773418",(s=>{0===s.ret?e({ticket:s.ticket,randstr:s.randstr}):t(Object.assign(new Error("已忶å¾å½¢éªè¯"),{code:"CAPTCHA_CANCELLED"}))}),{}).show():t(new Error("å¾å½¢éªè¯å°æªå è½½ï¼è¯·ç¨åéè¯"))}));if(!e())return;const a={...n,action:"old"===s?"changePhoneOld":"changePhoneNew",requestId:T(),...this.flow.flowId?{flowId:this.flow.flowId}:{},..."new"===s?{phoneNumber:t}:{}};this.verifyCode="",this.flow={...this.flow,challengeId:"",resendAt:Date.now()+6e4};const i=await(e=>S("function-login-gettelverifyv2",e))(a);!e()||"new"===s&&this.target!==t||(this.flow=i,this.sentTarget="new"===s?t:"",this.remember(),o({title:"éªè¯ç å·²åé",icon:"none"}))}))},async submit(){if(!this.canSubmit||this.expired||this.pending)return;const e="old"===this.step;await this.run(e?"verify":"commit",(async t=>{const s={flowId:this.flow.flowId,challengeId:this.flow.challengeId,verifyCode:this.verifyCode},n=await(e?(e=>S("function-user-changephone",{...e,action:"verifyOld"}))(s):D(s));t()&&(this.verifyCode="",e?(this.flow=n,this.remember()):this.finish(n))}))},async checkResult(){await this.run("query",(async e=>{const t=await O({flowId:this.flow.flowId});e()&&this.applyStatus(t)}))},async retryCommit(){"committing"!==this.flow.stage||this.expired||await this.run("commit",(async e=>{const t=await D({flowId:this.flow.flowId,challengeId:this.flow.challengeId});e()&&this.finish(t)}))},finish(e){this.done=!0,this.pending=!1,this.verifyCode="",this.error="",this.resultPhone=e.newPhoneMasked||this.flow.newPhoneMasked||"å·²ç»å®æ°ææºå·",this.currentPhoneChanged=!!e.currentPhoneChanged,this.currentPhoneMasked=e.currentPhoneMasked||"",this.forget(),this.$store.dispatch("fetchCurrentUserInfo").cat
1ch((()=>{}))},async restart(){this.busy||(this.forget(),this.flow={},this.pending=!1,this.verifyCode="",this.sentTarget="",this.error="",await this.load(!0))},formatTime:e=>new Date(e).toLocaleString("zh-CN",{hour12:!1}),backToSettings(){n({url:"/user/profile?id="+encodeURIComponent(this.userId)+"&tab=settings"})}}},[["render",function(e,n,o,N,x,S){const O=A(a("back-btn"),v),D=c,T=d,K=i("van-field"),L=i("van-cell-group"),U=A(a("lazy-image"),E),R=i("van-dialog"),V=A(a("layout-page"),I),$=A(a("content-layout"),P);return r(),t($,{size:"narrow",class:"phone-change-page"},{default:s((()=>[l(V,null,{header:s((()=>[l(T,{class:"phone-header"},{default:s((()=>[l(O),l(D,null,{default:s((()=>[u("æ´æ¢ææºå·")])),_:1})])),_:1})])),default:s((()=>[l(T,{class:"phone-body"},{default:s((()=>[l(T,{class:"phone-steps","aria-label":"æ´æ¢ææºå·æ¥éª¤"},{default:s((()=>[l(T,{class:h(["phone-step",{active:"old"===S.step,done:"old"!==S.step}])},{default:s((()=>[l(D,{class:"step-number"},{default:s((()=>[u("1")])),_:1}),l(D,null,{default:s((()=>[u("éªè¯åå·ç ")])),_:1})])),_:1},8,["class"]),l(T,{class:"step-line"}),l(T,{class:h(["phone-step",{active:"new"===S.step,done:x.done}])},{default:s((()=>[l(D,{class:"step-number"},{default:s((()=>[u("2")])),_:1}),l(D,null,{default:s((()=>[u("ç»å®æ°å·ç ")])),_:1})])),_:1},8,["class"])])),_:1}),x.done?(r(),t(T,{key:0,class:"phone-success",role:"status"},{default:s((()=>[l(T,{class:"success-mark"},{default:s((()=>[u("â")])),_:1}),l(T,{class:"phone-title"},{default:s((()=>[u("ææºå·æ´æ¢æå")])),_:1}),l(T,{class:"phone-number"},{default:s((()=>[u(p(x.resultPhone),1)])),_:1}),x.currentPhoneChanged?(r(),t(T,{key:0,class:"phone-description"},{default:s((()=>[u(" æ¬æ¬¡æ´æ¢å·²å®æï¼å½åç»å®å·ç 忥已å为 "+p(x.currentPhoneMasked)+"ï¼è¯·ä»¥è´¦å·è®¾ç½®ä¸çå·ç 为åã ",1)])),_:1})):(r(),t(T,{key:1,class:"phone-description"},{default:s((()=>[u(" 䏿¬¡è¯·ä½¿ç¨æ°ææºå·ç»å½ãè´¦å·èµæãæ¶èå订ååä¿çã ")])),_:1})),l(T,{class:"phone-primary",role:"button",tabindex:"0",onClick:S.backToSettings,onKeydown:[f(w(S.backToSettings,["prevent"]),["enter"]),f(w(S.backToSettings,["prevent"]),["space"])]},{default:s((()=>[u(" è¿åè´¦å·è®¾ç½® ")])),_:1},8,["onClick","onKeydown"])])),_:1})):x.info?(r(),y(b,{key:1},[x.info.hasPhone&&!S.cooldown||x.pending?x.pending?(r(),t(T,{key:1,class:"phone-notice",role:"status"},{default:s((()=>[l(T,{class:"phone-title"},{default:s((()=>[u("æ£å¨ç¡®è®¤ä¿®æ¹ç»æ")])),_:1}),l(T,{class:"phone-description"},{default:s((()=>[u(" æäº¤ç»æå°æªç¡®è®¤ï¼è¯·å
æ¥è¯¢ç»æã已宿çä¿®æ¹ä¼ç´æ¥æ¾ç¤ºæåã ")])),_:1}),l(T,{class:h(["phone-primary",{"is-disabled":x.busy}]),role:"button","aria-disabled":x.busy,tabindex:x.busy?-1:0,onClick:S.checkResult,onKeydown:[f(w(S.checkResult,["prevent"]),["enter"]),f(w(S.checkResult,["prevent"]),["space"])]},{default:s((()=>[u(p(x.busy?"æ£å¨æ¥è¯¢â¦":"æ¥è¯¢ä¿®æ¹ç»æ"),1)])),_:1},8,["class","aria-disabled","tabindex","onClick","onKeydown"]),"committing"===x.flow.stage?(r(),t(T,{key:0,class:h(["phone-secondary",{"is-disabled":x.busy||S.expired}]),role:"button","aria-disabled":x.busy||S.expired,tabindex:x.busy||S.expired?-1:0,onClick:S.retryCommit,onKeydown:[f(w(S.retryCommit,["prevent"]),["enter"]),f(w(S.retryCommit,["prevent"]),["space"])]},{default:s((()=>[u(" éè¯æäº¤ ")])),_:1},8,["class","aria-disabled","tabindex","onClick","onKeydown"])):g("",!0)])),_:1})):S.expired||"locked"===x.flow.stage?(r(),t(T,{key:2,class:"phone-notice"},{default:s((()=>[l(T,{class:"phone-title"},{default:s((()=>[u(p("locked"===x.flow.stage?"æ¬æ¬¡éªè¯å·²åç¨":"æ¬æ¬¡éªè¯å·²è¿æ"),1)])),_:1}),l(T,{class:"phone-description"},{default:s((()=>[u("è¯·éæ°éªè¯åææºå·åç»§ç»ã")])),_:1}),l(T,{class:h(["phone-primary",{"is-disabled":x.busy}]),role:"button","aria-disabled":x.busy,tabindex:x.busy?-1:0,onClick:S.restart,onKeydown:[f(w(S.restart,["prevent"]),["enter"]),f(w(S.restart,["prevent"]),["space"])]},{default:s((()=>[u(" éæ°å¼å§ ")])),_:1},8,["class","aria-disabled","tabindex","onClick","onKeydown"])])),_:1})):(r(),y(b,{key:3},[l(T,{class:"phone-title"},{default:s((()=>[u(p(e.$t("old"===S.step?"user.phoneChange.verifyOldTitle":"user.phoneChange.newPhoneTitle")),1)])),_:1}),"old"===S.step?(r(),t(T,{key:0,class:"phone-description"},{default:s((()=>[u(" 为ä¿éè´¦å·å®å
¨ï¼è¯·å
éªè¯å½åç»å®çææºå·ã ")])),_:1})):(r(),t(T,{key:1,class:"phone-description"},{default:s((()=>[u(" åææºå·å·²éªè¯ã请填åä½ æ¬äººæ£å¨ä½¿ç¨çæ°ææºå·ã ")])),_:1})),"old"===S.step?(r(),t(T,{key:2,class:"phone-number"},{default:s((()=>[u(p(x.info.oldPhoneMasked),1)])),_:1})):g("",!0),l(T,{class:"phone-form"},{default:s((()=>[l(L,{inset:""},{default:s((()=>["new"===S.step?(r(),y(b,{key:0},[l(K,{label:"å½å®¶ / å°åº",readonly:""},{input:s((()=>[m(C("select",{"onUpdate:modelValue":n[0]||(n[0]=e=>x.countryCode=e),class:"country-select",disabled:x.busy,"aria-label":"å½å®¶æå°åº",onChange:n[1]||(n[1]=(...e)=>S.targetChanged&&S.targetChanged(...e))},[(r(!0),y(b,null,_(x.countries,((e,t)=>(r(),y("option",{key:t,value:e.tel},p(e.name)+" +"+p(e.tel),9,["value"])))),128))],40,["disabled"]),[[k,x.countryCode]])])),_:1}),l(K,{modelValue:x.phoneNumber,"onUpdate:modelValue":[n[2]||(n[2]=e=>x.phoneNumber=e),S.targetChanged],label:"æ°ææºå·",type:"tel",maxlength:"15",autocomplete:"tel-national",placeholder:"请è¾å
¥æ°ææºå·",disabled:x.busy},null,8,["modelValue","disabled","onUpdate:modelValue"])],64)):g("",!0),l(K,{modelValue:x.verifyCode,"onUpdate:modelValue":n[4]||(n[4]=e=>x.verifyCode=e),label:"éªè¯ç ",type:"digit",maxlength:"6",autocomplete:"one-time-code",center:"",placeholder:e.$t("user.phoneChange.codePlaceholder"),disabled:x.busy,onKeyup:f(S.submit,["enter"])},{button:s((()=>[l(T,{class:h(["code-button",{"is-disabled":x.busy||S.waitSeconds>0||!S.canSend}]),role:"button","aria-disabled":x.busy||S.waitSeconds>0||!S.canSend,tabindex:x.busy||S.waitSeconds>0||!S.canSend?-1:0,onClick:S.sendCode,onKeydown:[f(w(S.sendCode,["stop","prevent"]),["enter"]),f(w(S.sendCode,["prevent"]),["space"])],onKeyup:n[3]||(n[3]=f(w((()=>{}),["stop"]),["enter"]))},{default:s((()=>[u(p(S.waitSeconds>0?S.waitSeconds+" ç§åéå":"send"===x.busyAction?"æ£å¨åéâ¦":"è·åéªè¯ç "),1)])),_:1},8,["class","aria-disabled","tabindex","onClick","onKeydown"])])),_:1},8,["modelValue","placeholder","disabled","onKeyup"])])),_:1}),"new"!==S.step||"86"===x.countryCode||x.info.hasPassword?g("",!0):(r(),t(T,{key:0,class:"phone-inline-tip"},{default:s((()=>[u(" å¢å¤ææºå·éè¦ä½¿ç¨å¯ç ç»å½ï¼è¯·å
å¨è´¦å·è®¾ç½®ä¸è®¾ç½®å¯ç ã "),l(T,{class:"phone-link",role:"link",tabindex:"0",onClick:S.backToSettings,onKeydown:[f(w(S.backToSettings,["prevent"]),["enter"]),f(w(S.backToSettings,["prevent"]),["space"])]},{default:s((()=>
1[u(" åå¾è®¾ç½®å¯ç ")])),_:1},8,["onClick","onKeydown"])])),_:1}))])),_:1}),x.flow.challengeId&&!x.verifyCode?(r(),t(T,{key:3,class:"phone-caption"},{default:s((()=>[u(" éªè¯ç 5 åéå
ææï¼éæ°åéåè¯·ä½¿ç¨ææ°éªè¯ç ã ")])),_:1})):g("",!0),l(T,{class:h(["phone-primary",{"is-disabled":x.busy||!S.canSubmit}]),role:"button","aria-disabled":x.busy||!S.canSubmit,tabindex:x.busy||!S.canSubmit?-1:0,onClick:S.submit,onKeydown:[f(w(S.submit,["prevent"]),["enter"]),f(w(S.submit,["prevent"]),["space"])]},{default:s((()=>[u(p(x.busy&&"send"!==x.busyAction?"æ£å¨éªè¯â¦":"old"===S.step?"éªè¯å¹¶ç»§ç»":"ç¡®è®¤æ´æ¢"),1)])),_:1},8,["class","aria-disabled","tabindex","onClick","onKeydown"]),l(T,{class:"phone-caption"},{default:s((()=>[u("æ´æ¢æååï¼7 天å
æ æ³åæ¬¡æ´æ¢ã")])),_:1})],64)):(r(),t(T,{key:0,class:"phone-notice"},{default:s((()=>[l(T,{class:"phone-title"},{default:s((()=>[u(p(x.info.hasPhone?"ææ¶æ æ³æ´æ¢":"å½åè´¦å·æªç»å®ææºå·"),1)])),_:1}),l(T,{class:"phone-description"},{default:s((()=>[u(p(x.info.hasPhone?"æ¯ 7 天坿´æ¢ä¸æ¬¡ï¼ä¸æ¬¡å¯æ´æ¢æ¶é´ï¼"+S.formatTime(x.info.nextChangeAt):"请è系管çååå©ç»å®ææºå·ã"),1)])),_:1})])),_:1}))],64)):(r(),t(T,{key:2,class:"phone-notice"},{default:s((()=>[l(T,{class:"phone-description"},{default:s((()=>[u(p(x.busy?"æ£å¨è¯»åè´¦å·ä¿¡æ¯â¦":"ææ¶æ æ³è¯»åè´¦å·ä¿¡æ¯"),1)])),_:1}),x.busy?g("",!0):(r(),t(T,{key:0,class:"phone-secondary",role:"button",tabindex:"0",onClick:S.load,onKeydown:[f(w(S.load,["prevent"]),["enter"]),f(w(S.load,["prevent"]),["space"])]},{default:s((()=>[u(" éæ°å è½½ ")])),_:1},8,["onClick","onKeydown"]))])),_:1})),x.error?(r(),t(T,{key:3,class:"phone-error",role:"alert"},{default:s((()=>[u(p(x.error),1)])),_:1})):g("",!0),x.done||S.cooldown?g("",!0):(r(),t(T,{key:4,class:"phone-help"},{default:s((()=>[l(T,{class:"phone-link",role:"link",tabindex:"0",onClick:n[5]||(n[5]=e=>x.showFeedback=!0),onKeydown:[n[6]||(n[6]=f(w((e=>x.showFeedback=!0),["prevent"]),["enter"])),n[7]||(n[7]=f(w((e=>x.showFeedback=!0),["prevent"]),["space"]))]},{default:s((()=>[u(p(e.$t("user.phoneChange.cannotReceive")),1)])),_:1})])),_:1}))])),_:1}),l(R,{show:x.showFeedback,title:e.$t("common.feedback.title"),theme:"dark",class:"phone-feedback","confirm-button-text":e.$t("common.feedback.close"),"close-on-click-overlay":"",onConfirm:n[8]||(n[8]=e=>x.showFeedback=!1),onClose:n[9]||(n[9]=e=>x.showFeedback=!1)},{default:s((()=>[l(T,{class:"phone-feedback-content"},{default:s((()=>[l(T,{class:"phone-feedback-text"},{default:s((()=>[u(p(e.$t("common.feedback.hint")),1)])),_:1}),l(U,{class:"phone-feedback-qrcode",mode:"aspectFit",src:"https://cloudstorage.d2core.com/app/qrcode-light-new.jpg?imageView2/format/webp/q/80"})])),_:1})])),_:1},8,["show","title","confirm-button-text"])])),_:1})])),_:1})}],["__scopeId","data-v-e5d8d438"]]);export{K as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.