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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
<template>
<div class="page-layout">
<div class="center">
<div class="header">
<div class="reg_logo">
<img src="../../../static/images/logo.png" />
</div>
<div class="reg_title">{{title}}</div>
<a class="reg_btn" @click=" returnClick" target="_self">[返回]</a>
</div>
<div class="content">
<div class="from-block">
<div class="step-content">
<a-steps :current="current">
<a-step> <span slot="title">验证手机号</span></a-step>
<a-step> <span slot="title">设置密码</span></a-step>
<a-step> <span slot="title">成功</span></a-step>
</a-steps>
</div>
<a-form-model v-if="current == 0" ref="formData" :model="formData" :rules="rules" :label-col="{ span: 2 }" :wrapper-col="{ span: 22 }" key="1">
<a-row>
<a-col :span="24">
<a-form-model-item ref="mobile" label="手机号" prop="mobile" :label-col="{ span: 2 }" :wrapper-col="{ span: 22 }">
<a-input ref="Mobile" v-model="formData.mobile" @blur="() => {$refs.mobile.onFieldBlur(); }" style="width:200px;" />
<span style="margin-left: 5px;"></span>
<a-button @click="verification()" :disabled="Disabled">{{Content}}</a-button>
</a-form-model-item>
</a-col>
</a-row>
<a-row>
<a-col :span="24">
<a-form-model-item ref="vCode" label="验证码" prop="vCode" :label-col="{ span: 2 }" :wrapper-col="{ span: 22 }">
<a-input v-model="formData.vCode" @blur="() => {$refs.vCode.onFieldBlur(); }" style="width:150px;" />
</a-form-model-item>
</a-col>
</a-row>
<a-row>
<a-col :span="24" style="text-align: center;">
<a-button type="primary" @click="next">下一步</a-button>
</a-col>
</a-row>
</a-form-model>
<a-form-model v-if="current == 1" ref="formPwd" :model="formPwd" :rules="pwdRules" :label-col="{ span: 2 }" :wrapper-col="{ span: 22 }" key="2">
<a-row>
<a-col :span="24">
<a-form-model-item label="新密码" prop="newPassword">
<a-input type="password" placeholder="请输入新密码" v-model="formPwd.newPassword" style="width:300px;" />
</a-form-model-item>
</a-col>
</a-row>
<a-row>
<a-col :span="24">
<a-form-model-item label="确认密码" prop="checkPwd">
<a-input type="password" placeholder="请确认新密码" v-model="formPwd.checkPwd" style="width:300px;" />
</a-form-model-item>
</a-col>
</a-row>
<a-row>
<a-col :span="24" style="text-align: center;">
<a-button type="primary" @click="submit">确定</a-button>
</a-col>
</a-row>
</a-form-model>
<a-result v-if="current == 2" status="success" title="" :sub-title="subMsg">
</a-result>
<a-modal v-model="showCode" title="验证" class="sc_modal" :width="'300px'" :dialog-style="{ top: '35%' }" :maskClosable="false" :footer="null" destroyOnClose>
<div style="line-height: 60px;">
<a-row>
<a-col :span="24" style="text-align: center;">
<img :src="codeUrl" @click="getCode">
<a-input v-model="verifiCode" style="width:100px;margin-left: 10px;" />
</a-col>
</a-row>
<a-row>
<a-col :span="24" style="text-align: center;">
<a-button type="primary" @click="verifiClick()">确定</a-button>
</a-col>
</a-row>
</div>
</a-modal>
</div>
</div>
</div>
</div>
</template>
<script>
import { isEmptyParams, checkPhone } from "@/views/utils/common"
import moment from 'moment'
import paraMultiSelect from '@/views/components/common/paraMultiSelect'
import paraSelect from '@/views/components/common/paraSelect'
import baseSelect from '@/views/components/common/baseSelect'
import UnitTreeSelect from '@/views/components/common/unitTreeSelect'
export default {
name: "PersonRegister",
components: {
paraMultiSelect, paraSelect, baseSelect, UnitTreeSelect
},
data () {
return {
current: 0,
Content: '获取验证码',
Time: 60,
Disabled: false,
showCode: false,
codeUrl: null,
uuid: null,
verifiCode: null,
title: process.env.VUE_APP_SYSTEM_TITLE,
formData: {
mobile: null, vCode: null
},
formPwd: { uuid: null, newPassword: null, checkPwd: null, },
rules: {
mobile: [],
vCode: [{ required: true, message: '请输入验证码', trigger: 'blur' }],
},
pwdRules: {
newPassword: [
{ required: true, message: '请输入新密码' },
{
validator: (rule, value, callback) => {
if (value == '' || value == undefined) {
callback()
}
let ckPwd = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,10}$/;
if (ckPwd.test(value)) {
callback()
} else {
callback(new Error('密码只能由数字加字母组成,长度为6-10位~'));
}
}
},
],
checkPwd: [
{ required: true, message: '请确认新密码' },
{
validator: (rule, value, callback) => {
if (value == '' || value == undefined) {
callback()
}
if (value == this.formPwd.newPassword) {
callback()
} else {
callback(new Error('与新密码不一致!'));
}
},
},
],
},
subMsg: "重置成功请使用新密码登录!",
}
},
props: {
},
created () {
this.initData()
},
methods: {
moment,
initData () {
this.rules.mobile = [
{ required: true, message: '请输入手机号', trigger: 'blur' },
{
validator: (rule, value, callback) => {
if (value == '' || value == undefined) {
callback()
}
var ckPhone = /^1(?:3[0-9]|4[5-9]|5[0-9]|6[12456]|7[0-8]|8[0-9]|9[0-9])[0-9]{8}$/;
if (ckPhone.test(value)) {
let pars = { mobile: value, type: 'reset' }
this.$api.base.checkMobile(pars).then(({ data = {} }) => {
if (data) {
callback()
}
callback(new Error('手机号不存在'));
})
} else {
callback(new Error('请输入正确的手机号'));
}
}
},
]
},
onBirthdayChange (date, dateString) {
this.formData.birthday = dateString;
},
closeWindow () {
this.$emit('close', 'close')
},
returnClick () {
this.$router.push('/')
},
verification () {
this.verifiCode = null
this.$refs.formData.validateField('mobile', (error) => {
if (!error) {
this.showCode = true
this.getCode()
}
})
},
getCode () {
this.verifiCode = null
this.$api.base.getCode().then(({ data = {} }) => {
if (data) {
this.uuid = data.uuid
this.codeUrl = data.img
}
}).catch(() => { })
},
verifiClick () {
if (this.verifiCode) {
let par = { uuid: this.uuid, code: this.verifiCode, mobile: this.formData.mobile }
this.$api.base.sendVerificationCode(par).then(({ data = {} }) => {
if (data) {
this.uuid = null
this.verifiCode = null
this.showCode = false
this.countStart()
} else {
this.getCode()
}
}).catch(() => {
this.getCode()
})
} else
this.$message.error('请填写验证码')
},
countStart () {
this.Disabled = true
let time = setInterval(() => {
if (this.Time < 1) {
clearInterval(time)
this.Content = '获取验证码'
this.Time = 60
this.Disabled = false
} else {
this.Time--
this.Content = this.Time + 's后重新发送'
}
}, 1000)
},
next () {
this.$refs.formData.validate(valid => {
if (valid) {
let pars = isEmptyParams(this.formData)
this.$api.base.resetCheck(pars).then(({ data = {} }) => {
if (data) {
this.formPwd.uuid = data
this.current = 1
}
}).catch(() => {
this.$message.error('失败,请稍后重试!')
})
} else { return false }
})
},
submit () {
console.log(this.formPwd)
this.$refs.formPwd.validate(valid => {
if (valid) {
let pars = isEmptyParams(this.formPwd)
this.$api.base.resetPwd(pars).then(({ data = {} }) => {
if (data) {
this.current = 2
} else {
this.current = 0
this.formData.vCode = null
}
}).catch(() => {
this.$message.error('失败,请稍后重试!')
})
} else { return false }
})
},
},
}
</script>
<style lang="less" scoped>
.page-layout {
height: 100vh;
overflow: auto;
font-family: "Microsoft YaHei";
color: #333;
background-color: #ffffff;
font-size: 16px;
background-image: url(../../../static/images/htmlbg.jpg);
}
.center {
width: 900px;
height: 100vh;
margin: 0 auto;
overflow: auto;
padding: 0px 20px 0px 20px;
background-color: #ffffff;
padding: 0px 20px 0px 20px;
}
.header {
position: relative;
border-bottom: 1px solid #b1afaf;
height: 80px;
text-align: right;
box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.12), 0 0 3px 0 rgba(0, 0, 0, 0.04);
.reg_logo {
bottom: 0px;
left: 0px;
width: 40px;
height: 60px;
line-height: 60px;
position: absolute;
}
.reg_logo img {
width: 40px;
height: 40px;
}
.reg_title {
height: 60px;
line-height: 60px;
position: absolute;
bottom: 0px;
left: 45px;
width: 500px;
color: #595959;
text-align: left;
font-size: 25px;
}
a.reg_btn {
position: absolute;
top: 48px;
right: 6px;
display: inline-block;
width: 50px;
height: 34px;
line-height: 34px;
// background: url(../../../static/images/ico.a07a352b.png) no-repeat left -1005px;
color: #38bcd5;
font-size: 15px;
}
}
.content {
.ant-result-title {
margin-left: 20px !important;
}
.ant-result .ant-result-title {
margin-left: 20px !important;
}
.footer {
background: #f1f1f1;
margin-top: 20px !important;
padding: 20px 0 !important;
width: 100%;
}
.code {
width: 33%;
display: inline-block;
height: 38px;
img {
cursor: pointer;
vertical-align: middle;
}
}
}
.from-block {
margin-top: 20px;
padding: 5px;
border: 1px solid #ece7e7;
}
.step-content {
padding: 5px 30px 20px 10px;
}
</style>