Commit 8c285293 by 梁建民

忘记密码

parent 12bcb135
...@@ -39,60 +39,60 @@ Page({ ...@@ -39,60 +39,60 @@ Page({
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function(options) { onLoad: function (options) {
}, },
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
onReady: function() { onReady: function () {
}, },
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function() { onShow: function () {
}, },
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide: function() { onHide: function () {
}, },
/** /**
* 生命周期函数--监听页面卸载 * 生命周期函数--监听页面卸载
*/ */
onUnload: function() { onUnload: function () {
}, },
/** /**
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
onPullDownRefresh: function() { onPullDownRefresh: function () {
}, },
/** /**
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom: function() { onReachBottom: function () {
}, },
/** /**
* 获取验证码 * 获取验证码
*/ */
getCode: function() { getCode: function () {
let self = this; let self = this;
let currentTime = this.data.currentTime; let currentTime = this.data.currentTime;
let interval = setInterval(function() { let interval = setInterval(function () {
currentTime--; currentTime--;
...@@ -116,7 +116,7 @@ Page({ ...@@ -116,7 +116,7 @@ Page({
/** /**
* 发送验证码 * 发送验证码
*/ */
getVerificationCode: function(e) { getVerificationCode: function (e) {
//验证必填手机号 //验证必填手机号
if (this.data.formData.mobile) { if (this.data.formData.mobile) {
...@@ -176,7 +176,7 @@ Page({ ...@@ -176,7 +176,7 @@ Page({
/** /**
* 刷新图形验证码 * 刷新图形验证码
*/ */
refreshVerification: function() { refreshVerification: function () {
this.setData({ this.setData({
vcode: true vcode: true
...@@ -192,7 +192,7 @@ Page({ ...@@ -192,7 +192,7 @@ Page({
/** /**
* 校验字段 * 校验字段
*/ */
bindinputFn: function(e) { bindinputFn: function (e) {
let value = e.detail.value let value = e.detail.value
let reg_mobile = /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/; let reg_mobile = /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/;
let reg_pwd = /^[0-9A-Za-z]{6,}$/; let reg_pwd = /^[0-9A-Za-z]{6,}$/;
...@@ -269,7 +269,7 @@ Page({ ...@@ -269,7 +269,7 @@ Page({
/** /**
* 校验字段 * 校验字段
*/ */
calcForm: function(val, type) { calcForm: function (val, type) {
let mobile = val.mobile; let mobile = val.mobile;
let code = val.code; let code = val.code;
let password = val.password; let password = val.password;
...@@ -341,49 +341,50 @@ Page({ ...@@ -341,49 +341,50 @@ Page({
/** /**
*忘记密码 *忘记密码
*/ */
formSubmit: function(e) { formSubmit: function (e) {
if (this.data.type == 1) { if (this.data.type == 1) {
//第一步 //第一步
if (this.calcForm(e.detail.value, 1)) { if (this.calcForm(e.detail.value, 1)) {
//第二步
if (this.calcForm(e.detail.value, 2)) {
let params = {
mobile: this.data.formData.mobile,
code: this.data.formData.code,
password: this.data.formData.password
}
http.getData(apis.resetPassword, 'POST', params, (res) => {
if (res.errcode === 0) {
debugger
this.setData({
type: 3
});
//注入token
wx.setStorage({
key: "access_token",
data: res.data.access_token
});
this.setData({ //注入用户id
type: 2, wx.setStorage({
btnText: '设置密码' key: "user_id",
}); data: res.data.user_id
});
}
} else if (this.data.type == 2) {
//第二步 //登录环信帐号
if (this.calcForm(e.detail.value, 2)) { getApp().getImUser();
let params = { } else {
mobile: this.data.formData.mobile, wx.showToast({
code: this.data.formData.code, title: res.errmsg,
password: this.data.formData.password icon: 'none',
duration: 2000
});
this.refreshVerification();
}
});
} }
http.getData(apis.resetPassword, 'POST', params, (res) => {
if (res.errcode === 0) {
this.setData({
type: 3
});
} else {
wx.showToast({
title: res.errmsg,
icon: 'none',
duration: 2000
});
this.refreshVerification();
this.setData({
type: 1,
btnText: '下一步'
});
}
});
} }
} }
...@@ -391,7 +392,7 @@ Page({ ...@@ -391,7 +392,7 @@ Page({
/** /**
* 密码是否可见 * 密码是否可见
*/ */
toggleFn: function(e) { toggleFn: function (e) {
if (this.data['visiblePwd']) { if (this.data['visiblePwd']) {
...@@ -409,4 +410,4 @@ Page({ ...@@ -409,4 +410,4 @@ Page({
} }
} }
}) })
\ No newline at end of file
...@@ -12,8 +12,7 @@ ...@@ -12,8 +12,7 @@
<view class="inp-wrap row verCenter {{mobileFlag ? 'inp-error':''}}"> <view class="inp-wrap row verCenter {{mobileFlag ? 'inp-error':''}}">
<text class="icon iconfont iconiconxiantiaoshouji21"></text> <text class="icon iconfont iconiconxiantiaoshouji21"></text>
<view class="form-item-right row verCenter bothSide"> <view class="form-item-right row verCenter bothSide">
<input placeholder="请输入手机号" placeholder-class="placeholderClass" name="mobile" type="number" data-type="1" <input placeholder="请输入手机号" placeholder-class="placeholderClass" name="mobile" type="number" data-type="1" bindinput='bindinputFn'></input>
bindinput='bindinputFn'></input>
<view class="areacode" bindtap="switchPrice"> <view class="areacode" bindtap="switchPrice">
<text class="tel-value">中国 + 86</text> <text class="tel-value">中国 + 86</text>
<text class="icon iconfont iconbianzu1"></text> <text class="icon iconfont iconbianzu1"></text>
...@@ -38,10 +37,23 @@ ...@@ -38,10 +37,23 @@
<button class="vcode {{disabled ? 'vcode-color':''}}" disabled="{{disabled}}" bindtap="getVerificationCode">{{timeText}}</button> <button class="vcode {{disabled ? 'vcode-color':''}}" disabled="{{disabled}}" bindtap="getVerificationCode">{{timeText}}</button>
</view> </view>
</view> </view>
<view class="inp-wrap row verCenter {{passwordFlag ? 'inp-error':''}}">
<text class="icon iconfont iconiconxiantiaoshouji2"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入新密码" placeholder-class="placeholderClass" class="pwd" name="password" data-type="4" password='{{passwordType}}' bindinput='bindinputFn'></input>
<block wx:if="{{visiblePwd}}">
<text class="icon iconfont iconiconxiantiaoshouji3 pwd-ico" bindtap="toggleFn"></text>
</block>
<block wx:else>
<text class="icon iconfont iconiconxiantiaoshouji4 pwd-ico" bindtap="toggleFn"></text>
</block>
</view>
</view>
</block> </block>
<block wx:elif="{{type === 2}}"> <block wx:elif="{{type === 2}}">
<view class="inp-wrap row verCenter {{passwordFlag ? 'inp-error':''}}"> <!-- <view class="inp-wrap row verCenter {{passwordFlag ? 'inp-error':''}}">
<text class="icon iconfont iconiconxiantiaoshouji2"></text> <text class="icon iconfont iconiconxiantiaoshouji2"></text>
<view class="form-item-right row verCenter bothSide"> <view class="form-item-right row verCenter bothSide">
<input placeholder="请输入新密码" placeholder-class="placeholderClass" class="pwd" name="password" data-type="4" <input placeholder="请输入新密码" placeholder-class="placeholderClass" class="pwd" name="password" data-type="4"
...@@ -53,7 +65,7 @@ ...@@ -53,7 +65,7 @@
<text class="icon iconfont iconiconxiantiaoshouji4 pwd-ico" bindtap="toggleFn"></text> <text class="icon iconfont iconiconxiantiaoshouji4 pwd-ico" bindtap="toggleFn"></text>
</block> </block>
</view> </view>
</view> </view> -->
</block> </block>
<block wx:elif="{{type === 3}}"> <block wx:elif="{{type === 3}}">
...@@ -74,7 +86,7 @@ ...@@ -74,7 +86,7 @@
</view> </view>
</view> </view>
<button wx:if="{{type === 1 || type === 2}}" class="register-button" form-type="submit" disabled="{{disabledBtn}}" loading="{{loading}}">{{btnText}}</button> <button wx:if="{{type === 1 || type === 2}}" class="register-button" form-type="submit" disabled="{{disabledBtn}}" loading="{{loading}}">设置密码</button>
</form> </form>
</view> </view>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment