<template>
|
<div class v-loading="vLoading" :style="`width: ${currentWidth}px;height:${currentHeight}px`">
|
<div class="web-site">
|
<a href="http://www.smartai.com" target="_blank">www.smartai.com</a>
|
</div>
|
<licence />
|
<div class="right-bg" style>
|
<particle-network />
|
</div>
|
<div class="left-bg">
|
<div class="login-logo">
|
<img src="/images/login-logo.png" alt width="105px" height="105px" />
|
</div>
|
<div class="login-com">
|
<span>北京贝思科技术有限公司</span>
|
</div>
|
<div class="login-form">
|
<el-form
|
:model="user"
|
status-icon
|
:rules="nullRule"
|
:validate-on-rule-change="false"
|
ref="ruleForm"
|
class="demo-ruleForm"
|
>
|
<el-form-item prop="loginName">
|
<el-input v-model="user.loginName" style="width:280px" placeholder="请输入用户名">
|
<i slot="prefix" class="iconfont iconyonghu1"></i>
|
</el-input>
|
</el-form-item>
|
<el-form-item prop="password">
|
<el-input
|
show-password
|
@keyup.enter.native="systemLogin()"
|
v-model="user.password"
|
autocomplete="off"
|
style="width:280px"
|
placeholder="请输入密码"
|
>
|
<i slot="prefix" class="iconfont iconmima"></i>
|
</el-input>
|
</el-form-item>
|
<el-form-item>
|
<el-button ref="submit" type="warning" @click="systemLogin()" style="width:280px">登录</el-button>
|
</el-form-item>
|
</el-form>
|
</div>
|
<!-- <p class="gradient-text gradient-text-one">——— {{serverTitle || 'SmartAI — ReID'}} ———</p> -->
|
<p class="gradient-text gradient-text-one">—— <b>SmartAI</b> 人工智能操作系统 ——</p>
|
<p class="gradient-text gradient-text-one" style="letter-spacing: 1.8px;font-size:15px;"> V1.0.0 </p>
|
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import { tologin, getLoginUserData, getServerName } from './api.ts'
|
import ParticleNetwork from './ParticleNetwork'
|
import Licence from '@/components/licence'
|
import { getMenuListData, findButtonAuthoritys, findInArr } from "@/api/utils";
|
|
export default {
|
name: 'login-pgae',
|
metaInfo: {
|
title: '登录页'
|
},
|
components: {
|
ParticleNetwork,
|
Licence
|
},
|
data: () => ({
|
serverTitle: "",
|
user: {
|
loginName: '',
|
password: '',
|
rememberMe: false
|
},
|
nullRule: {},
|
rules: {
|
loginName: [
|
{ required: true, message: '请输入用户名', trigger: 'change' }
|
],
|
password: [{ required: true, message: '请输入密码', trigger: 'change' }]
|
},
|
loading: '',
|
vLoading: false,
|
currentHeight: 1057,
|
currentWidth: 1920
|
}),
|
created() {
|
this.getServerName()
|
this.getScreenHeight()
|
},
|
mounted() {
|
console.log(this.serverTitle)
|
},
|
watch: {},
|
beforeDestroy() {
|
window.onresize = null
|
},
|
methods: {
|
systemLogin() {
|
this.nullRule = this.rules
|
this.$nextTick(() => {
|
this.$refs['ruleForm'].validate(valid => {
|
if (valid) {
|
this.loading = this.$loading({
|
lock: true,
|
text: 'Loading',
|
spinner: 'el-icon-loading',
|
background: 'rgba(0, 0, 0, 0.7)'
|
})
|
this.testLogin()
|
// return false
|
} else {
|
this.nullRule = {}
|
}
|
})
|
this.nullRule = {}
|
})
|
},
|
async testLogin() {
|
tologin({ username: this.user.loginName, password: this.user.password })
|
.then(json => {
|
// console.log(json, "登录请求");
|
const loginedInfo = {
|
access_token: json.token_type + ' ' + json.access_token,
|
refresh_token: json.refresh_token
|
}
|
sessionStorage.setItem('expires_in', json.expires_in)
|
sessionStorage.setItem('loginedInfo', JSON.stringify(loginedInfo))
|
this.loading.close()
|
this.getLoginUserData()
|
})
|
.catch(err => {
|
// console.log(err, "登录报错");
|
this.loading.close()
|
this.$notify({
|
title: '提示',
|
type: 'error',
|
message: err
|
})
|
this.$refs.pwd.focus()
|
})
|
},
|
async getLoginUserData() {
|
let json = await getLoginUserData()
|
if (!json.error) {
|
// this.loading.close()
|
sessionStorage.setItem('userInfo', JSON.stringify(json))
|
this.$notify({
|
title: '提示',
|
type: 'success',
|
message: '登录成功!'
|
})
|
|
// 获取权限
|
await this.getMenuList()
|
location.assign("/view/desktop/")
|
return json
|
} else {
|
this.$notify({
|
title: '提示',
|
type: 'error',
|
message: '登录失败!'
|
})
|
// this.loading.close()
|
}
|
},
|
|
getScreenHeight() {
|
this.currentHeight = document.documentElement.clientHeight
|
this.currentWidth = document.documentElement.clientWidth
|
// console.log(this.currentHeight, "当前窗口大小");
|
window.onresize = () => {
|
this.currentHeight = document.documentElement.clientHeight
|
this.currentWidth = document.documentElement.clientWidth
|
// console.log(this.currentHeight, "当前窗口大小2", this.currentWidth);
|
this.$forceUpdate()
|
}
|
},
|
async getServerName() {
|
let res = await getServerName()
|
if (res && res.success) {
|
console.log(res.data.serverName)
|
this.serverTitle = res.data.serverName
|
window.document.title = res.data.serverName
|
? res.data.serverName
|
: 'SmartAI'
|
sessionStorage.setItem('title', res.data.serverName)
|
}
|
},
|
async getMenuList() {
|
let results = await getMenuListData({});
|
if (results && results.success) {
|
/* 存储权限 */
|
let buttonAuthoritys = results.data;
|
// console.log(this.$route.query.is_loginsss)
|
if (results && results.length && this.$route.query.is_login) {
|
this.$router.replace(results[0].url);
|
}
|
sessionStorage.setItem("buttonAuthoritys", "," + buttonAuthoritys + ",");
|
sessionStorage.setItem("menuInfo", JSON.stringify(results));
|
} else {
|
this.$toast({
|
type: "error",
|
message: "菜单获取失败"
|
});
|
}
|
},
|
},
|
}
|
</script>
|
<style lang="scss">
|
.right-bg {
|
position: fixed;
|
top: 0;
|
left: 0;
|
background-image: url("/images/login-net.png");
|
|
width: 100%;
|
height: 100%;
|
min-width: 1000px;
|
z-index: -10;
|
zoom: 1;
|
background-color: #fff;
|
background-repeat: no-repeat;
|
background-size: cover;
|
-webkit-background-size: cover;
|
-o-background-size: cover;
|
background-position: center 0;
|
}
|
.web-site {
|
position: absolute;
|
top: 55px;
|
left: 41px;
|
font-family: PingFangSC-Medium;
|
font-size: 20px;
|
color: #6170e1;
|
letter-spacing: 6.15px;
|
}
|
.left-bg {
|
position: absolute;
|
top: 29%;
|
right: 18%;
|
width: 390px;
|
height: 426px;
|
background: rgba(146, 208, 255, 0.23);
|
border-radius: 4px;
|
text-align: center;
|
.login-logo {
|
margin-top: -53px;
|
}
|
|
.login-com {
|
font-family: PingFangSC-Medium;
|
font-size: 22px;
|
color: #ffffff;
|
letter-spacing: 0.44px;
|
margin: 15px;
|
}
|
.login-form {
|
margin: 40px 10px;
|
// margin: 24px 10px 40px 10px;
|
}
|
.gradient-text {
|
line-height: 36px;
|
font-size: 17px;
|
font-family: -webkit-pictograph;
|
font-weight: bolder;
|
position: relative;
|
b{
|
font-size: 20px;
|
}
|
}
|
.gradient-text-one {
|
background-image: linear-gradient(to right, #51feff 5%, #ff8725 100%);
|
-webkit-background-clip: text;
|
-webkit-text-fill-color: transparent;
|
}
|
|
.el-input__prefix {
|
left: 8px;
|
}
|
|
.el-form-item__error {
|
left: 54px;
|
}
|
}
|
</style>
|