findPassword.vue
2.94 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
<template>
<div class="login_container">
<img src="@/assets/icon/bg_login_2.png" />
<div class="login_box">
<NafmHeader navClass="nafmii-head-bg1" :title="title" bgColor="transparent" />
</div>
<div class="login_content">
<div class="login_form_box">
<div class="login_form">
<van-field v-show="type=='phone'" v-model.trim="userName" clearable type="tel" maxlength="11" :left-icon="telIcon" placeholder="请输入手机号" />
<van-field v-show="type=='email'" v-model.trim="email" clearable :left-icon="emailIcon" placeholder="请输入邮箱" />
<van-field v-model="password" clearable label="" maxlength="6" :left-icon="VerificationIcon" placeholder="请输入验证码">
<template #button>
<SendVerificationCode :phone="userName" :email="email" :data="objParams" />
</template>
</van-field>
<div class="login_btn" :class="{loginActive:isBothValue}" @click="jumpResetPasswordPage">确定</div>
</div>
</div>
</div>
</div>
</template>
<script>
import SendVerificationCode from '@/components/SendVerificationCode'
import utils from "@/utils/";
export default {
name: 'Login',
components: {
SendVerificationCode
},
data() {
return {
userName: null,
password: "",
title: '',
type: null,
objParams: {},
email: '',
phone: '',
telIcon: require('@/assets/icon/tel.png'),
emailIcon: require('@/assets/icon/email.png'),
VerificationIcon: require('@/assets/icon/verification.png'),
passwordIcon: require('@/assets/icon/password.png'),
}
},
created() {
const { type } = this.$route.query
this.type = type
Object.assign(this.objParams, {
type
})
if (type == 'phone') {
this.title = '手机号找回'
} else {
this.title = '邮箱找回'
}
},
computed: {
isBothValue() {
if ((this.userName && this.password) || (this.email && this.password)) {
return true
} else {
return false
}
},
},
methods: {
jumpResetPasswordPage() {
const { type } = this.$route.query
if (type == 'phone') {
// 判断手机号不能为空
if (!this.userName) {
Toast('请输入手机号')
return
}
if (!utils.phoneRegCheck(this.userName)) {
Toast("请输入正确的手机号码!");
return
}
} else {
// 判断邮箱不能为空
if (!this.email) {
Toast('请输入邮箱')
return
}
if (!utils.emailRegCheck(this.email)) {
Toast("请输入正确的邮箱格式!");
return
}
}
if (!this.password) {
Toast('请输入验证码')
return
}
this.$router.push({
path: '/user/resetPassword'
})
}
}
}
</script>
<style lang="less" scoped>
@import "./less/login.less";
</style>