处理登录问题
处理手机绑定用户问题
This commit is contained in:
parent
4d9ec42cdc
commit
5f37f9cba5
@ -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,17 +214,12 @@ Page({
|
||||
},
|
||||
// 获取验证码
|
||||
getCode: function () {
|
||||
var self = this
|
||||
app.restAjax.get(app.restAjax.path('{usercenterUrl}/api/sms/getverificationcode/' + self.data.phone, [app.usercenterUrl]), {}, null,
|
||||
function (code, data) {
|
||||
if (code == 200) {
|
||||
console.log(data)
|
||||
var self = this;
|
||||
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({
|
||||
@ -237,10 +232,9 @@ Page({
|
||||
})
|
||||
}
|
||||
}, 1000)
|
||||
}
|
||||
},
|
||||
app.restAjax.get(app.restAjax.path('{usercenterUrl}/api/sms/getverificationcode/' + self.data.phone, [app.usercenterUrl]), {}, null,
|
||||
function (code, data) {},
|
||||
function (code, data) {
|
||||
console.log(data)
|
||||
wx.showToast({
|
||||
title: data.msg,
|
||||
icon: 'none',
|
||||
@ -250,7 +244,10 @@ Page({
|
||||
},
|
||||
// 提交绑定手机
|
||||
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);
|
||||
})
|
||||
},
|
||||
/**
|
||||
|
@ -138,15 +138,15 @@
|
||||
<view class="set-phone-box">
|
||||
<view class="tips">您还没有绑定手机号,请先绑定手机号</view>
|
||||
<view class="phone-input">
|
||||
<input placeholder="请输入手机号" bindinput="phoneNum" class="phone-input"></input>
|
||||
<input placeholder="请输入手机号" bindinput="phoneNum" class="phone-input" type="number"></input>
|
||||
</view>
|
||||
<view class="code-input">
|
||||
<input placeholder="请输入验证码" bindinput="inputCode"></input>
|
||||
<input placeholder="请输入验证码" bindinput="inputCode" type="number"></input>
|
||||
<view class="get-code" bindtap="testPhone" wx:if="{{!gotCode}}">获取验证码</view>
|
||||
<view class="got-code" wx:else>{{restTime}}</view>
|
||||
</view>
|
||||
<view class="set-phone-btn-box">
|
||||
<view class="set-phone-btn" bindtap="submitPhone">确认</view>
|
||||
<view class="set-phone-btn" bindtap="submitPhone" wx:if="{{!isConfirm}}">确认</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
Loading…
Reference in New Issue
Block a user