PageSourceSearch

https://www.d2core.com/assets/user-change-phone.Di_EpuU8.js

js d2core.com collected 2026-10-04 00:42:22 UTC 17,474 bytes, 1 lines download raw bytes

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.