From 6d81de316afba89a518c94a9b500c1958e690de5 Mon Sep 17 00:00:00 2001 From: kola-web Date: Sat, 16 May 2026 16:14:29 +0800 Subject: [PATCH] Improve change phone validation and prefer BigPicLink for video posters --- src/pages/changePhone/index.ts | 101 ++++++++++++++++++++++------------------ src/pages/repository/index.wxml | 2 +- 2 files changed, 56 insertions(+), 47 deletions(-) diff --git a/src/pages/changePhone/index.ts b/src/pages/changePhone/index.ts index 12047df..1481c02 100644 --- a/src/pages/changePhone/index.ts +++ b/src/pages/changePhone/index.ts @@ -1,78 +1,87 @@ -const app = getApp(); -let timer = null as null | number; +const app = getApp() +let timer = null as null | number Page({ data: { - mobile: "", - code: "", + mobile: '', + code: '', - codeText: "发送验证码", + codeText: '发送验证码', }, onLoad() {}, getCode() { - if (timer) return; - const mobile = this.data.mobile; + if (timer) return + const mobile = this.data.mobile if (!mobile) { wx.showToast({ - title: "手机号不能为空", - icon: "none", - }); - return; + title: '手机号不能为空', + icon: 'none', + }) + return } // 验证手机号 - if (!/^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/.test(mobile)) { + if (!/^1[3-9]\d{9}$/.test(mobile)) { wx.showToast({ - title: "手机号格式不正确", - icon: "none", - }); - return; + title: '手机号格式不正确', + icon: 'none', + }) + return } wx.ajax({ - method: "POST", - url: "?r=igg4/login/send-verify-code", + method: 'POST', + url: '?r=igg4/login/send-verify-code', data: { mobile, }, - }).then((res) => { - console.log(res); + }).then((_res) => { wx.showToast({ - icon: "none", - title: "验证码已发送~", - }); - let time = 60; + icon: 'none', + title: '验证码已发送~', + }) + let time = 60 timer = setInterval(() => { - time--; + time-- this.setData({ - codeText: time + "s后重新发送", - }); + codeText: `${time}s后重新发送`, + }) if (time <= 0) { - clearInterval(timer as number); - timer = null; + clearInterval(timer as number) + timer = null this.setData({ - codeText: "发送验证码", - }); + codeText: '发送验证码', + }) } - }, 1000); - }); + }, 1000) + }) }, handleSubmit() { - const { mobile, code } = this.data; - const { registrationSource, registChannel, regBusinessId } = app.globalData; + if (!this.data.mobile) { + wx.showToast({ + icon: 'none', + title: '请输入手机号', + }) + return + } + if (!this.data.code) { + wx.showToast({ + icon: 'none', + title: '请输入验证码', + }) + return + } wx.ajax({ - method: "POST", - url: "?r=igg4/account/update-telephone", + method: 'POST', + url: '?r=igg4/account/update-telephone', data: { - mobile, - code, - registrationSource, - registChannel, - regBusinessId, + mobile: this.data.mobile, + code: this.data.code, }, }).then((_res) => { - wx.navigateBack(); - }); + app.getUserInfo(this, true) + wx.navigateBack() + }) }, handleBack() { - wx.navigateBack(); + wx.navigateBack() }, -}); +}) diff --git a/src/pages/repository/index.wxml b/src/pages/repository/index.wxml index af7dae1..0b97053 100644 --- a/src/pages/repository/index.wxml +++ b/src/pages/repository/index.wxml @@ -95,7 +95,7 @@ - + {{item.Title}}