register.vue
10.7 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
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
<template>
<el-row class="login-box">
<div>
<h1>团 体 会 员 注 册</h1>
<!-- <el-row v-if="!showRegister" :gutter="20">
<el-card class=" box">
<el-row>
<el-col :span="12">
<el-card
shadow="hover" class="card
" :class="{ active: selectItem==1}" @click="selectItem=1"
>
<div class="imgbox">
<img class="imgs" src="@/assets/images/btn01@2x.png" alt="">
<h2 style="text-align: center;">团体会员</h2>
<div class="con">
这里是团体会员介绍这里
是团体会员介绍
</div>
</div>
<img v-if="selectItem==1" class="imgSon" src="@/assets/images/xz@2x.png" alt="">
</el-card>
</el-col>
<el-col :span="12">
<el-card
shadow="hover" class="card
" :class="{ active: selectItem==2}" @click="selectItem=2"
>
<div class="imgbox">
<img class="imgs" src="@/assets/images/btn02@2x.png" alt="">
<h2 style="text-align: center;">个人会员</h2>
<div class="con">
这里是团体会员介绍这里
是团体会员介绍
</div>
</div>
<img v-if="selectItem==2" class="imgSon" src="@/assets/images/xz@2x.png" alt="">
</el-card>
</el-col>
</el-row>
<br>
<br>
<el-row justify="center">
<el-button class="btn" :disabled="selectItem==0" type="primary" @click="selected">确 定</el-button>
</el-row>
</el-card>
</el-row> -->
<div class="restFrom">
<el-form
ref="registerRef"
:model="registerForm"
:rules="registerRules"
class="register-form"
>
<el-form-item prop="telNo">
<el-input
v-model="registerForm.telNo"
type="text"
size="large"
auto-complete="off"
placeholder="请输入手机号,可作为登录账号"
>
<template #prefix><svg-icon icon-class="phone" class="el-input__icon input-icon" /></template>
</el-input>
</el-form-item>
<el-form-item prop="password">
<el-input
v-model="registerForm.password"
type="password"
size="large"
auto-complete="off"
placeholder="密码为8位以上大小写字母加数字加特殊符号组合"
>
<template #prefix><svg-icon
icon-class="password"
class="el-input__icon input-icon"
/></template>
</el-input>
</el-form-item>
<el-form-item prop="passwords">
<el-input
v-model="registerForm.passwords"
type="password"
size="large"
auto-complete="off"
placeholder="确认密码"
>
<template #prefix><svg-icon
icon-class="password"
class="el-input__icon input-icon"
/></template>
</el-input>
</el-form-item>
<el-form-item prop="captcha">
<captcha ref="codeRef" v-model="registerForm.captcha" v-model:uuid="registerForm.uuid" @keyup.enter="handleRegister" />
</el-form-item>
<el-form-item prop="code">
<captcha-sms v-model="registerForm.code" :verify="checkCaptchaSms" @keyup.enter="handleRegister" @error="getCode" />
</el-form-item>
<el-form-item style="width: 100%">
<el-button
:loading="loading"
size="large"
type="success"
style="width: 100%;border: 0;"
@click.prevent="handleRegister"
>
<span v-if="!loading">注 册</span>
<span v-else>注 册 中...</span>
</el-button>
</el-form-item>
</el-form>
</div>
</div>
</el-row>
</template>
<script setup>
import { ref } from 'vue'
import { getCurrentInstance } from '@vue/runtime-core'
import { groupMemberRegister } from '@/api/login'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useRouter } from 'vue-router'
import Captcha from './components/captcha'
import CaptchaSms from './components/captchaSms'
import zxcvbn from 'zxcvbn'
const { proxy } = getCurrentInstance()
// const selectItem = ref(1)
// const showRegister = ref(true)
// function selected() {
// if (selectItem.value == 2) {
// proxy.$modal.msgWarning('个人会员暂未开放注册')
// } else if (selectItem.value == 1) {
// showRegister.value = true
// }
// }
const router = useRouter()
const registerForm = ref({
telNo: '',
password: '',
code: '',
uuid: '',
captcha: ''
})
const registerRules = {
telNo: [
{ required: true, trigger: 'blur', message: '请输入手机号' },
{
pattern: /^1[3456789]\d{9}$/,
message: '手机号码格式不正确',
trigger: 'blur'
}
],
password: [
{ required: true, trigger: 'blur', message: '请输入您的密码' },
{
min: 6,
max: 18,
message: '用户密码长度必须介于 6 和 18 之间',
trigger: 'blur'
},
{
pattern: /^(?=.*?[a-z])(?=.*?[A-Z])(?=.*?\d)(?=.*?[!#@*&.])[a-zA-Z\d!#@*&.]{8,}$/,
message: '8位以上大小写字母、数字、特殊符号组合',
trigger: 'blur'
}
],
passwords: [
{ required: true, trigger: 'blur', message: '请确认密码' },
{ validator: validatePassword, trigger: 'blur' }
],
captcha: [{ required: true, trigger: 'blur', message: '请输入图形验证码' }],
code: [{ required: true, trigger: 'blur', message: '请输入短信验证码' }]
}
const loading = ref(false)
function handleRegister() {
// console.log(zxcvbn(registerForm.value.password))
proxy.$refs['registerRef'].validate((valid) => {
if (valid) {
loading.value = true
groupMemberRegister(registerForm.value)
.then((res) => {
ElMessageBox.alert(
"<font color='red'>恭喜你,您的账号 " +
registerForm.value.telNo +
' 注册成功!</font>',
'系统提示',
{
dangerouslyUseHTMLString: true,
type: 'success'
}
).then(() => {
router.push('/login')
})
})
.catch(() => {
loading.value = false
getCode()
})
}
})
}
// 确认密码
function validatePassword(rule, value, callback) {
if (registerForm.value.password === value) {
return callback() // callback() is a function on the Vue prototype. It can be called like the regular callback. (See https://vuejs.org
} else {
return callback(new Error('两次密码不一致,请重新输入'))
}
}
// 发送短信验证码
function checkCaptchaSms() {
// 判断手机号正确
if (!registerForm.value.telNo) {
ElMessage({
showClose: true,
message: '请输入手机号',
type: 'error'
})
return Promise.reject()
}
// 判断验证码填了没
if (!registerForm.value.captcha) {
ElMessage({
showClose: true,
message: '请输入图形验证码',
type: 'error'
})
return Promise.reject()
}
const strTemp = /^1[3|4|5|6|7|8|9][0-9]{9}$/
if (!strTemp.test(registerForm.value.telNo)) {
ElMessage({
showClose: true,
message: '请输入正确的手机号',
type: 'error'
})
return Promise.reject()
}
return Promise.resolve({
uuid: registerForm.value.uuid,
telNo: registerForm.value.telNo,
captcha: registerForm.value.captcha
})
}
function getCode() {
proxy.$refs['codeRef'].getCode()
}
</script>
<style lang="scss" scoped>
:deep(.el-input-group__append) {
color: #fff;
background-color: #44dcb5;
}
.restFrom {
display: flex;
justify-content: center;
align-items: center;
height: 80%;
}
.login-box {
display: flex;
justify-content: center;
align-items: center;
}
.title {
padding: 0px 200px;
height: 100px;
background-color: #fff;
}
.title-right {
display: flex;
justify-content: space-between;
}
.title-left {
color: #043793;
font-weight: 900;
font-size: 30px;
margin-left: 100px;
padding-top: 25px;
}
.tilt-btn {
// background-color: #043793;
color: #043793;
font-weight: 700;
background-color: none;
font-size: 20px;
margin-right: 20px;
padding-top: 15px;
padding-left: 20px;
padding-right: 20px;
cursor: pointer;
}
.btn {
color: #fff;
background-color: #043793;
border-radius: 10px;
}
.title-text {
color: #043793;
font-weight: 500;
font-size: 20px;
}
.text-center {
color: #fff;
font-size: 40px;
font-weight: 700;
margin-right: 40px;
}
.register {
// display: flex;
// justify-content: center;
// align-items: center;
height: 100%;
background-image: url("@/assets/images/login-background.jpg");
background-size: cover;
}
.register-form {
width: 580px;
height: 460px;
background: #FFFFFF;
box-shadow: 0px 0px 38px 0px rgba(30,98,151,0.73);
border-radius: 15px;
padding: 40px 65px;
:deep(.el-input) {
height: 40px;
input {
height: 40px;
}
}
.input-icon {
height: 39px;
width: 14px;
margin-left: 0px;
}
}
.register-tip {
font-size: 13px;
text-align: center;
color: #bfbfbf;
}
.register-code {
width: 33%;
height: 40px;
float: right;
img {
cursor: pointer;
vertical-align: middle;
}
}
.el-register-footer {
height: 40px;
line-height: 40px;
position: fixed;
bottom: 0;
width: 100%;
text-align: center;
color: #fff;
font-family: Arial;
font-size: 12px;
letter-spacing: 1px;
}
.register-code-img {
height: 40px;
padding-left: 12px;
}
.text{
text-align: center;
position: absolute;
top: 120px;
font-size: 36px;
font-family: Source Han Sans CN;
font-weight: bold;
color: #FFFFFF;
}
.con{
font-size: 18px;
font-family: Source Han Sans CN;
font-weight: 400;
color: #7B7F83;
}
.imgs{
width: 268px;
height:249px ;
}
.imgbox{
width: 350px;
// margin: 25px;
text-align: center;
}
.card{
margin: 25px;
border: 4px solid #DCDCDC;
border-radius: 15px;
position: relative;
}
.imgSon{
position: absolute;
top: -1px;
left: -1px;
width: 90px;
height: 90px;
border: 0 !important;
}
.active{
border: 4px solid #014A9F !important;
}
.btn{
width: 440px;
height: 60px;
background: #014A9F;
border-radius: 4px;
}
:deep(.btn span){
font-size: 20px;
font-family: Source Han Sans CN;
font-weight: 400;
color: #FFFFFF;
}
h1{text-align: center; color: #fff;}
</style>