修改统一身份认证

This commit is contained in:
chy
2026-03-02 10:33:39 +08:00
parent 458ac46ca4
commit a869e62351
6 changed files with 110 additions and 61 deletions

View File

@@ -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"'
}) })

View File

@@ -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',

View File

@@ -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 {

View File

@@ -259,7 +259,7 @@ export default {
}, },
// 列表查询 // 列表查询
async handleQueryPageList() { async handleQueryPageList() {
debugger
// 将特殊参数值urlcode处理 // 将特殊参数值urlcode处理
// 默认的排序 // 默认的排序
if ( if (

View File

@@ -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,12 +11,9 @@
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"
@@ -33,7 +28,7 @@
/> />
</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,7 +70,7 @@
<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"
@@ -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,7 +124,7 @@ export default {
redirect: undefined, redirect: undefined,
otherQuery: {}, otherQuery: {},
needCaptcha: false, needCaptcha: false,
centerDialogVisible: false centerDialogVisible: false,
}; };
}, },
watch: { watch: {
@@ -140,18 +137,35 @@ export default {
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;
debugger
let token = getToken();
console.log(ticket);
console.log(token);
if (ticket == undefined && token == null) {
//跳转统一身份认证
var isTs = true; var isTs = true;
if (isTs) { if (isTs) {
//window.location.href = 'http://127.0.0.1/login?redirect=/lig/oauth2/oauth2/application&appid=330b4ecb60c9a6802b957fe1e5a5ecd3&url=http://localhost:9528/#/login'; 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>
@@ -274,7 +317,6 @@ export default {
.el-input { .el-input {
display: inline-block; display: inline-block;
width: 100%; width: 100%;
} }
.el-form-item { .el-form-item {
@@ -365,7 +407,7 @@ 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;
@@ -380,7 +422,6 @@ export default {
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;

View File

@@ -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;