|
@@ -1,311 +0,0 @@
|
1
|
|
-<template>
|
2
|
|
- <div class="login-container">
|
3
|
|
- <el-form
|
4
|
|
- ref="regisiterForm"
|
5
|
|
- :model="regisiterForm"
|
6
|
|
- :rules="regisiterRules"
|
7
|
|
- class="login-form"
|
8
|
|
- auto-complete="on"
|
9
|
|
- label-position="left"
|
10
|
|
- >
|
11
|
|
- <div class="title-container">
|
12
|
|
- <h3 class="title">注册账号</h3>
|
13
|
|
- </div>
|
14
|
|
-
|
15
|
|
- <el-form-item prop="name">
|
16
|
|
- <span class="svg-container">
|
17
|
|
- <svg-icon icon-class="user" />
|
18
|
|
- </span>
|
19
|
|
- <el-input
|
20
|
|
- ref="name"
|
21
|
|
- v-model="regisiterForm.name"
|
22
|
|
- placeholder="用户名"
|
23
|
|
- name="name"
|
24
|
|
- type="text"
|
25
|
|
- tabindex="1"
|
26
|
|
- />
|
27
|
|
- </el-form-item>
|
28
|
|
- <el-form-item prop="password">
|
29
|
|
- <span class="svg-container">
|
30
|
|
- <svg-icon icon-class="password" />
|
31
|
|
- </span>
|
32
|
|
- <el-input
|
33
|
|
- ref="password"
|
34
|
|
- v-model="regisiterForm.password"
|
35
|
|
- type="password"
|
36
|
|
- placeholder="请输入密码"
|
37
|
|
- name="password"
|
38
|
|
- tabindex="2"
|
39
|
|
- />
|
40
|
|
- </el-form-item>
|
41
|
|
- <el-form-item prop="password2">
|
42
|
|
- <span class="svg-container">
|
43
|
|
- <svg-icon icon-class="password" />
|
44
|
|
- </span>
|
45
|
|
- <el-input
|
46
|
|
- ref="password2"
|
47
|
|
- v-model="regisiterForm.password2"
|
48
|
|
- type="password"
|
49
|
|
- placeholder="确认密码"
|
50
|
|
- name="password2"
|
51
|
|
- tabindex="3"
|
52
|
|
- />
|
53
|
|
- </el-form-item>
|
54
|
|
- <el-form-item prop="phone">
|
55
|
|
- <span class="svg-container">
|
56
|
|
- <svg-icon icon-class="phone" />
|
57
|
|
- </span>
|
58
|
|
- <el-input
|
59
|
|
- ref="phone"
|
60
|
|
- v-model="regisiterForm.phone"
|
61
|
|
- type="tel"
|
62
|
|
- placeholder="手机号"
|
63
|
|
- name="phone"
|
64
|
|
- tabindex="4"
|
65
|
|
- />
|
66
|
|
- </el-form-item>
|
67
|
|
-
|
68
|
|
- <el-form-item prop="captcha" style="width:65%">
|
69
|
|
- <span class="svg-container">
|
70
|
|
- <svg-icon icon-class="captcha" />
|
71
|
|
- </span>
|
72
|
|
- <el-input
|
73
|
|
- ref="captcha"
|
74
|
|
- v-model="regisiterForm.captcha"
|
75
|
|
- type="text"
|
76
|
|
- placeholder="验证码"
|
77
|
|
- tabindex="5"
|
78
|
|
- name="captcha"
|
79
|
|
- @keyup.enter.native="handleLogin"
|
80
|
|
- />
|
81
|
|
- <el-button style="position: absolute;right: -150px;top: 6px;" :disabled="disabled" @click="sendCode">{{ btnText }}</el-button>
|
82
|
|
- </el-form-item>
|
83
|
|
-
|
84
|
|
- <el-button
|
85
|
|
- :loading="loading"
|
86
|
|
- type="primary"
|
87
|
|
- style="width: 100%; margin-bottom: 30px"
|
88
|
|
- @click.native.prevent="handleLogin"
|
89
|
|
- >注册</el-button>
|
90
|
|
- <el-link :underline="false" style="margin:0" type="primary">
|
91
|
|
- <router-link
|
92
|
|
- :to="{path: '/login'}"
|
93
|
|
- >登录系统</router-link>
|
94
|
|
- </el-link>
|
95
|
|
- <el-link :underline="false" style="float:right" type="primary">
|
96
|
|
- <router-link
|
97
|
|
- :to="{name: 'forgotPassword'}"
|
98
|
|
- >忘记密码</router-link>
|
99
|
|
- </el-link>
|
100
|
|
- </el-form>
|
101
|
|
- </div>
|
102
|
|
-</template>
|
103
|
|
-<script>
|
104
|
|
-import { getCaptcha, signUp } from '@/api/user'
|
105
|
|
-import md5 from 'js-md5'
|
106
|
|
-export default {
|
107
|
|
- name: 'Login',
|
108
|
|
- data() {
|
109
|
|
- const validatePhone = (rule, value, callback) => {
|
110
|
|
- if (!value) {
|
111
|
|
- return callback(new Error('手机号不能为空'))
|
112
|
|
- } else {
|
113
|
|
- const reg = /^1[3|4|5|7|8][0-9]\d{8}$/
|
114
|
|
- if (reg.test(value)) {
|
115
|
|
- callback()
|
116
|
|
- } else {
|
117
|
|
- return callback(new Error('请输入正确的手机号'))
|
118
|
|
- }
|
119
|
|
- }
|
120
|
|
- }
|
121
|
|
- return {
|
122
|
|
- regisiterForm: {
|
123
|
|
- name: undefined,
|
124
|
|
- password: undefined,
|
125
|
|
- phone: undefined,
|
126
|
|
- captcha: '619400',
|
127
|
|
- password2: undefined
|
128
|
|
- },
|
129
|
|
- regisiterRules: {
|
130
|
|
- name: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
|
131
|
|
- password: [
|
132
|
|
- { required: true, trigger: 'change', message: '请输入密码' }
|
133
|
|
- ],
|
134
|
|
- password2: [
|
135
|
|
- { required: true, trigger: 'change', message: '请再次输入密码' }
|
136
|
|
- ],
|
137
|
|
- phone: [
|
138
|
|
- { required: true, trigger: 'change', validator: validatePhone }
|
139
|
|
- ],
|
140
|
|
- captcha: [
|
141
|
|
- { required: true, trigger: 'change', message: '请输入验证码' }
|
142
|
|
- ]
|
143
|
|
- },
|
144
|
|
- disabled: false,
|
145
|
|
- btnText: '发送验证码',
|
146
|
|
- time: 0,
|
147
|
|
- loading: false
|
148
|
|
- }
|
149
|
|
- },
|
150
|
|
- methods: {
|
151
|
|
- sendCode() {
|
152
|
|
- this.disabled = true
|
153
|
|
-
|
154
|
|
- this.$refs.regisiterForm.validateField('phone', (errorMessage) => {
|
155
|
|
- if (errorMessage) {
|
156
|
|
- this.$message.error(errorMessage)
|
157
|
|
-
|
158
|
|
- this.disabled = false
|
159
|
|
- } else {
|
160
|
|
- getCaptcha({ phone: this.regisiterForm.phone })
|
161
|
|
- .then((e) => {})
|
162
|
|
- .catch((res) => {
|
163
|
|
- })
|
164
|
|
- this.time = 60
|
165
|
|
- const timer = setInterval(() => {
|
166
|
|
- this.time-- // 倒计时递减
|
167
|
|
- this.btnText = `${this.time}s后重新发送`
|
168
|
|
- if (this.time === 0) {
|
169
|
|
- this.disabled = false
|
170
|
|
- this.btnText = '重新发送'
|
171
|
|
- this.time = this.countDown
|
172
|
|
- clearInterval(timer)
|
173
|
|
- }
|
174
|
|
- }, 1000)
|
175
|
|
- }
|
176
|
|
- })
|
177
|
|
- },
|
178
|
|
- handleLogin() {
|
179
|
|
- this.$refs.regisiterForm.validate((valid) => {
|
180
|
|
- if (valid) {
|
181
|
|
- if (this.regisiterForm.password !== this.regisiterForm.password2) {
|
182
|
|
- this.$message('密码输入不一致请重新输入')
|
183
|
|
- this.$refs.password2.focus()
|
184
|
|
- return false
|
185
|
|
- } else {
|
186
|
|
- var newData = { ...this.regisiterForm }
|
187
|
|
- newData.password = md5(newData.password)
|
188
|
|
- signUp(newData).then((res) => {
|
189
|
|
- this.$message('注册成功')
|
190
|
|
- this.$router.push({ path: '/login' })
|
191
|
|
- })
|
192
|
|
- }
|
193
|
|
- } else {
|
194
|
|
- return false
|
195
|
|
- }
|
196
|
|
- })
|
197
|
|
- }
|
198
|
|
- }
|
199
|
|
-}
|
200
|
|
-</script>
|
201
|
|
-
|
202
|
|
-<style lang="scss">
|
203
|
|
-/* 修复input 背景不协调 和光标变色 */
|
204
|
|
-/* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */
|
205
|
|
-
|
206
|
|
-$bg: #283443;
|
207
|
|
-$light_gray: #fff;
|
208
|
|
-$cursor: #fff;
|
209
|
|
-
|
210
|
|
-@supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
|
211
|
|
- .login-container .el-input input {
|
212
|
|
- color: $cursor;
|
213
|
|
- }
|
214
|
|
-}
|
215
|
|
-
|
216
|
|
-/* reset element-ui css */
|
217
|
|
-.login-container {
|
218
|
|
- .el-input {
|
219
|
|
- display: inline-block;
|
220
|
|
- height: 47px;
|
221
|
|
- width: 85%;
|
222
|
|
-
|
223
|
|
- input {
|
224
|
|
- background: transparent;
|
225
|
|
- border: 0px;
|
226
|
|
- -webkit-appearance: none;
|
227
|
|
- border-radius: 0px;
|
228
|
|
- padding: 12px 5px 12px 15px;
|
229
|
|
- color: $light_gray;
|
230
|
|
- height: 47px;
|
231
|
|
- caret-color: $cursor;
|
232
|
|
-
|
233
|
|
- &:-webkit-autofill {
|
234
|
|
- box-shadow: 0 0 0px 1000px $bg inset !important;
|
235
|
|
- -webkit-text-fill-color: $cursor !important;
|
236
|
|
- }
|
237
|
|
- }
|
238
|
|
- }
|
239
|
|
-
|
240
|
|
- .el-form-item {
|
241
|
|
- border: 1px solid rgba(255, 255, 255, 0.1);
|
242
|
|
- background: rgba(0, 0, 0, 0.1);
|
243
|
|
- border-radius: 5px;
|
244
|
|
- color: #454545;
|
245
|
|
- }
|
246
|
|
-}
|
247
|
|
-</style>
|
248
|
|
-
|
249
|
|
-<style lang="scss" scoped>
|
250
|
|
-$bg: #2d3a4b;
|
251
|
|
-$dark_gray: #889aa4;
|
252
|
|
-$light_gray: #eee;
|
253
|
|
-
|
254
|
|
-.login-container {
|
255
|
|
- min-height: 100%;
|
256
|
|
- width: 100%;
|
257
|
|
- background-color: $bg;
|
258
|
|
- overflow: hidden;
|
259
|
|
-
|
260
|
|
- .login-form {
|
261
|
|
- position: relative;
|
262
|
|
- width: 520px;
|
263
|
|
- max-width: 100%;
|
264
|
|
- padding: 160px 35px 0;
|
265
|
|
- margin: 0 auto;
|
266
|
|
- overflow: hidden;
|
267
|
|
- }
|
268
|
|
-
|
269
|
|
- .tips {
|
270
|
|
- font-size: 14px;
|
271
|
|
- color: #fff;
|
272
|
|
- margin-bottom: 10px;
|
273
|
|
-
|
274
|
|
- span {
|
275
|
|
- &:first-of-type {
|
276
|
|
- margin-right: 16px;
|
277
|
|
- }
|
278
|
|
- }
|
279
|
|
- }
|
280
|
|
-
|
281
|
|
- .svg-container {
|
282
|
|
- padding: 6px 5px 6px 15px;
|
283
|
|
- color: $dark_gray;
|
284
|
|
- vertical-align: middle;
|
285
|
|
- width: 30px;
|
286
|
|
- display: inline-block;
|
287
|
|
- }
|
288
|
|
-
|
289
|
|
- .title-container {
|
290
|
|
- position: relative;
|
291
|
|
-
|
292
|
|
- .title {
|
293
|
|
- font-size: 26px;
|
294
|
|
- color: $light_gray;
|
295
|
|
- margin: 0px auto 40px auto;
|
296
|
|
- text-align: center;
|
297
|
|
- font-weight: bold;
|
298
|
|
- }
|
299
|
|
- }
|
300
|
|
-
|
301
|
|
- .show-pwd {
|
302
|
|
- position: absolute;
|
303
|
|
- right: 10px;
|
304
|
|
- top: 7px;
|
305
|
|
- font-size: 16px;
|
306
|
|
- color: $dark_gray;
|
307
|
|
- cursor: pointer;
|
308
|
|
- user-select: none;
|
309
|
|
- }
|
310
|
|
-}
|
311
|
|
-</style>
|