From 5f37f9cba5b6cd202f8c53e4a5c001abb0bb6202 Mon Sep 17 00:00:00 2001 From: wenc000 <450292408@qq.com> Date: Thu, 16 Jul 2020 19:42:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E7=99=BB=E5=BD=95=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 处理手机绑定用户问题 --- pages/index/index.js | 69 +++++++++++++++++++++--------------------- pages/index/index.wxml | 6 ++-- 2 files changed, 37 insertions(+), 38 deletions(-) diff --git a/pages/index/index.js b/pages/index/index.js index 2184626..43c4729 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -7,7 +7,7 @@ Page({ randomName: '', showPhone: true, gotCode: false, - restTime: 10, + restTime: 120, timer: '', indicatorDots: true, autoplay: true, @@ -29,7 +29,8 @@ Page({ liveUrl: app.liveUrl, liveList: [] }, - usercenterUrl: app.usercenterUrl + usercenterUrl: app.usercenterUrl, + isConfirm: false }, doLogin: function () { var self = this; @@ -189,7 +190,6 @@ Page({ this.setData({ phone: res.detail.value }) - console.log(this.data.phone) }, // 校验手机号 testPhone: function () { @@ -214,43 +214,40 @@ Page({ }, // 获取验证码 getCode: function () { - var self = this + var self = this; + self.setData({ + gotCode: true + }) + self.data.timer = setInterval(function () { + var cur = self.data.restTime - 1 + if (cur == 0) { + clearInterval(self.data.timer) + self.setData({ + restTime: 120, + gotCode: false + }) + } else { + self.setData({ + restTime: cur + }) + } + }, 1000) app.restAjax.get(app.restAjax.path('{usercenterUrl}/api/sms/getverificationcode/' + self.data.phone, [app.usercenterUrl]), {}, null, + function (code, data) {}, function (code, data) { - if (code == 200) { - console.log(data) - self.setData({ - gotCode: true - }) - self.data.timer = setInterval(function () { - var cur = self.data.restTime - 1 - console.log(cur) - if (cur == 0) { - clearInterval(self.data.timer) - self.setData({ - restTime: 120, - gotCode: false - }) - } else { - self.setData({ - restTime: cur - }) - } - }, 1000) - } - }, - function (code, data) { - console.log(data) wx.showToast({ title: data.msg, icon: 'none', duration: 1500 }) - } ) + }) }, // 提交绑定手机 submitPhone: function () { - var self = this + var self = this; + self.setData({ + isConfirm: true + }) app.restAjax.put(app.restAjax.path('{usercenterUrl}/app/user/updateminiappdefaultusername', [app.usercenterUrl]), { phone: self.data.phone, verificationCode: self.data.code @@ -259,17 +256,19 @@ Page({ token: self.data.token } }, function (code, data) { - console.log(data) wx.setStorageSync('token', data.data); wx.setStorageSync('isRandomUsername', 0) clearInterval(self.data.timer) self.setData({ - showPhone: false, - restTime: 120 + showPhone: false }) + wx.showTabBar(); self.getUserInfo() }, function (code, data) { - console.log(data) + app.dialog.msg(data.msg); + self.setData({ + isConfirm: false + }) }) }, // 验证码 @@ -305,7 +304,7 @@ Page({ userInfo: data }) }, function (code, data) { - console.log(data) + app.dialog.msg(data.msg); }) }, /** diff --git a/pages/index/index.wxml b/pages/index/index.wxml index d2bed56..f88358a 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -138,15 +138,15 @@ 您还没有绑定手机号,请先绑定手机号 - + - + 获取验证码 {{restTime}} - 确认 + 确认 \ No newline at end of file