forget.vue
11.2 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<template>
<view class="page-forget">
<navElement title="重置密码"></navElement>
<view class="tip row">
<text class="iconfont icon-ts"></text>
<text class="tt">猎芯网移动端目前仅支持手机号找回方式,如果您要通过邮箱账号找回密码,请使用电脑打开猎芯网www.ichunt.com</text>
</view>
<view class="step row verCenter">
<view class="box column verCenter" :class="{ curr: index == curr }" v-for="(item, index) in textArr" :key="index">
<text class="line"></text>
<text class="tt">{{ item }}</text>
</view>
</view>
<!-- 身份验证 -->
<template v-if="curr == 0">
<view class="input-box mobile row verCenter" style="margin-bottom: 24rpx;">
<view class="picker-box">
<picker @change="bindPickerChange" :value="index" :range="array">
<view class="row verCenter bothSide">
<view class="uni-input">{{ array[index] }}</view>
<view class="iconfont icon-arrbot"></view>
</view>
</picker>
</view>
<input type="number" placeholder="请输入手机号码" placeholder-style="color:#919399;" class="uni-input" v-model="formParams.account" />
</view>
<view class="input-box verification-code row bothSide verCenter" style="margin-bottom: 24rpx;" v-if="verify_flag">
<input type="text" placeholder="请输入图中字符,不区分大小写" placeholder-style="color:#919399;" class="uni-input" v-model="formParams.verify" />
<image :src="url" class="pic" @click="refresh()"></image>
</view>
<view class="input-box code row bothSide verCenter" style="margin-bottom: 40rpx;">
<input type="number" placeholder="请输入验证码" placeholder-style="color:#919399;" class="uni-input" v-model="formParams.sms_verify" />
<text class="code-text" @click="countdownChange()" :class="{ disabled: code_disabled }">{{ code_text }}</text>
</view>
<view class="btn row rowCenter verCenter" @click="submit(1)" :class="{ disabled: formParams.account == '' || formParams.sms_verify == '' }">提交</view>
</template>
<!-- 重置密码 -->
<template v-else-if="curr == 1">
<view class="input-box pwd row bothSide verCenter" style="margin-bottom: 40px;">
<template v-if="pwd_flag">
<input type="password" placeholder="请输入6-20位数字、字母或符号组合密码" placeholder-style="color:#919399;" class="uni-input" v-model="formParams.password" />
<text class="iconfont icon-a-juxingbeifen14" @click="pwd_flag = false"></text>
</template>
<template v-else>
<input type="text" placeholder="请输入6-20位数字、字母或符号组合密码" placeholder-style="color:#919399;" class="uni-input" v-model="formParams.password" />
<text class="iconfont icon-juxing" @click="pwd_flag = true"></text>
</template>
</view>
<view class="btn row rowCenter verCenter" @click="submit(2)">提交</view>
</template>
<!-- 完成 -->
<template v-else-if="curr == 2">
<view class="success column rowCenter verCenter">
<image src="../../static/success.png" class="p1"></image>
<text class="success-t1">密码重置成功</text>
<navigator class="success-btn row rowCenter verCenter" url="/login" hover-class="none">去登录</navigator>
</view>
</template>
</view>
</template>
<script>
import { Ichunt_Api, Api_Url, Code_Url } from '@/util/api.js';
import navElement from '@/components/nav.vue';
import { setCookie, delCookie, getCookie, startCountdown } from '@/util/util.js';
export default {
components: {
navElement
},
data() {
return {
code_text: '获取验证码',
code_disabled: false,
index: 0,
array: ['0086', '00886', '00853', '00852'],
textArr: ['身份验证', '重置密码', '完成'],
verify_flag: false, //是否显示图形验证码
pwd_flag: true,
curr: 0,
url: Code_Url + '?pf=2', //图形验证码地址
formParams: {
password: '',
sms_verify: '',
account: '',
verify: '',
intl_code: '0086'
}
};
},
onLoad(options) {
this.formParams.account = options.account;
},
methods: {
bindPickerChange: function(e) {
console.log('picker发送选择改变,携带值为', e.detail.value);
this.index = e.detail.value;
this.formParams.intl_code = this.array[e.detail.value];
},
/**
* 刷新验证码
*/
refresh() {
var Yo4teW_gid = getCookie('Yo4teW_gid');
var Yo4teW_csrf = getCookie('Yo4teW_csrf');
var Yo4teW_uid = getCookie('Yo4teW_uid');
this.url = Code_Url + '?time=' + new Date().getTime() + '&pf=2&Yo4teW_gid=' + Yo4teW_gid + '&Yo4teW_csrf=' + Yo4teW_csrf + '&Yo4teW_uid=' + Yo4teW_uid + '&id=2';
},
/**
* 手机验证码
*/
countdownChange() {
var reg = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/;
if (!this.formParams.account) {
uni.showToast({
title: '请输入手机号',
icon: 'none'
});
return false;
}
if (!reg.test(this.formParams.account)) {
uni.showToast({
title: '手机格式错误',
icon: 'none'
});
return false;
}
this.request(Api_Url + '/public/findsmsverify', 'POST', { mobile: this.formParams.account, verify: this.formParams.verify, intl_code: this.formParams.intl_code, type: 2 }, true, true).then(res => {
if (res.err_code === 0) {
if (!this.code_disabled) {
const countdown = startCountdown({
duration: 60,
onTick: remainingTime => {
this.code_disabled = true;
this.code_text = `重新发送${remainingTime}S`;
},
onComplete: () => {
this.code_disabled = false;
this.code_text = `获取验证码`;
}
});
countdown.start();
}
} else if (res.err_code === 10001 || res.err_code === 10002) {
uni.showModal({
itle: '提示',
content: res.err_msg,
showCancel: false,
success: res => {
if (res.confirm) {
this.verify_flag = true;
this.refresh(); //刷新验证码
} else if (res.cancel) {
}
}
});
} else {
this.verify_flag = false;
uni.showModal({
itle: '提示',
content: res.err_msg,
showCancel: false
});
}
});
},
submit(type) {
if (type == 1) {
var reg = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/;
if (!this.formParams.account) {
uni.showToast({
title: '请输入手机号',
icon: 'none'
});
return false;
}
if (!reg.test(this.formParams.account)) {
uni.showToast({
title: '手机格式错误',
icon: 'none'
});
return false;
}
if (!this.formParams.sms_verify) {
uni.showToast({
title: '请输入验证码',
icon: 'none'
});
return false;
}
this.request(Api_Url + '/reg/forgetPassword', 'POST', { account: this.formParams.account, verify: this.formParams.verify, sms_verify: this.formParams.sms_verify, intl_code: this.formParams.intl_code }, true, true).then(res => {
if (res.err_code === 0) {
this.curr = type;
} else if (res.err_code === 10001 || res.err_code === 10002) {
uni.showModal({
itle: '提示',
content: res.err_msg,
showCancel: false,
success: res => {
if (res.confirm) {
this.verify_flag = true;
this.refresh(); //刷新验证码
}
}
});
} else {
this.verify_flag = false;
uni.showModal({
itle: '提示',
content: res.err_msg,
showCancel: false
});
}
});
} else if (type == 2) {
this.request(Api_Url + '/reg/changePasswordFromMsg', 'POST', { account: this.formParams.account, password: this.formParams.password, intl_code: this.formParams.intl_code }, true, true).then(res => {
if (res.err_code === 0) {
this.curr = type;
} else if (res.err_code === 10001 || res.err_code === 10002) {
uni.showModal({
itle: '提示',
content: res.err_msg,
showCancel: false,
success: res => {
if (res.confirm) {
this.verify_flag = true;
this.refresh(); //刷新验证码
}
}
});
} else {
this.verify_flag = false;
uni.showModal({
itle: '提示',
content: res.err_msg,
showCancel: false
});
}
});
}
}
}
};
</script>
<style lang="scss">
@import '@/assets/css/mine/forget.scss';
</style>