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