Commit 27460c84 by 梁建民

忘记密码

parent 20b4559f
{
"pages": [
"pages/person/auth/index",
"pages/person/forget/index",
"pages/person/register/index",
"pages/person/verifycode/index",
"pages/person/login/index",
......
{
"usingComponents": {},
"navigationBarTitleText": "IC业务助手用户协议",
"navigationBarBackgroundColor": "white",
"navigationBarTextStyle": "black",
"backgroundColor": "white"
"navigationBarTitleText": "IC业务助手用户协议"
}
\ No newline at end of file
......@@ -37,7 +37,7 @@ Page({
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
......
{
"usingComponents": {
},
"navigationBarTitleText": "",
"navigationBarBackgroundColor": "white",
"navigationBarTextStyle": "black",
"backgroundColor": "white"
"usingComponents": {},
"navigationBarTitleText": ""
}
\ No newline at end of file
const http = require('../../../utils/util.js');
import {
apis
} from '../../../utils/api.js';
Page({
/**
* 页面的初始数据
*/
data: {
type: 1,
btnText: '下一步',
error: false,
errorText: '',
visiblePwd: false,
passwordType: true,
mobileFlag: false,
passwordFlag: false,
codeFlag: false,
disabled: false,
disabledBtn: false,
loading: false,
currentTime: 61,
vcode: false,
vcodeFlag: false,
timeText: '发送验证码',
captchaUrl: '',
captchaUuid: '',
captcha: '',
formData: {
mobile: '',
password: '',
code: ''
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
},
/**
* 获取验证码
*/
getCode: function() {
let self = this;
let currentTime = this.data.currentTime;
let interval = setInterval(function() {
currentTime--;
self.setData({
timeText: currentTime + 's'
});
if (currentTime <= 0) {
clearInterval(interval);
self.setData({
timeText: '重新发送',
currentTime: 61,
disabled: false
});
}
}, 1000)
},
/**
* 发送验证码
*/
getVerificationCode: function(e) {
//验证必填手机号
if (this.data.formData.mobile) {
//验证是否发送了验证码
if (this.data.captchaUuid) {
//是否填写了验证码
if (this.data.captcha) {
http.getData(apis.getRegistCode, 'GET', {
captchaUuid: this.data.captchaUuid,
captcha: this.data.captcha,
mobile: this.data.formData.mobile,
code_type: 3
}, (res) => {
if (res.err_code === 0) {
this.getCode();
this.setData({
disabled: true
});
} else if (res.err_code === 500) {
//图形验证码不正确的时候
this.refreshVerification();
wx.showToast({
title: res.err_msg,
icon: 'none',
duration: 2000
});
} else {
wx.showToast({
title: res.err_msg,
icon: 'none',
duration: 2000
});
}
}, true);
} else {
this.setData({
error: true,
errorText: '图形验证码不能为空',
vcodeFlag: true
});
}
} else {
this.refreshVerification();
}
} else {
this.setData({
error: true,
errorText: '手机号不能为空',
mobileFlag: true
});
}
},
/**
* 刷新图形验证码
*/
refreshVerification: function() {
this.setData({
vcode: true
});
http.getData(apis.captchaInfo, 'GET', null, (res) => {
this.setData({
captchaUrl: res.captchaUrl,
captchaUuid: res.captchaUuid
});
});
},
/**
* 校验字段
*/
bindinputFn: function(e) {
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_pwd = /^[0-9A-Za-z]{6,}$/;
if (e.currentTarget.dataset.type == 1) {
if (value) {
this.setData({
error: true,
errorText: '请填写正确的手机号',
mobileFlag: true
});
if (reg_mobile.test(value)) {
this.setData({
'formData.mobile': value,
error: false,
errorText: '',
mobileFlag: false
});
}
}
} else if (e.currentTarget.dataset.type == 2) {
if (value) {
this.setData({
'formData.code': value,
error: false,
errorText: '',
codeFlag: false
});
}
} else if (e.currentTarget.dataset.type == 3) {
if (value) {
this.setData({
captcha: value
});
this.setData({
error: false,
errorText: '',
vcodeFlag: false
});
}
} else if (e.currentTarget.dataset.type == 4) {
if (value) {
this.setData({
error: true,
errorText: '密码由字母和数字组成,且不能少于6位',
passwordFlag: true
});
if (reg_pwd.test(value)) {
this.setData({
'formData.password': value,
error: false,
errorText: '',
passwordFlag: false
});
}
}
}
},
/**
* 校验字段
*/
calcForm: function(val, type) {
let mobile = val.mobile;
let code = val.code;
let password = val.password;
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,}$/;
if (!mobile && type == 1) {
this.setData({
error: true,
errorText: '手机号不能为空',
mobileFlag: true
});
return false;
}
if (!reg_mobile.test(mobile) && type == 1) {
this.setData({
error: true,
errorText: '请填写正确的手机号',
mobileFlag: true
});
return false;
}
if (!code && type == 1) {
this.setData({
error: true,
errorText: '验证码不能为空',
codeFlag: true
});
return false;
}
if (!password && type == 2) {
this.setData({
error: true,
errorText: '密码不能为空',
mobileFlag: false,
passwordFlag: true
});
return false;
}
if (!reg_pwd.test(password) && type == 2) {
this.setData({
error: true,
errorText: '密码由字母和数字组成,且不能少于6位',
mobileFlag: false,
passwordFlag: true
});
return false;
}
this.setData({
error: false,
errorText: '',
codeFlag: false,
mobileFlag: false
});
return true;
},
/**
*忘记密码
*/
formSubmit: function(e) {
if (this.data.type == 1) {
//第一步
if (this.calcForm(e.detail.value, 1)) {
this.setData({
type: 2,
btnText: '设置密码'
});
}
} else if (this.data.type == 2) {
//第二步
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.err_code === 0) {
this.setData({
type: 3
});
} else {
wx.showToast({
title: res.err_msg,
icon: 'none',
duration: 2000
});
this.refreshVerification();
this.setData({
type: 1,
btnText: '下一步'
});
}
});
}
}
},
/**
* 密码是否可见
*/
toggleFn: function(e) {
if (this.data['visiblePwd']) {
this.setData({
visiblePwd: false,
passwordType: true
});
} else {
this.setData({
visiblePwd: true,
passwordType: false
});
}
}
})
{
"usingComponents": {},
"navigationBarTitleText": "忘记密码"
}
\ No newline at end of file
.person {
margin: 0 55rpx;
padding-top: 32rpx;
.tit {
margin-bottom: 50rpx;
.t1 {
font-size: 48rpx;
color: #2e3033;
font-weight: 600;
line-height: 67rpx;
}
.t2 {
font-size: 26rpx;
font-weight: 400;
line-height: 40px;
color: #8a9299;
}
}
.inp-wrap {
height: 98rpx;
border-bottom: 1px solid #d8dfe6;
padding-left: 10rpx;
input {
padding-left: 35rpx;
width: 340rpx;
}
.icon {
color: #adb6bf;
}
.pwd-ico {
padding-left: 160rpx;
}
.vcode {
font-size: 32rpx;
color: #61a0f2;
background: none;
font-weight: 400;
border: 0 !important;
&::after {
border: 0 !important;
}
}
.areacode {
border-left: 1px solid #d8dfe6;
.tel-value {
font-size: 32rpx;
color: #515559;
padding: 7rpx 11rpx 7rpx 16rpx;
}
.icon {
color: #d8dfe6;
font-size: 26rpx;
}
}
}
.register-button {
height: 98rpx;
line-height: 98rpx;
background: rgba(13, 132, 209, 1) !important;
box-shadow: 0px 6rpx 10rpx 0rpx rgba(97, 160, 242, 0.3) !important;
border-radius: 8rpx;
color: #fff !important;
font-size: 32rpx;
margin-top: 40rpx;
text-align: center;
}
.error-wrap {
margin-top: 24rpx;
.error {
.iconfont {
color: #ea1717;
}
.txt {
font-size: 24rpx;
color: #ea1717;
margin-left: 15rpx;
}
}
.forget {
font-size: 28rpx;
color: #61a0f2;
}
}
.placeholderClass {
color: #adb6bf;
font-size: 32rpx;
}
.inp-error {
border-bottom: 1px solid #ea1717;
.icon {
color: #ea1717;
}
input {
color: #ea1717;
}
}
}
.success {
width: 100%;
padding-top: 50rpx;
.img {
width: 480rpx;
height: 346rpx;
}
.t1 {
padding-top: 40rpx;
margin-bottom: 14rpx;
font-size: 48rpx;
color: #2e3033;
line-height: 67rpx;
font-weight: 600;
display: block;
}
.t2 {
font-size: 26rpx;
font-weight: 400;
color: #8a9299;
margin-bottom: 66rpx;
}
}
<!-- 注册 -->
<view class="person">
<view class="column tit" wx:if="{{type === 1 || type === 2}}">
<text class="t1">验证手机号</text>
<text class="t2">知道吗! 还可以用验证登录呢</text>
</view>
<form bindsubmit="formSubmit">
<block wx:if="{{type === 1}}">
<view class="inp-wrap row verCenter {{mobileFlag ? 'inp-error':''}}">
<text class="icon iconfont iconiconxiantiaoshouji21"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入手机号" placeholder-class="placeholderClass" name="mobile" type="number" data-type="1"
bindinput='bindinputFn'></input>
<view class="areacode" bindtap="switchPrice">
<text class="tel-value">中国 + 86</text>
<text class="icon iconfont iconbianzu1"></text>
</view>
</view>
</view>
<view class="inp-wrap row verCenter {{vcodeFlag ? 'inp-error':''}}" wx:if="{{vcode}}">
<text class="icon iconfont iconiconxiantiaoshouji"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入图形验证码" placeholder-class="placeholderClass" name='captcha' data-type="3" bindinput='bindinputFn'></input>
<view class='code-img'>
<cover-image src="{{captchaUrl}}" class="img" bindtap='refreshVerification'></cover-image>
</view>
</view>
</view>
<view class="inp-wrap row verCenter {{codeFlag ? 'inp-error':''}}">
<text class="icon iconfont iconiconxiantiaoshouji"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入验证码" placeholder-class="placeholderClass" name='code' data-type="2" bindinput='bindinputFn'></input>
<button class="vcode {{disabled ? 'vcode-color':''}}" disabled="{{disabled}}" bindtap="getVerificationCode">{{timeText}}</button>
</view>
</view>
</block>
<block wx:elif="{{type === 2}}">
<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 wx:elif="{{type === 3}}">
<view class="success column rowCenter verCenter">
<cover-image src="/res/images/imgs/scu.png" class="img"></cover-image>
<text class="t1">恭喜您,密码找回成功</text>
<text class="t2">请保管好您的账户信息。</text>
</view>
<navigator url="/pages/tab/home/home" class="register-button" open-type="switchTab">返回首页</navigator>
</block>
<view class="error-wrap row bothSide verCenter" wx:if="{{type === 1 || type === 2}}">
<view class="error">
<block wx:if="{{error}}">
<text class="icon iconfont iconiconxiantiaoshouji1"></text>
<text class="txt">{{errorText}}</text>
</block>
</view>
</view>
<button wx:if="{{type === 1 || type === 2}}" class="register-button" form-type="submit" disabled="{{disabledBtn}}" loading="{{loading}}">{{btnText}}</button>
</form>
</view>
.person {
margin: 0 55rpx;
padding-top: 32rpx;
}
.person .tit {
margin-bottom: 50rpx;
}
.person .tit .t1 {
font-size: 48rpx;
color: #2e3033;
font-weight: 600;
line-height: 67rpx;
}
.person .tit .t2 {
font-size: 26rpx;
font-weight: 400;
line-height: 40px;
color: #8a9299;
}
.person .inp-wrap {
height: 98rpx;
border-bottom: 1px solid #d8dfe6;
padding-left: 10rpx;
}
.person .inp-wrap input {
padding-left: 35rpx;
width: 340rpx;
}
.person .inp-wrap .icon {
color: #adb6bf;
}
.person .inp-wrap .pwd-ico {
padding-left: 160rpx;
}
.person .inp-wrap .vcode {
font-size: 32rpx;
color: #61a0f2;
background: none;
font-weight: 400;
border: 0 !important;
}
.person .inp-wrap .vcode::after {
border: 0 !important;
}
.person .inp-wrap .areacode {
border-left: 1px solid #d8dfe6;
}
.person .inp-wrap .areacode .tel-value {
font-size: 32rpx;
color: #515559;
padding: 7rpx 11rpx 7rpx 16rpx;
}
.person .inp-wrap .areacode .icon {
color: #d8dfe6;
font-size: 26rpx;
}
.person .register-button {
height: 98rpx;
line-height: 98rpx;
background: #0d84d1 !important;
box-shadow: 0px 6rpx 10rpx 0rpx rgba(97, 160, 242, 0.3) !important;
border-radius: 8rpx;
color: #fff !important;
font-size: 32rpx;
margin-top: 40rpx;
text-align: center;
}
.person .error-wrap {
margin-top: 24rpx;
}
.person .error-wrap .error .iconfont {
color: #ea1717;
}
.person .error-wrap .error .txt {
font-size: 24rpx;
color: #ea1717;
margin-left: 15rpx;
}
.person .error-wrap .forget {
font-size: 28rpx;
color: #61a0f2;
}
.person .placeholderClass {
color: #adb6bf;
font-size: 32rpx;
}
.person .inp-error {
border-bottom: 1px solid #ea1717;
}
.person .inp-error .icon {
color: #ea1717;
}
.person .inp-error input {
color: #ea1717;
}
.success {
width: 100%;
padding-top: 50rpx;
}
.success .img {
width: 480rpx;
height: 346rpx;
}
.success .t1 {
padding-top: 40rpx;
margin-bottom: 14rpx;
font-size: 48rpx;
color: #2e3033;
line-height: 67rpx;
font-weight: 600;
display: block;
}
.success .t2 {
font-size: 26rpx;
font-weight: 400;
color: #8a9299;
margin-bottom: 66rpx;
}
{
"usingComponents": {},
"navigationBarTitleText": "",
"navigationBarBackgroundColor": "white",
"navigationBarTextStyle": "black",
"backgroundColor": "white"
"navigationBarTitleText": ""
}
\ No newline at end of file
......@@ -162,7 +162,7 @@ Page({
});
if (reg_mobile.test(value)) {
wx.hideKeyboard();
this.setData({
error: false,
errorText: '',
......
{
"usingComponents": {},
"navigationBarTitleText": "",
"navigationBarBackgroundColor": "white",
"navigationBarTextStyle": "black",
"backgroundColor": "white"
"navigationBarTitleText": ""
}
\ No newline at end of file
......@@ -41,7 +41,7 @@
</block>
</view>
<navigator class="forget" url="pages/person/verifycode/index">忘记密码?</navigator>
<navigator class="forget" url="/pages/person/forget/index">忘记密码?</navigator>
</view>
......@@ -50,7 +50,7 @@
<view class="bottom row bothSide">
<navigator class="txt" url="/pages/person/verifycode/index">验证码登录</navigator>
<navigator class="txt" url="/pages/person/verifycode/index">注册账户</navigator>
<navigator class="txt" url="/pages/person/register/index">注册账户</navigator>
</view>
</view>
\ No newline at end of file
......@@ -216,6 +216,7 @@ Page({
});
if (reg_mobile.test(value)) {
wx.hideKeyboard();
this.setData({
error: false,
errorText: '',
......
{
"usingComponents": {},
"navigationBarTitleText": "免费注册",
"navigationBarBackgroundColor": "white",
"navigationBarTextStyle": "black",
"backgroundColor": "white"
"navigationBarTitleText": "免费注册"
}
\ No newline at end of file
......@@ -45,7 +45,7 @@
<view class="inp-wrap row verCenter {{codeFlag ? 'inp-error':''}}">
<text class="icon iconfont iconiconxiantiaoshouji"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入手机验证码" placeholder-class="placeholderClass" name='code' data-type="2" bindinput='bindinputFn'></input>
<input placeholder="请输入验证码" placeholder-class="placeholderClass" name='code' data-type="2" bindinput='bindinputFn'></input>
<button class="vcode {{disabled ? 'vcode-color':''}}" disabled="{{disabled}}" bindtap="getVerificationCode">{{timeText}}</button>
</view>
</view>
......
{
"usingComponents": {},
"navigationBarTitleText": "注册成功",
"navigationBarBackgroundColor": "white",
"navigationBarTextStyle": "black",
"backgroundColor": "white"
"navigationBarTitleText": "注册成功"
}
\ No newline at end of file
......@@ -197,21 +197,19 @@ Page({
let reg_mobile = /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/;
if (e.currentTarget.dataset.type == 1) {
this.setData({
'formData.mobile': value
});
if (value) {
this.setData({
error: true,
errorText: '请填写正确的手机号',
mobileFlag: true
});
if (reg_mobile.test(value)) {
wx.hideKeyboard();
this.setData({
'formData.mobile': value,
error: false,
errorText: '',
mobileFlag: false
......
{
"usingComponents": {},
"navigationBarTitleText": "",
"navigationBarBackgroundColor": "white",
"navigationBarTextStyle": "black",
"backgroundColor": "white"
"navigationBarTitleText": ""
}
\ No newline at end of file
......@@ -30,7 +30,7 @@
<view class="inp-wrap row verCenter {{codeFlag ? 'inp-error':''}}">
<text class="icon iconfont iconiconxiantiaoshouji"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入手机验证码" placeholder-class="placeholderClass" name='code' data-type="2" bindinput='bindinputFn'></input>
<input placeholder="请输入验证码" placeholder-class="placeholderClass" name='code' data-type="2" bindinput='bindinputFn'></input>
<button class="vcode {{disabled ? 'vcode-color':''}}" disabled="{{disabled}}" bindtap="getVerificationCode">{{timeText}}</button>
</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