findPassword.vue
3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<template>
<view class="find-password-page">
<public-module></public-module>
<view class="top u-flex" >
<view @click="showPhone" :style="{color:!nextStatus?'#0079fe':''}" class="item">1.验证手机号码</view>
<view :style="{color:!nextStatus?'':'#0079fe'}" class="item">2.设置新密码</view>
</view>
<view v-if="!nextStatus" style="margin-top: 40rpx;" class="f__login">
<view class="loginPhone">
<view class="form-row">
<input class="input" type="number" v-model="phone" placeholder="请输入手机号码"
placeholder-style="font-weight:normal"></input>
</view>
<view style="height: 25rpx;"></view>
<view class="form-row">
<input class="input" type="number" v-model="vCode" placeholder="请输入短信验证码"
placeholder-style="font-weight:normal"></input>
<view class="getvcode" :class="{forhidden:readonly}" @click="getVcode">{{ codeText }}</view>
</view>
<button class="submit" size="default" @click="onNextSubmit">
<text style="color:#fff">下一步</text>
</button>
</view>
</view>
<view v-else style="margin-top: 40rpx;" class="f__login">
<view class="loginPhone">
<view class="form-row">
<input class="input" type="password" v-model="password" placeholder="请设置6-20位新的登录密码"
placeholder-style="font-weight:normal"></input>
</view>
<view style="height: 25rpx;"></view>
<view class="form-row">
<input class="input" type="password" v-model="rePassword" placeholder="请再次输入新的登录密码"
placeholder-style="font-weight:normal"></input>
</view>
<button class="submit" size="default" @click="onSubmit">
<text style="color:#fff">确定</text>
</button>
</view>
</view>
</view>
</template>
<script>
var clear;
export default {
data() {
return {
readonly: false,
codeText: '发送验证码',
phone: '', //号码
vCode: '', //验证码
nextStatus: false,
password:'',
rePassword:''
}
},
methods: {
//验证码按钮文字状态
getCodeState() {
const _this = this;
this.readonly = true;
this.codeText = '60S后重新获取';
var s = 60;
clear = setInterval(() => {
s--;
_this.codeText = s + 'S后重新获取';
if (s <= 0) {
clearInterval(clear);
_this.codeText = '发送验证码';
_this.readonly = false;
}
}, 1000);
},
//获取验证码
getVcode() {
if (this.readonly) {
uni.showToast({
title: '验证码已发送~',
icon: 'none'
});
return;
}
if (this.phone == '') {
uni.showToast({
title: '请输入手机号~',
icon: 'none'
});
return;
}
const phoneRegular = /^1\d{10}$/;
if (!phoneRegular.test(this.phone)) {
uni.showToast({
title: '手机号格式不正确~',
icon: 'none'
});
return;
}
let httpData = {}
// 获取验证码接口
uni.$u.http.post(`/yt/noauth/sendLoginSmsCode/${this.phone}` ).then(res => {
this.getCodeState(); //开始倒计时
})
},
onNextSubmit() {
this.nextStatus = true
},
showPhone(){
this.nextStatus = false
},
onSubmit() {
if(this.password!==this.rePassword) return uni.$u.toast('两次输入密码不一致');
let httpData={
password: this.password,
phoneNumber: this.phone,
userId: this.vCode
}
uni.$u.http.post(`/yt/noauth/reset/${this.phone}`, httpData).then(res => {
uni.showToast({
title: '重置密码成功~',
icon: 'none'
});
setTimeout(() => {
uni.navigateBack({
delta:2
})
}, 500);
});
}
}
}
</script>
<style lang="scss" scoped>
@import './static/findPassword.scss';
</style>