修改统一身份认证
This commit is contained in:
@@ -4,6 +4,6 @@ const prodEnv = require('./prod.env')
|
|||||||
|
|
||||||
module.exports = merge(prodEnv, {
|
module.exports = merge(prodEnv, {
|
||||||
NODE_ENV: '"development"',
|
NODE_ENV: '"development"',
|
||||||
// BASE_API: '"http://127.0.0.1:48090"'
|
BASE_API: '"http://127.0.0.1:48090"'
|
||||||
BASE_API: '"http://192.168.1.241:8080/prod-api"'
|
// BASE_API: '"http://192.168.1.241:8080/prod-api"'
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,6 +8,14 @@ export function login (data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function logincas (data) {
|
||||||
|
return request({
|
||||||
|
url: 'accessUser/logincas',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export function logout () {
|
export function logout () {
|
||||||
return request({
|
return request({
|
||||||
url: 'accessUser/logout',
|
url: 'accessUser/logout',
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ export default router
|
|||||||
const whiteList = ['/login', '/aj/**', '/el/**', '/bigscreen/viewer', '/excelreport/viewer']
|
const whiteList = ['/login', '/aj/**', '/el/**', '/bigscreen/viewer', '/excelreport/viewer']
|
||||||
// 判断是否需要登录权限 以及是否登录
|
// 判断是否需要登录权限 以及是否登录
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
|
|
||||||
NProgress.start()
|
NProgress.start()
|
||||||
let token = getToken();
|
let token = getToken();
|
||||||
let lideeUser = getAccessUser();
|
let lideeUser = getAccessUser();
|
||||||
@@ -18,6 +17,7 @@ router.beforeEach((to, from, next) => {
|
|||||||
next()
|
next()
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
|
|
||||||
if (whiteList.includes(to.path)) {
|
if (whiteList.includes(to.path)) {
|
||||||
next()
|
next()
|
||||||
}else {
|
}else {
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ export default {
|
|||||||
},
|
},
|
||||||
// 列表查询
|
// 列表查询
|
||||||
async handleQueryPageList() {
|
async handleQueryPageList() {
|
||||||
debugger
|
|
||||||
// 将特殊参数值urlcode处理
|
// 将特殊参数值urlcode处理
|
||||||
// 默认的排序
|
// 默认的排序
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="login_container">
|
<div class="login_container">
|
||||||
|
|
||||||
<div class="login_contant">
|
<div class="login_contant">
|
||||||
<img src="@/assets/images/login.jpg" alt="image" class="login_img" />
|
<img src="@/assets/images/login.jpg" alt="image" class="login_img" />
|
||||||
<el-form
|
<el-form
|
||||||
@@ -13,27 +11,24 @@
|
|||||||
label-position="left"
|
label-position="left"
|
||||||
@keyup.enter.native="handleLogin"
|
@keyup.enter.native="handleLogin"
|
||||||
>
|
>
|
||||||
<div class="title_container">
|
<div class="title_container">国瑞药业驾驶舱平台</div>
|
||||||
国瑞药业驾驶舱平台
|
<div style="height: 30px"></div>
|
||||||
</div>
|
|
||||||
<div style="height: 30px;"></div>
|
|
||||||
<div class="form_fields">
|
<div class="form_fields">
|
||||||
|
<el-form-item prop="loginName">
|
||||||
<el-form-item prop="loginName">
|
<el-input
|
||||||
<el-input
|
ref="loginName"
|
||||||
ref="loginName"
|
v-model="loginForm.loginName"
|
||||||
v-model="loginForm.loginName"
|
placeholder="用户名"
|
||||||
placeholder="用户名"
|
name="loginName"
|
||||||
name="loginName"
|
type="text"
|
||||||
type="text"
|
tabindex="1"
|
||||||
tabindex="1"
|
autocomplete="on"
|
||||||
autocomplete="on"
|
@focus="setTop('0')"
|
||||||
@focus="setTop('0')"
|
@change="getPsw"
|
||||||
@change="getPsw"
|
/>
|
||||||
/>
|
</el-form-item>
|
||||||
</el-form-item>
|
|
||||||
<div>
|
<div>
|
||||||
<div style="height: 20px;"></div>
|
<div style="height: 20px"></div>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
name="password"
|
name="password"
|
||||||
@@ -62,7 +57,7 @@
|
|||||||
@keyup.native="checkCapslock"
|
@keyup.native="checkCapslock"
|
||||||
/>
|
/>
|
||||||
<span class="show_pwd" @click="showPwd">
|
<span class="show_pwd" @click="showPwd">
|
||||||
<div style="height: 10px;"></div>
|
<div style="height: 10px"></div>
|
||||||
<i class="el-icon-view" />
|
<i class="el-icon-view" />
|
||||||
</span>
|
</span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -75,13 +70,13 @@
|
|||||||
<p>记住密码</p>
|
<p>记住密码</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="height: 30px;"></div>
|
<div style="height: 30px"></div>
|
||||||
<el-button
|
<el-button
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
type="primary"
|
type="primary"
|
||||||
class="login_btn"
|
class="login_btn"
|
||||||
@click.native.prevent="handleLogin"
|
@click.native.prevent="handleLogin"
|
||||||
>登 录</el-button
|
>登 录</el-button
|
||||||
>
|
>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
@@ -100,13 +95,13 @@
|
|||||||
import Verify from "@/components/verifition/Verify";
|
import Verify from "@/components/verifition/Verify";
|
||||||
import cookies from "js-cookie";
|
import cookies from "js-cookie";
|
||||||
import { Decrypt, Encrypt } from "@/utils/index";
|
import { Decrypt, Encrypt } from "@/utils/index";
|
||||||
import { login } from "@/api/login";
|
import { login, logincas } from "@/api/login";
|
||||||
import { transPsw } from "@/utils/encrypted";
|
import { transPsw } from "@/utils/encrypted";
|
||||||
import { setToken, setAccessUser } from "@/utils/auth";
|
import { setToken, getToken, setAccessUser } from "@/utils/auth";
|
||||||
export default {
|
export default {
|
||||||
name: "Login",
|
name: "Login",
|
||||||
components: {
|
components: {
|
||||||
Verify
|
Verify,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -115,11 +110,13 @@ export default {
|
|||||||
loginForm: {
|
loginForm: {
|
||||||
loginName: "",
|
loginName: "",
|
||||||
password: "",
|
password: "",
|
||||||
verifyCode: ""
|
verifyCode: "",
|
||||||
},
|
},
|
||||||
loginRules: {
|
loginRules: {
|
||||||
loginName: [{ required: true, message: "用户名必填", trigger: "blur" }],
|
loginName: [{ required: true, message: "用户名必填", trigger: "blur" }],
|
||||||
password: [{ required: true, message: "用户密码必填", trigger: "blur" }]
|
password: [
|
||||||
|
{ required: true, message: "用户密码必填", trigger: "blur" },
|
||||||
|
],
|
||||||
},
|
},
|
||||||
passwordType: "password",
|
passwordType: "password",
|
||||||
capsTooltip: false,
|
capsTooltip: false,
|
||||||
@@ -127,31 +124,48 @@ export default {
|
|||||||
redirect: undefined,
|
redirect: undefined,
|
||||||
otherQuery: {},
|
otherQuery: {},
|
||||||
needCaptcha: false,
|
needCaptcha: false,
|
||||||
centerDialogVisible: false
|
centerDialogVisible: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
$route: {
|
$route: {
|
||||||
// 监听路由获取上个路由(from)的地址和参数
|
// 监听路由获取上个路由(from)的地址和参数
|
||||||
handler: function(route) {
|
handler: function (route) {
|
||||||
const query = route.query;
|
const query = route.query;
|
||||||
if (query) {
|
if (query) {
|
||||||
this.redirect = query.redirect;
|
this.redirect = query.redirect;
|
||||||
this.otherQuery = this.getOtherQuery(query);
|
this.otherQuery = this.getOtherQuery(query);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
immediate: true
|
immediate: true,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.handleLoginFocus();
|
this.handleLoginFocus();
|
||||||
},
|
//获取url传参 ticket url
|
||||||
created() {
|
const ticket = this.$route.query.ticket;
|
||||||
var isTs=true;
|
debugger
|
||||||
if(isTs){
|
let token = getToken();
|
||||||
//window.location.href = 'http://127.0.0.1/login?redirect=/lig/oauth2/oauth2/application&appid=330b4ecb60c9a6802b957fe1e5a5ecd3&url=http://localhost:9528/#/login';
|
console.log(ticket);
|
||||||
|
console.log(token);
|
||||||
|
if (ticket == undefined && token == null) {
|
||||||
|
//跳转统一身份认证
|
||||||
|
var isTs = true;
|
||||||
|
if (isTs) {
|
||||||
|
debugger
|
||||||
|
//window.location.href = 'http://192.168.1.241/login?redirect=/lig/oauth2/oauth2/application&appid=330b4ecb60c9a6802b957fe1e5a5ecd3&url=http://192.168.1.241:8080/#/login';
|
||||||
|
window.location.href = 'http://127.0.0.1/login?redirect=/lig/oauth2/oauth2/application&appid=330b4ecb60c9a6802b957fe1e5a5ecd3&url=http://127.0.0.1:9528/#/login';
|
||||||
|
|
||||||
|
}
|
||||||
|
} else if (ticket != undefined && token == null) {
|
||||||
|
//请求登录
|
||||||
|
console.log(222222222);
|
||||||
|
this.logincasapi();
|
||||||
|
} else {
|
||||||
|
console.log(3333333);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
created() {},
|
||||||
methods: {
|
methods: {
|
||||||
handleLoginFocus() {
|
handleLoginFocus() {
|
||||||
if (this.loginForm.loginName === "") {
|
if (this.loginForm.loginName === "") {
|
||||||
@@ -187,7 +201,7 @@ export default {
|
|||||||
},
|
},
|
||||||
// 滑动验证码
|
// 滑动验证码
|
||||||
useVerify() {
|
useVerify() {
|
||||||
this.$refs.loginForm.validate(valid => {
|
this.$refs.loginForm.validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.$refs.verify.show();
|
this.$refs.verify.show();
|
||||||
} else {
|
} else {
|
||||||
@@ -204,7 +218,7 @@ export default {
|
|||||||
},
|
},
|
||||||
// 登录操作
|
// 登录操作
|
||||||
handleLogin() {
|
handleLogin() {
|
||||||
this.$refs.loginForm.validate(valid => {
|
this.$refs.loginForm.validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
// 登录失败次数过多需要展示滑动验证码
|
// 登录失败次数过多需要展示滑动验证码
|
||||||
@@ -218,11 +232,40 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
async logincasapi() {
|
||||||
|
const ticket = this.$route.query.ticket;
|
||||||
|
const obj = {
|
||||||
|
loginName: ticket,
|
||||||
|
password: "demo",
|
||||||
|
verifyCode: "",
|
||||||
|
};
|
||||||
|
const { code, data } = await logincas(obj);
|
||||||
|
this.loading = false;
|
||||||
|
if (code != "200") return;
|
||||||
|
setToken(data.token);
|
||||||
|
setAccessUser(data);
|
||||||
|
// 选中记住密码时 把密码存到cookie里,时效15天
|
||||||
|
this.rememberPsw &&
|
||||||
|
cookies.set(
|
||||||
|
`u_${this.loginForm.loginName}`,
|
||||||
|
Encrypt(this.loginForm.password),
|
||||||
|
{ expires: 15 }
|
||||||
|
);
|
||||||
|
if (data && data.captcha) {
|
||||||
|
this.needCaptcha = true;
|
||||||
|
} else {
|
||||||
|
this.needCaptcha = false;
|
||||||
|
this.$router.push({
|
||||||
|
path: this.redirect || "/index",
|
||||||
|
query: this.otherQuery,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
async loginApi() {
|
async loginApi() {
|
||||||
const obj = {
|
const obj = {
|
||||||
loginName: this.loginForm.loginName,
|
loginName: this.loginForm.loginName,
|
||||||
password: transPsw(this.loginForm.password),
|
password: transPsw(this.loginForm.password),
|
||||||
verifyCode: ""
|
verifyCode: "",
|
||||||
};
|
};
|
||||||
const { code, data } = await login(obj);
|
const { code, data } = await login(obj);
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
@@ -242,7 +285,7 @@ export default {
|
|||||||
this.needCaptcha = false;
|
this.needCaptcha = false;
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
path: this.redirect || "/index",
|
path: this.redirect || "/index",
|
||||||
query: this.otherQuery
|
query: this.otherQuery,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -253,8 +296,8 @@ export default {
|
|||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -266,15 +309,14 @@ export default {
|
|||||||
opacity: 10;
|
opacity: 10;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
}
|
}
|
||||||
.delete {
|
.delete {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.login_container {
|
.login_container {
|
||||||
.el-input {
|
.el-input {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-form-item {
|
.el-form-item {
|
||||||
@@ -351,7 +393,7 @@ export default {
|
|||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
//height: calc(100% - 60px);
|
//height: calc(100% - 60px);
|
||||||
height: 100%;
|
height: 100%;
|
||||||
.login_img {
|
.login_img {
|
||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -365,22 +407,21 @@ export default {
|
|||||||
min-width: 460px;
|
min-width: 460px;
|
||||||
width: 22%;
|
width: 22%;
|
||||||
height: 400px;
|
height: 400px;
|
||||||
background-color: #006DD9;
|
background-color: #006dd9;
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
padding: 30px;
|
padding: 30px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
.title_container {
|
.title_container {
|
||||||
position: relative;
|
position: relative;
|
||||||
font-size: 22px;
|
font-size: 22px;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.form_fields {
|
.form_fields {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
|
|
||||||
.show_pwd {
|
.show_pwd {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 10px;
|
right: 10px;
|
||||||
@@ -433,7 +474,7 @@ export default {
|
|||||||
.login_btn {
|
.login_btn {
|
||||||
min-width: 400px;
|
min-width: 400px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
background: #0BA1F8;
|
background: #0ba1f8;
|
||||||
border: none;
|
border: none;
|
||||||
// border-radius: 10px;
|
// border-radius: 10px;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export default {
|
|||||||
"background-attachment": "initial",
|
"background-attachment": "initial",
|
||||||
"background-origin": "initial",
|
"background-origin": "initial",
|
||||||
"background-clip": "initial",
|
"background-clip": "initial",
|
||||||
|
transform: `scale(${ratioEquipment}, ${ratioEquipment})`,
|
||||||
"transform-origin": "0 0"
|
"transform-origin": "0 0"
|
||||||
};
|
};
|
||||||
this.widgets = data.dashboard.widgets;
|
this.widgets = data.dashboard.widgets;
|
||||||
|
|||||||
Reference in New Issue
Block a user