|
@@ -1,19 +1,19 @@
|
|
|
<template>
|
|
|
<div class="login-container">
|
|
|
- <img class="bg" :src="bg" alt="" />
|
|
|
- <img class="logo" :src="logo" alt="" />
|
|
|
- <div class="affiche-box" v-if="noticeData.isShow">
|
|
|
+ <img class="bg" :src="bg" alt="">
|
|
|
+ <img class="logo" :src="logo" alt="">
|
|
|
+ <div v-if="noticeData.isShow" class="affiche-box">
|
|
|
<h4>{{ noticeData.titile }}</h4>
|
|
|
<p>
|
|
|
{{ noticeData.content }}
|
|
|
</p>
|
|
|
<div class="qrcode">
|
|
|
- <img :src="noticeData.picture" alt="" />
|
|
|
+ <img :src="noticeData.picture" alt="">
|
|
|
</div>
|
|
|
</div>
|
|
|
<el-form
|
|
|
- :rules="rules"
|
|
|
ref="loginForm"
|
|
|
+ :rules="rules"
|
|
|
:model="loginForm"
|
|
|
class="login-form"
|
|
|
auto-complete="on"
|
|
@@ -65,117 +65,116 @@
|
|
|
type="primary"
|
|
|
style="width: 100%; margin-top: 10px; background: #3d22d7"
|
|
|
@click.native.prevent="handleLogin"
|
|
|
- >登录</el-button
|
|
|
- >
|
|
|
+ >登录</el-button>
|
|
|
</el-form>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { validUsername } from "@/utils/validate";
|
|
|
-const path = require("path");
|
|
|
-import { systemNoticeGetNotice } from "@/api/user_manage";
|
|
|
-import { getPicture } from "@/api/user";
|
|
|
+import { validUsername } from '@/utils/validate'
|
|
|
+const path = require('path')
|
|
|
+import { systemNoticeGetNotice } from '@/api/user_manage'
|
|
|
+import { getPicture } from '@/api/user'
|
|
|
|
|
|
export default {
|
|
|
- name: "Login",
|
|
|
+ name: 'Login',
|
|
|
data() {
|
|
|
const validateUsername = (rule, value, callback) => {
|
|
|
if (!validUsername(value)) {
|
|
|
- callback(new Error("Please enter the correct user name"));
|
|
|
+ callback(new Error('Please enter the correct user name'))
|
|
|
} else {
|
|
|
- callback();
|
|
|
+ callback()
|
|
|
}
|
|
|
- };
|
|
|
+ }
|
|
|
const validatePassword = (rule, value, callback) => {
|
|
|
if (value.length < 6) {
|
|
|
- callback(new Error("The password can not be less than 6 digits"));
|
|
|
+ callback(new Error('The password can not be less than 6 digits'))
|
|
|
} else {
|
|
|
- callback();
|
|
|
+ callback()
|
|
|
}
|
|
|
- };
|
|
|
+ }
|
|
|
return {
|
|
|
loginForm: {
|
|
|
- username: "",
|
|
|
- password: "",
|
|
|
+ username: '',
|
|
|
+ password: ''
|
|
|
},
|
|
|
rules: {
|
|
|
password: [
|
|
|
- { required: true, message: "请输入密码", trigger: "blur" },
|
|
|
+ { required: true, message: '请输入密码', trigger: 'blur' },
|
|
|
{
|
|
|
pattern:
|
|
|
/^(((?=.*\d)(?=.*[a-z])(?=.*[A-Z]))|((?=.*\d)(?=.*[a-z])(?=.*[~!@#$%^&*]))|((?=.*\d)(?=.*[A-Z])(?=.*[~!@#$%^&*]))|((?=.*[a-z])(?=.*[A-Z])(?=.*[~!@#$%^&*]))|((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[~!@#$%^&*]))).{10,32}$/,
|
|
|
message:
|
|
|
- "必须大小写字母、数字、特殊字符,4种组合中至少满足3种,且密码长度在10-32位之间。若无法登录,请联系管理员!",
|
|
|
- },
|
|
|
- ],
|
|
|
+ '必须大小写字母、数字、特殊字符,4种组合中至少满足3种,且密码长度在10-32位之间。若无法登录,请联系管理员!'
|
|
|
+ }
|
|
|
+ ]
|
|
|
},
|
|
|
loading: false,
|
|
|
- passwordType: "password",
|
|
|
+ passwordType: 'password',
|
|
|
redirect: undefined,
|
|
|
// 公告数据
|
|
|
noticeData: {},
|
|
|
- title: "防控终端管理平台",
|
|
|
- bg:'',
|
|
|
- logo:'',
|
|
|
- };
|
|
|
+ title: '防控终端管理平台',
|
|
|
+ bg: '',
|
|
|
+ logo: ''
|
|
|
+ }
|
|
|
},
|
|
|
watch: {
|
|
|
$route: {
|
|
|
- handler: function (route) {
|
|
|
- this.redirect = route.query && route.query.redirect;
|
|
|
+ handler: function(route) {
|
|
|
+ this.redirect = route.query && route.query.redirect
|
|
|
},
|
|
|
- immediate: true,
|
|
|
- },
|
|
|
+ immediate: true
|
|
|
+ }
|
|
|
},
|
|
|
created() {
|
|
|
- this.getPicture();
|
|
|
- this.systemNoticeGetNotice();
|
|
|
+ this.getPicture()
|
|
|
+ this.systemNoticeGetNotice()
|
|
|
},
|
|
|
methods: {
|
|
|
// 获取背景
|
|
|
getPicture() {
|
|
|
getPicture().then((res) => {
|
|
|
- console.log(res);
|
|
|
- this.title = res.data.title;
|
|
|
- this.bg = res.data.bg;
|
|
|
- this.logo = res.data.logo;
|
|
|
- document.title=res.data.title
|
|
|
- this.changeFavicon(res.data.favicon);
|
|
|
- });
|
|
|
+ console.log(res)
|
|
|
+ this.title = res.data.title
|
|
|
+ this.bg = res.data.bg
|
|
|
+ this.logo = res.data.logo
|
|
|
+ document.title = res.data.title
|
|
|
+ this.changeFavicon(res.data.favicon)
|
|
|
+ })
|
|
|
},
|
|
|
// 更改favicon.icon
|
|
|
changeFavicon(link) {
|
|
|
- let $favicon = document.querySelector('link[rel="icon"]');
|
|
|
+ let $favicon = document.querySelector('link[rel="icon"]')
|
|
|
if ($favicon !== null) {
|
|
|
- $favicon.href = link;
|
|
|
+ $favicon.href = link
|
|
|
} else {
|
|
|
- $favicon = document.createElement("link");
|
|
|
- $favicon.rel = "icon";
|
|
|
- $favicon.href = link;
|
|
|
- document.head.appendChild($favicon);
|
|
|
+ $favicon = document.createElement('link')
|
|
|
+ $favicon.rel = 'icon'
|
|
|
+ $favicon.href = link
|
|
|
+ document.head.appendChild($favicon)
|
|
|
}
|
|
|
},
|
|
|
// 获取公告栏
|
|
|
systemNoticeGetNotice() {
|
|
|
systemNoticeGetNotice().then((res) => {
|
|
|
- this.noticeData = res.data;
|
|
|
- });
|
|
|
+ this.noticeData = res.data
|
|
|
+ })
|
|
|
},
|
|
|
showPwd() {
|
|
|
- if (this.passwordType === "password") {
|
|
|
- this.passwordType = "";
|
|
|
+ if (this.passwordType === 'password') {
|
|
|
+ this.passwordType = ''
|
|
|
} else {
|
|
|
- this.passwordType = "password";
|
|
|
+ this.passwordType = 'password'
|
|
|
}
|
|
|
this.$nextTick(() => {
|
|
|
- this.$refs.password.focus();
|
|
|
- });
|
|
|
+ this.$refs.password.focus()
|
|
|
+ })
|
|
|
},
|
|
|
handleLogin() {
|
|
|
this.$refs.loginForm.validate(async(valid) => {
|
|
|
if (valid) {
|
|
|
- this.loading = true;
|
|
|
+ this.loading = true
|
|
|
// this.$store
|
|
|
// .dispatch("user/login", this.loginForm)
|
|
|
// .then(() => {
|
|
@@ -200,16 +199,18 @@ export default {
|
|
|
try {
|
|
|
await this.$store.dispatch('user/login', this.loginForm)
|
|
|
await this.$store.dispatch('user/getInfo')
|
|
|
+ const openInOutStatistics = this.$store.getters.openInOutStatistics
|
|
|
+ const path = openInOutStatistics ? '/dashboard/index' : '/pass_records/index'
|
|
|
if (this.$store.getters.role === 1) {
|
|
|
- this.$router.push({ path: '/index' })
|
|
|
+ this.$router.push({ path })
|
|
|
} else if (this.$store.getters.role === 2) {
|
|
|
- this.$router.push({ path: '/index' })
|
|
|
+ this.$router.push({ path })
|
|
|
} else if (this.$store.getters.role === 3) {
|
|
|
- this.$router.push({ path: '/index' })
|
|
|
+ this.$router.push({ path })
|
|
|
} else if (this.$store.getters.role === 4) {
|
|
|
- this.$router.push({ path: '/index' })
|
|
|
+ this.$router.push({ path })
|
|
|
} else if (this.$store.getters.role === 5) {
|
|
|
- this.$router.push({ path: '/index' })
|
|
|
+ this.$router.push({ path })
|
|
|
} else if (this.$store.getters.role === 99) {
|
|
|
this.$router.push({ path: '/machine_list/index' })
|
|
|
}
|