3f535f30
杨鑫
'初始'
|
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
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
|
@click="getPassword=true"
>返回登录</el-button>
<div class="cardBox">
<el-form
ref="retrievePwd"
:model="retrievePwdForm"
:rules="retrievePwdRules"
label-position="left"
label-width="0px"
class="login-form"
>
<el-form-item prop="username">
<el-input
v-model="retrievePwdForm.username"
type="text"
maxlength="11"
auto-complete="off"
placeholder="请输入手机号码"
class="iptHeight"
>
<svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />
</el-input>
</el-form-item>
<el-form-item prop="code">
<el-input
v-model="retrievePwdForm.code"
type="text"
class="iptHeight"
auto-complete="off"
style="width: 63%"
placeholder="请输入验证码"
@keyup.enter.native="forgetPwdFn"
>
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
</el-input>
<div class="login-code">
<el-button
class="codeBtn"
type="primary"
:loading="codeloading"
@click="getCode(retrievePwdForm.username)"
>
<span v-if="!codeloading">获取验证码</span>
<span v-else>{{ count }} s</span>
</el-button>
</div>
</el-form-item>
<el-form-item prop="newPassword">
<el-input
v-model="retrievePwdForm.newPassword"
type="password"
maxlength="11"
auto-complete="off"
placeholder="新密码"
class="iptHeight"
>
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
</el-input>
</el-form-item>
<el-form-item prop="password">
<el-input
v-model="retrievePwdForm.password"
type="password"
maxlength="11"
auto-complete="off"
placeholder="确认密码"
class="iptHeight"
>
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
</el-input>
</el-form-item>
<el-form-item style="width: 100%">
<el-button
:loading="loading"
size="medium"
type="primary"
style="width: 100%; border-radius: 20px"
@click.native.prevent="forgetPwdFn"
>
<span v-if="!loading">确 认 修 改</span>
<span v-else>提 交 中...</span>
</el-button>
</el-form-item>
</el-form>
</div>
</div>
</el-card>
</div>
<!-- 底部 -->
<!-- <div class="login-footer">© 2019 antis</div> -->
</div>
</template>
<script>
// import { validUsername } from '@/utils/validate'
import { adminBuild, forgetPassword } from '@/api/user'
import {
getUserId
} from '@/utils/auth' // get token from cookie
const TIME_COUNT = 60 // 更改倒计时时间
import Background from '@/assets/images/background.jpg'
import { getCode } from '@/api/account'
const JM = require('@/utils/rsaEncrypt.js')
export default {
name: 'Login',
data() {
// const validateUsername = (rule, value, callback) => {
// if (!validUsername(value)) {
// callback(new Error('Please enter the correct user name'))
// } else {
// callback()
// }
// }
// const validatePassword = (rule, value, callback) => {
// if (value.length < 6) {
// callback(new Error('The password can not be less than 6 digits'))
// } else {
// callback()
// }
// }
return {
Background: Background,
cookiePass: '',
loginForm: {
username: '',
password: '',
rememberMe: false
},
anthorForm: {
username: '',
code: '',
rememberMe: false
},
retrievePwdForm: {
code: '',
newPassword: '',
password: '',
username: '' // 手机号
},
tabIndex: 0,
activeList: [
{
name: '账户密码登录',
id: 0
},
{
name: '手机号码登录',
id: 1
}
],
retrievePwdRules: {
username: [
{ required: true, trigger: 'blur', message: '手机号码不能为空' }
],
code: [
{ required: true, trigger: 'blur', message: '验证码不能为空' }
],
newPassword: [
{ required: true, trigger: 'blur', message: '密码不能为空' }
],
password: [
{ required: true, trigger: 'blur', message: '确认密码不能为空' }
]
},
loginRules: {
username: [
{ required: true, trigger: 'blur', message: '用户名不能为空' }
],
password: [{ required: true, trigger: 'blur', message: '密码不能为空' }]
},
anthorRules: {
username: [
{ required: true, trigger: 'blur', message: '手机号不能为空' }
],
code: [{ required: true, trigger: 'blur', message: '验证码不能为空' }]
},
loading: false,
codeloading: false,
count: '',
timer: null,
redirect: undefined,
getPassword: true
}
},
watch: {
$route: {
handler: function(route) {
this.redirect = route.query && route.query.redirect
},
immediate: true
}
},
methods: {
// 点击tab
touchTab(index) {
console.log(index)
this.tabIndex = index
},
// 获取验证码
async getCode(phone) {
console.log(phone)
if (phone === '' || phone === undefined) {
this.$message.error('请填写电话号码')
return
}
const res = await getCode({ phone })
if (res.code === '') {
this.$message({
message: '发送成功,请注意查看手机短信',
type: 'success'
})
if (!this.timer) {
this.codeloading = true
this.count = TIME_COUNT
this.timer = setInterval(() => {
if (this.count > 1 && this.count <= TIME_COUNT) {
this.count--
} else {
clearInterval(this.timer) // 清除定时器
this.timer = null
this.codeloading = false
}
}, 1000)
}
}
// if (!this.timer) {
// this.codeloading = true
// this.count = TIME_COUNT
// this.show = false
// const res = await getCode({ phone })
// if (res.code === '') {
// this.$message({
// message: '发送成功,请注意查看手机短信',
// type: 'success'
// })
// }
// this.timer = setInterval(() => {
// if (this.count > 0 && this.count <= TIME_COUNT) {
// this.count--
// } else {
// this.show = true
// clearInterval(this.timer) // 清除定时器
// this.timer = null
// this.codeloading = false
// }
// }, 1000)
// }
},
// 忘记密码
runForgetPassord() {
this.getPassword = false
},
showPwd() {
if (this.passwordType === 'password') {
this.passwordType = ''
} else {
this.passwordType = 'password'
}
this.$nextTick(() => {
this.$refs.password.focus()
})
},
// 账户登录
handleAccountLogin() {
this.$refs.loginForm.validate(valid => {
if (valid) {
this.loading = true
const data = {
// username: JM.encrypt(this.loginForm.username),
// password: JM.encrypt(this.loginForm.password),
username: this.loginForm.username,
password: this.loginForm.password,
rememberMe: this.loginForm.rememberMe
}
this.$store
.dispatch('user/login', data)
.then(() => {
console.log(this.redirect)
this.$router.push({ path: this.redirect || '/' })
this.loading = false
adminBuild({ platformUserId: getUserId() }).then(res => {
console.log(res)
})
})
.catch(() => {
this.loading = false
})
} else {
console.log('error submit!!')
return false
}
})
},
// 手机号码
handlePhoneLogin() {
console.log(this.anthorForm)
this.$refs.anthorForm.validate(valid => {
if (valid) {
this.loading = true
const data = {
username: JM.encrypt(this.anthorForm.username),
code: JM.encrypt(this.anthorForm.code),
rememberMe: this.anthorForm.rememberMe
}
this.$store
.dispatch('user/login', data)
.then(() => {
this.$router.push({ path: this.redirect || '/' })
this.loading = false
adminBuild({ platformUserId: getUserId() }).then(res => {
console.log(res)
})
})
.catch(() => {
this.loading = false
})
} else {
console.log('error submit!!')
return false
}
})
},
// 找回密码
forgetPwdFn() {
console.log(this.retrievePwdForm)
this.$refs.retrievePwd.validate(valid => {
if (valid) {
this.loading = true
const data = {
|