register.vue
4.27 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
<template>
<div class="register_container">
<img src="@/assets/icon/bg_login_2.png" />
<div class="login_box">
<NafmHeader navClass="nafmii-head-bg1" />
</div>
<div class="login_content">
<div class="login_form_box">
<div class="login_form">
<van-field v-model.trim="phone" clearable type="tel" maxlength="11" :left-icon="phoneIcon" placeholder="请输入手机号" />
<van-field v-model.trim="verification" clearable label="" type="tel" maxlength="6" :left-icon="VerificationIcon" placeholder="请输入验证码">
<template #button>
<SendVerificationCode :phone="phone" :data="objParams" />
</template>
</van-field>
<van-field v-model.trim="password" clearable type="password" maxlength="16" :left-icon="passwordIcon" placeholder="请输入6-16位密码" />
<van-field v-model.trim="aginPassword" clearable type="password" maxlength="16" :left-icon="emptyIcon" placeholder="再次输入6-16位密码" />
<div class="login_btn" :class="{loginActive:isBothValue}" @click="handleRegister">注 册</div>
<div class="go_login_btn " @click="jumpLoginPage">有账号去登录</div>
</div>
</div>
</div>
<div class="register_agreement">
<div class="agreement_content">
<van-checkbox v-model="checked" checked-color="#106abc" class="checkbox" shape="square" icon-size="12px">
用户注册即代表同意
</van-checkbox>
<router-link to="">《用户协议及隐私政策》</router-link>
</div>
</div>
</div>
</template>
<script>
import SendVerificationCode from '@/components/SendVerificationCode'
import utils from "@/utils/";
export default {
name: 'Register',
components: {
SendVerificationCode
},
data() {
return {
phone: null,
verification: "",
password: "",
aginPassword: "",
objParams: {
type: 'phone'
},
type: 'phone',
phoneIcon: require('@/assets/icon/user.png'),
VerificationIcon: require('@/assets/icon/verification.png'),
passwordIcon: require('@/assets/icon/password.png'),
emptyIcon: require('@/assets/icon/empty.png'),
checked: false
}
},
computed: {
isBothValue() {
if (this.phone && this.verification && this.password && this.aginPassword && this.checked) {
return true
} else {
return false
}
},
},
mounted() {
// this.
},
methods: {
// 注册操作
handleRegister() {
if (!this.phone) {
Toast('请输入手机号')
return
}
if (!utils.phoneRegCheck(this.phone)) {
Toast("请输入正确的手机号码!");
return
}
if (!this.verification) {
Toast('请输入验证码')
return
}
if (!this.password) {
Toast('请输入密码')
return
}
if (!this.aginPassword) {
Toast('请再次输入密码')
return
}
if (this.password != this.aginPassword) {
Toast('两次密码输入不一致,请重新输入')
return
}
if (!this.checked) {
Toast('选勾选用户协议及隐私政策')
return
}
// todo 请求接口 注册成功 查询用户信息 并且完成登录操作
console.log(1)
this.$router.push({
path: '/user/person',
query: {
status: 'first'
}
})
},
// 跳转到登录页面
jumpLoginPage() {
const { source } = this.$route.query
if (source == 'phone' || source == 'username') {
this.$router.back()
} else {
this.$router.push({
path: '/user/login/phone'
})
}
}
}
}
</script>
<style lang="less" scoped>
@import "./less/login.less";
.register_container {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
.go_login_btn {
margin-top: 10px;
display: flex;
justify-content: center;
color: #106abc;
font-size: 13px;
}
.register_agreement {
width: 384px;
display: flex;
flex: 1;
flex-direction: row;
align-items: flex-end;
margin-bottom: 30px;
justify-content: center;
a {
color: #106abc;
}
}
.agreement_content {
display: flex;
flex-direction: row;
align-items: center;
}
</style>