李志伟 3 years ago
parent
commit
611244ecce
5 changed files with 0 additions and 652 deletions
  1. 0
    45
      src/api/user.js
  2. 0
    14
      src/router/index.js
  3. 0
    272
      src/views/login/forgotPassword.vue
  4. 0
    10
      src/views/login/index.vue
  5. 0
    311
      src/views/login/register.vue

+ 0
- 45
src/api/user.js View File

@@ -22,26 +22,6 @@ export function login(data) {
22 22
   })
23 23
 }
24 24
 
25
-/**
26
-* 注册账号
27
-* @param {*} data
28
-* @returns
29
-*/
30
-export const signUp = (data) => request({
31
-  url: '/admin/signup',
32
-  method: 'post',
33
-  data
34
-})
35
-
36
-/**
37
- * 获取验证码
38
- * @param {*} params
39
- * @returns
40
- */
41
-export const getCaptcha = (params) => request({
42
-  url: '/admin/captcha', params
43
-})
44
-
45 25
 /**
46 26
  * 修改密码
47 27
  * @param {*} data
@@ -50,28 +30,3 @@ export const getCaptcha = (params) => request({
50 30
 export const changePassword = (data) => request({
51 31
   url: '/admin/change-password', method: 'put', data
52 32
 })
53
-/**
54
- * 启用账号
55
- * @param {*} data
56
- * @returns
57
- */
58
-export const enableUser = (id) => request({
59
-  url: `/admin/user/${id}/on`, method: 'put'
60
-})
61
-/**
62
- * 禁用账号
63
- * @param {*} data
64
- * @returns
65
- */
66
-export const disableUser = (id) => request({
67
-  url: `/admin/user/${id}/off`, method: 'put'
68
-})
69
-
70
-/**
71
- * 找回密码
72
- * @param {*} data
73
- * @returns
74
- */
75
-export const findPassword = (data) => request({
76
-  url: '/admin/find-password', method: 'put', data
77
-})

+ 0
- 14
src/router/index.js View File

@@ -63,20 +63,6 @@ export const constantRoutes = [
63 63
     hidden: true
64 64
   },
65 65
 
66
-  {
67
-    path: '/login/register',
68
-    component: () => import('@/views/login/register'),
69
-    hidden: true,
70
-    name: 'register'
71
-  },
72
-
73
-  {
74
-    path: '/login/forgotPassword',
75
-    component: () => import('@/views/login/forgotPassword'),
76
-    hidden: true,
77
-    name: 'forgotPassword'
78
-  },
79
-
80 66
   {
81 67
     path: '/404',
82 68
     component: () => import('@/views/404'),

+ 0
- 272
src/views/login/forgotPassword.vue View File

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

+ 0
- 10
src/views/login/index.vue View File

@@ -55,16 +55,6 @@
55 55
         style="width: 100%; margin-bottom: 30px"
56 56
         @click.native.prevent="handleLogin"
57 57
       >登录</el-button>
58
-      <el-link :underline="false" style="margin:0" type="primary">
59
-        <router-link
60
-          :to="{name: 'register'}"
61
-        >注册账号</router-link>
62
-      </el-link>
63
-      <el-link :underline="false" style="float:right" type="primary">
64
-        <router-link
65
-          :to="{name: 'forgotPassword'}"
66
-        >忘记密码</router-link>
67
-      </el-link>
68 58
     </el-form>
69 59
   </div>
70 60
 </template>

+ 0
- 311
src/views/login/register.vue View File

@@ -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>