|
@@ -24,9 +24,7 @@
|
|
|
</div>
|
|
|
|
|
|
<el-form-item prop="username">
|
|
|
- <span class="svg-container">
|
|
|
- <svg-icon icon-class="user" />
|
|
|
- </span>
|
|
|
+ <i class="iconfont icon-user form-left-container" />
|
|
|
<el-input
|
|
|
ref="username"
|
|
|
v-model="loginForm.username"
|
|
@@ -39,9 +37,7 @@
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item prop="password">
|
|
|
- <span class="svg-container">
|
|
|
- <svg-icon icon-class="password" />
|
|
|
- </span>
|
|
|
+ <i class="iconfont icon-password form-left-container" />
|
|
|
<el-input
|
|
|
:key="passwordType"
|
|
|
ref="password"
|
|
@@ -53,12 +49,40 @@
|
|
|
auto-complete="on"
|
|
|
@keyup.enter.native="handleLogin"
|
|
|
/>
|
|
|
- <span class="show-pwd" @click="showPwd">
|
|
|
- <svg-icon
|
|
|
- :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'"
|
|
|
- />
|
|
|
- </span>
|
|
|
+ <i :class="`iconfont icon-${passwordType === 'password' ? 'eye' : 'eye-open'} form-right-container`" @click="showPwd" />
|
|
|
</el-form-item>
|
|
|
+ <template v-if="isAdmin">
|
|
|
+ <el-form-item prop="phone">
|
|
|
+ <i class="iconfont icon-phone form-left-container" />
|
|
|
+ <el-input
|
|
|
+ ref="phone"
|
|
|
+ v-model="loginForm.phone"
|
|
|
+ placeholder="手机号"
|
|
|
+ name="phone"
|
|
|
+ type="text"
|
|
|
+ tabindex="1"
|
|
|
+ auto-complete="on"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <div style="display: flex;align-items: center">
|
|
|
+ <el-form-item prop="code" style="flex: 1">
|
|
|
+ <i class="iconfont icon-captcha form-left-container" />
|
|
|
+ <el-input
|
|
|
+ ref="code"
|
|
|
+ v-model="loginForm.code"
|
|
|
+ placeholder="验证码"
|
|
|
+ name="code"
|
|
|
+ type="text"
|
|
|
+ tabindex="1"
|
|
|
+ auto-complete="on"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-button class="code_btn" type="primary" :disabled="isSending" :loading="submitLoading" @click="sendCode">
|
|
|
+ {{ isSending ? `${countdown}s后重试` : "发送验证码" }}
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
|
|
|
<el-button
|
|
|
:loading="loading"
|
|
@@ -74,31 +98,33 @@
|
|
|
import { validUsername } from '@/utils/validate'
|
|
|
const path = require('path')
|
|
|
import { systemNoticeGetNotice } from '@/api/user_manage'
|
|
|
-import { getPicture } from '@/api/user'
|
|
|
+import { getPicture, getCode } from '@/api/user'
|
|
|
|
|
|
export default {
|
|
|
name: 'Login',
|
|
|
data() {
|
|
|
- const validateUsername = (rule, value, callback) => {
|
|
|
- if (!validUsername(value)) {
|
|
|
- callback(new Error('Please enter the correct user name'))
|
|
|
- } else {
|
|
|
- callback()
|
|
|
- }
|
|
|
- }
|
|
|
- const validatePassword = (rule, value, callback) => {
|
|
|
- if (value.length < 6) {
|
|
|
- callback(new Error('The password can not be less than 6 digits'))
|
|
|
+ const validatePhone = (rule, value, callback) => {
|
|
|
+ const phoneReg = /^1[3-9]\d{9}$/
|
|
|
+ if (!value || !phoneReg.test(value)) {
|
|
|
+ callback(new Error('请输入正确的手机号码'))
|
|
|
} else {
|
|
|
callback()
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return {
|
|
|
loginForm: {
|
|
|
username: '',
|
|
|
- password: ''
|
|
|
+ password: '',
|
|
|
+ phone: null,
|
|
|
+ code: ''
|
|
|
},
|
|
|
rules: {
|
|
|
+ username: [{
|
|
|
+ required: true,
|
|
|
+ whitespace: true,
|
|
|
+ message: '请输入你的账号',
|
|
|
+ trigger: ['change', 'blur'] }],
|
|
|
password: [
|
|
|
{ required: true, message: '请输入密码', trigger: 'blur' },
|
|
|
{
|
|
@@ -107,7 +133,13 @@ export default {
|
|
|
message:
|
|
|
'必须大小写字母、数字、特殊字符,4种组合中至少满足3种,且密码长度在10-32位之间。若无法登录,请联系管理员!'
|
|
|
}
|
|
|
- ]
|
|
|
+ ],
|
|
|
+ phone: [{ required: true, trigger: ['change', 'blur'], validator: validatePhone }],
|
|
|
+ code: [{
|
|
|
+ required: true,
|
|
|
+ whitespace: true,
|
|
|
+ message: '请输入验证码',
|
|
|
+ trigger: ['change', 'blur'] }]
|
|
|
},
|
|
|
loading: false,
|
|
|
passwordType: 'password',
|
|
@@ -116,7 +148,19 @@ export default {
|
|
|
noticeData: {},
|
|
|
title: '防控终端管理平台',
|
|
|
bg: '',
|
|
|
- logo: ''
|
|
|
+ logo: '',
|
|
|
+
|
|
|
+ /** 验证码开始 **/
|
|
|
+ isSending: false,
|
|
|
+ submitLoading: false,
|
|
|
+ countdown: 60,
|
|
|
+ timer: null
|
|
|
+ /** 验证码结束 **/
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ isAdmin() {
|
|
|
+ return this.loginForm.username == 'admin'
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
@@ -197,6 +241,10 @@ export default {
|
|
|
// this.loading = false;
|
|
|
// });
|
|
|
try {
|
|
|
+ if (!this.isAdmin) {
|
|
|
+ this.loginForm.phone = ''
|
|
|
+ this.loginForm.code = ''
|
|
|
+ }
|
|
|
await this.$store.dispatch('user/login', this.loginForm)
|
|
|
await this.$store.dispatch('user/getInfo')
|
|
|
const openInOutStatistics = this.$store.getters.openInOutStatistics
|
|
@@ -224,6 +272,43 @@ export default {
|
|
|
return false
|
|
|
}
|
|
|
})
|
|
|
+ },
|
|
|
+ // 发送验证码
|
|
|
+ sendCode() {
|
|
|
+ this.$refs.loginForm.validateField(['phone'], (valid) => {
|
|
|
+ console.log('发送验证码校验', valid)
|
|
|
+ // 字段校验成功则返回空串
|
|
|
+ if (!valid) {
|
|
|
+ const _this = this
|
|
|
+ _this.submitLoading = true
|
|
|
+ getCode({
|
|
|
+ username: _this.loginForm.username,
|
|
|
+ phone: _this.loginForm.phone
|
|
|
+ }).then(res => {
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: '发送验证码成功!'
|
|
|
+ })
|
|
|
+ _this.isSending = true
|
|
|
+ _this.countdown = 60
|
|
|
+ // 模拟请求后端发送验证码
|
|
|
+ console.log('验证码已发送至手机号:', _this.loginForm.phone)
|
|
|
+
|
|
|
+ _this.timer = setInterval(() => {
|
|
|
+ if (_this.countdown > 0) {
|
|
|
+ _this.countdown -= 1
|
|
|
+ } else {
|
|
|
+ clearInterval(_this.timer)
|
|
|
+ _this.isSending = false
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
+ }).finally(() => {
|
|
|
+ _this.submitLoading = false
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -247,7 +332,7 @@ $cursor: #fff;
|
|
|
.login-container {
|
|
|
.el-input {
|
|
|
display: inline-block;
|
|
|
- height: 47px;
|
|
|
+ height: 46px;
|
|
|
width: 85%;
|
|
|
|
|
|
input {
|
|
@@ -257,7 +342,8 @@ $cursor: #fff;
|
|
|
border-radius: 0px;
|
|
|
padding: 12px 5px 12px 15px;
|
|
|
color: black;
|
|
|
- height: 47px;
|
|
|
+ height: 46px;
|
|
|
+ line-height: 46px;
|
|
|
caret-color: black;
|
|
|
|
|
|
&:-webkit-autofill {
|
|
@@ -272,6 +358,8 @@ $cursor: #fff;
|
|
|
background: rgba(255, 255, 255, 0.8);
|
|
|
border-radius: 5px;
|
|
|
color: #454545;
|
|
|
+ height: 46px;
|
|
|
+ line-height: 46px;
|
|
|
}
|
|
|
}
|
|
|
</style>
|
|
@@ -322,13 +410,27 @@ $light_gray: #eee;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- .svg-container {
|
|
|
- padding: 6px 5px 6px 15px;
|
|
|
+ .form-left-container {
|
|
|
+ height: 46px;
|
|
|
+ width: 30px;
|
|
|
+ text-align: right;
|
|
|
color: $dark_gray;
|
|
|
vertical-align: middle;
|
|
|
+ display: inline-block;
|
|
|
+ }
|
|
|
+
|
|
|
+ .form-right-container {
|
|
|
+ height: 46px;
|
|
|
width: 30px;
|
|
|
+ text-align: center;
|
|
|
+ color: $dark_gray;
|
|
|
+ vertical-align: middle;
|
|
|
display: inline-block;
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+
|
|
|
+ .icon-eye {
|
|
|
+ font-size: 14px;
|
|
|
}
|
|
|
|
|
|
.title-container {
|
|
@@ -353,6 +455,26 @@ $light_gray: #eee;
|
|
|
user-select: none;
|
|
|
}
|
|
|
|
|
|
+ .code_btn {
|
|
|
+ margin-bottom: 22px;
|
|
|
+ width: 115px;
|
|
|
+ height: 46px;
|
|
|
+ margin-left: 10px;
|
|
|
+ font-size: 14px;
|
|
|
+ border-radius: 4px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ cursor: pointer;
|
|
|
+ background: #3d22d7;
|
|
|
+ border-color: #3d22d7;
|
|
|
+ }
|
|
|
+
|
|
|
+ .code_btn.is-disabled{
|
|
|
+ background: #6B74C8;
|
|
|
+ border-color: #6B74C8;
|
|
|
+ }
|
|
|
+
|
|
|
.logo {
|
|
|
position: absolute;
|
|
|
right: 50px;
|