Compare commits
5 Commits
7c1f4911d2
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a81a41c78 | ||
|
|
feb1b2e8e9 | ||
|
|
281c6d71b2 | ||
|
|
adc41d5918 | ||
|
|
3c0b29333c |
10
src/App.vue
10
src/App.vue
@@ -1,19 +1,22 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="app" style="background-color:#0e2e87" v-if="$route.meta.bigScreen">
|
<div id="app" style="background-color:#0e2e87" v-if="$route.meta.bigScreen">
|
||||||
<router-view />
|
<router-view />
|
||||||
|
<global-loading ref="globalLoading" />
|
||||||
</div>
|
</div>
|
||||||
<div id="app" v-else>
|
<div id="app" v-else>
|
||||||
<router-view :key="language"/>
|
<router-view :key="language"/>
|
||||||
<theme-picker />
|
<theme-picker />
|
||||||
|
<global-loading ref="globalLoading" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ThemePicker from "@/components/ThemePicker";
|
import ThemePicker from "@/components/ThemePicker";
|
||||||
|
import GlobalLoading from '@/components/GlobalLoading'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "App",
|
name: "App",
|
||||||
components: { ThemePicker },
|
components: { ThemePicker, GlobalLoading },
|
||||||
metaInfo() {
|
metaInfo() {
|
||||||
return {
|
return {
|
||||||
title: this.$store.state.settings.dynamicTitle && this.$store.state.settings.title,
|
title: this.$store.state.settings.dynamicTitle && this.$store.state.settings.title,
|
||||||
@@ -26,9 +29,14 @@ export default {
|
|||||||
language(){
|
language(){
|
||||||
return this.$store.state.settings.language
|
return this.$store.state.settings.language
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
// 将loading方法挂载到全局,方便在任何组件中调用
|
||||||
|
this.$root.$loading = this.$refs.globalLoading
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
#app .theme-picker {
|
#app .theme-picker {
|
||||||
display: none;
|
display: none;
|
||||||
|
|||||||
@@ -186,3 +186,24 @@ export function changeLanguage(lang) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
export function logincas (data) {
|
||||||
|
return request({
|
||||||
|
url: '/logincas',
|
||||||
|
headers: {
|
||||||
|
isToken: false,
|
||||||
|
},
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function outlogcas (data) {
|
||||||
|
return request({
|
||||||
|
url: '/outlogcas',
|
||||||
|
headers: {
|
||||||
|
isToken: false,
|
||||||
|
},
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
83
src/components/GlobalLoading/index.vue
Normal file
83
src/components/GlobalLoading/index.vue
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
<template>
|
||||||
|
<div v-if="visible" class="global-loading">
|
||||||
|
<div class="loading-mask">
|
||||||
|
<div class="loading-content">
|
||||||
|
<div class="loading-spinner"></div>
|
||||||
|
<p class="loading-text">{{ text }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'GlobalLoading',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
visible: false,
|
||||||
|
text: '加载中...'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
show(text = '加载中...') {
|
||||||
|
this.text = text
|
||||||
|
this.visible = true
|
||||||
|
},
|
||||||
|
hide() {
|
||||||
|
this.visible = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.global-loading {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
z-index: 9999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-mask {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: rgba(0, 0, 0, 0.5);
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-content {
|
||||||
|
background: white;
|
||||||
|
padding: 20px 30px;
|
||||||
|
border-radius: 8px;
|
||||||
|
text-align: center;
|
||||||
|
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-spinner {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
margin: 0 auto 10px;
|
||||||
|
border: 3px solid #f3f3f3;
|
||||||
|
border-top: 3px solid #0f73ee;
|
||||||
|
border-radius: 50%;
|
||||||
|
animation: spin 1s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-text {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
0% { transform: rotate(0deg); }
|
||||||
|
100% { transform: rotate(360deg); }
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -39,6 +39,7 @@ import TopNav from '@/components/TopNav';
|
|||||||
import Hamburger from '@/components/Hamburger';
|
import Hamburger from '@/components/Hamburger';
|
||||||
import SizeSelect from '@/components/SizeSelect';
|
import SizeSelect from '@/components/SizeSelect';
|
||||||
import langSelect from '@/layout/components/langSelect';
|
import langSelect from '@/layout/components/langSelect';
|
||||||
|
import {outlogcas} from "@/api/login";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -72,18 +73,43 @@ export default {
|
|||||||
this.$store.dispatch('app/toggleSideBar');
|
this.$store.dispatch('app/toggleSideBar');
|
||||||
},
|
},
|
||||||
async logout() {
|
async logout() {
|
||||||
this.$confirm(this.$t('login.989807-31'), this.$t('login.989807-32'), {
|
try {
|
||||||
|
await this.$confirm(this.$t('login.989807-31'), this.$t('login.989807-32'), {
|
||||||
confirmButtonText: this.$t('confirm'),
|
confirmButtonText: this.$t('confirm'),
|
||||||
cancelButtonText: this.$t('cancel'),
|
cancelButtonText: this.$t('cancel'),
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
this.$store.dispatch('LogOut').then(() => {
|
|
||||||
location.href = '/index';
|
|
||||||
});
|
});
|
||||||
})
|
|
||||||
.catch(() => {});
|
// 先调用 CAS 退出接口
|
||||||
|
await this.outlogincasapi();
|
||||||
|
|
||||||
|
// 再执行 Store 退出
|
||||||
|
await this.$store.dispatch('LogOut');
|
||||||
|
|
||||||
|
// 清理本地存储
|
||||||
|
sessionStorage.clear();
|
||||||
|
localStorage.clear();
|
||||||
|
localStorage.setItem('is_logging_out', 'true');
|
||||||
|
// 跳转
|
||||||
|
// location.href = '/index';
|
||||||
|
window.location.href = 'http://192.168.1.241/login?redirect=/lig/oauth2/oauth2/application&appid=330b4ecb60c9a6802b957fe1e5a5ecd3&url=http%3A%2F%2F192.168.1.241%3A9000%2Flogin'+(this.redirect?'&ssUrl='+this.redirect:'');
|
||||||
|
// window.location.href = 'http://localhost:81/login?redirect=/lig/oauth2/oauth2/application&appid=330b4ecb60c9a6802b957fe1e5a5ecd3&url=http%3A%2F%2Flocalhost%3A80%2Flogin'+(this.redirect?'&ssUrl='+this.redirect:'');
|
||||||
|
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
// 用户取消或出错时的处理
|
||||||
|
console.log('退出取消或失败', error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async outlogincasapi() {
|
||||||
|
const obj = {
|
||||||
|
loginName: "admin",
|
||||||
|
password: "demo",
|
||||||
|
verifyCode: "",
|
||||||
|
};
|
||||||
|
const { code, data } = await outlogcas(obj);
|
||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import 'video.js/dist/video-js.css';
|
|||||||
import BaiduMap from 'vue-baidu-map'; // 百度地图
|
import BaiduMap from 'vue-baidu-map'; // 百度地图
|
||||||
|
|
||||||
import Contextmenu from 'vue-contextmenujs';
|
import Contextmenu from 'vue-contextmenujs';
|
||||||
|
import GlobalLoading from '@/components/GlobalLoading';
|
||||||
Vue.use(Contextmenu);
|
Vue.use(Contextmenu);
|
||||||
|
|
||||||
import ItemWrap from './views/bigScreen/components/item-wrap/item-wrap.vue';
|
import ItemWrap from './views/bigScreen/components/item-wrap/item-wrap.vue';
|
||||||
@@ -98,6 +99,7 @@ Vue.component('ImageUpload', ImageUpload);
|
|||||||
Vue.component('ImagePreview', ImagePreview);
|
Vue.component('ImagePreview', ImagePreview);
|
||||||
Vue.component('DictTag', DictTag);
|
Vue.component('DictTag', DictTag);
|
||||||
Vue.component('MonacoEditor', MonacoEditor);
|
Vue.component('MonacoEditor', MonacoEditor);
|
||||||
|
Vue.component('GlobalLoading', GlobalLoading);
|
||||||
Vue.use(plugins);
|
Vue.use(plugins);
|
||||||
Vue.use(directive);
|
Vue.use(directive);
|
||||||
Vue.use(VueMeta);
|
Vue.use(VueMeta);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import Cookies from 'js-cookie'
|
|||||||
|
|
||||||
const TokenKey = 'Admin-Token'
|
const TokenKey = 'Admin-Token'
|
||||||
const UserId = 'userId'
|
const UserId = 'userId'
|
||||||
|
const AccessUserKey = 'AJReportUser'
|
||||||
export function getToken() {
|
export function getToken() {
|
||||||
return Cookies.get(TokenKey)
|
return Cookies.get(TokenKey)
|
||||||
}
|
}
|
||||||
@@ -26,3 +26,16 @@ export function setUserId(userId) {
|
|||||||
export function removeUserId() {
|
export function removeUserId() {
|
||||||
return Cookies.remove(UserId)
|
return Cookies.remove(UserId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function setAccessUser(accessUser) {
|
||||||
|
if(typeof(accessUser) == "undefined" || accessUser== null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let val = accessUser;
|
||||||
|
if(typeof(accessUser) == "object"){
|
||||||
|
val = JSON.stringify(accessUser);
|
||||||
|
}
|
||||||
|
return localStorage.setItem(AccessUserKey, val)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<!-- 路由跳转 Loading 遮罩,解决闪屏 -->
|
||||||
<div class="login">
|
<div class="login">
|
||||||
<div class="main">
|
<div class="main">
|
||||||
<div v-if="acountLogin" class="container a-container" :class="{ 'is-txl': isATxl }">
|
<div v-if="acountLogin" class="container a-container" :class="{ 'is-txl': isATxl }">
|
||||||
@@ -9,7 +10,7 @@
|
|||||||
<el-form-item v-if="loginForm.bindId != null">
|
<el-form-item v-if="loginForm.bindId != null">
|
||||||
<div class="alert-box-wrap">
|
<div class="alert-box-wrap">
|
||||||
<div v-if="loginForm.bindId != null" class="alert-message-wrap">
|
<div v-if="loginForm.bindId != null" class="alert-message-wrap">
|
||||||
<i class="el-icon-warning" />
|
<i class="el-icon-warning"/>
|
||||||
{{ $t('login.989807-10') }}
|
{{ $t('login.989807-10') }}
|
||||||
</div>
|
</div>
|
||||||
<el-row>
|
<el-row>
|
||||||
@@ -32,24 +33,27 @@
|
|||||||
<el-form-item prop="username">
|
<el-form-item prop="username">
|
||||||
<div class="username">
|
<div class="username">
|
||||||
<i class="el-icon-user icon"></i>
|
<i class="el-icon-user icon"></i>
|
||||||
<input class="form__input" v-model="loginForm.username" auto-complete="off" type="text" :placeholder="$t('login.989807-4')" />
|
<input class="form__input" v-model="loginForm.username" auto-complete="off" type="text"
|
||||||
|
:placeholder="$t('login.989807-4')"/>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item prop="password" :class="{ 'is-null': isacount }">
|
<el-form-item prop="password" :class="{ 'is-null': isacount }">
|
||||||
<div class="password">
|
<div class="password">
|
||||||
<svg-icon icon-class="password" class="icon left" />
|
<svg-icon icon-class="password" class="icon left"/>
|
||||||
<input class="form__input" v-model="loginForm.password" auto-complete="off" :type="pwdtype" :placeholder="$t('login.989807-5')" @keyup.enter="handleLogin" />
|
<input class="form__input" v-model="loginForm.password" auto-complete="off" :type="pwdtype"
|
||||||
|
:placeholder="$t('login.989807-5')" @keyup.enter="handleLogin"/>
|
||||||
<span class="el-icon-view icon right" @click="changetype()"></span>
|
<span class="el-icon-view icon right" @click="changetype()"></span>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item v-if="captchaOnOff" prop="code" :class="{ 'is-null': ispwd }">
|
<el-form-item v-if="captchaOnOff" prop="code" :class="{ 'is-null': ispwd }">
|
||||||
<div style="width: 350px" class="check">
|
<div style="width: 350px" class="check">
|
||||||
<svg-icon icon-class="auth-code" class="icon" />
|
<svg-icon icon-class="auth-code" class="icon"/>
|
||||||
<input v-model="loginForm.code" auto-complete="off" class="form__input__code" type="text" :placeholder="$t('login.989807-6')" />
|
<input v-model="loginForm.code" auto-complete="off" class="form__input__code" type="text"
|
||||||
|
:placeholder="$t('login.989807-6')"/>
|
||||||
<div class="login-code">
|
<div class="login-code">
|
||||||
<img :src="codeUrl" @click="getCode" style="float: right" />
|
<img :src="codeUrl" @click="getCode" style="float: right"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -63,7 +67,8 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<!-- <button class="form__button button submit">登录</button> -->
|
<!-- <button class="form__button button submit">登录</button> -->
|
||||||
<el-button class="form__button button submit" v-if="!bindAccount" :loading="loading" type="primary" @click.native.prevent="handleLogin">
|
<el-button class="form__button button submit" v-if="!bindAccount" :loading="loading" type="primary"
|
||||||
|
@click.native.prevent="handleLogin">
|
||||||
<span v-if="!loading">{{ $t('login.989807-3') }}</span>
|
<span v-if="!loading">{{ $t('login.989807-3') }}</span>
|
||||||
<span v-else>{{ $t('login.989807-13') }}</span>
|
<span v-else>{{ $t('login.989807-13') }}</span>
|
||||||
</el-button>
|
</el-button>
|
||||||
@@ -81,8 +86,9 @@
|
|||||||
<!-- <span class="form__span">没有账号?立即注册</span> -->
|
<!-- <span class="form__span">没有账号?立即注册</span> -->
|
||||||
<el-form-item prop="phonenumber">
|
<el-form-item prop="phonenumber">
|
||||||
<div class="telphone" style="width: 350px">
|
<div class="telphone" style="width: 350px">
|
||||||
<svg-icon icon-class="phone" class="icon" />
|
<svg-icon icon-class="phone" class="icon"/>
|
||||||
<input v-model="smsLoginForm.phonenumber" class="form__input__code" type="text" auto-complete="off" :placeholder="$t('login.989807-8')" @input="validatePhoneNumber" />
|
<input v-model="smsLoginForm.phonenumber" class="form__input__code" type="text" auto-complete="off"
|
||||||
|
:placeholder="$t('login.989807-8')" @input="validatePhoneNumber"/>
|
||||||
<div class="sendcode">
|
<div class="sendcode">
|
||||||
<el-button
|
<el-button
|
||||||
slot="append"
|
slot="append"
|
||||||
@@ -100,26 +106,33 @@
|
|||||||
|
|
||||||
<el-form-item prop="smsCode">
|
<el-form-item prop="smsCode">
|
||||||
<div class="smscode" :class="{ 'is-null': isphone }">
|
<div class="smscode" :class="{ 'is-null': isphone }">
|
||||||
<svg-icon icon-class="password" class="icon" />
|
<svg-icon icon-class="password" class="icon"/>
|
||||||
<input class="form__input" type="password" v-model="smsLoginForm.smsCode" auto-complete="off" :placeholder="$t('login.989807-9')" />
|
<input class="form__input" type="password" v-model="smsLoginForm.smsCode" auto-complete="off"
|
||||||
|
:placeholder="$t('login.989807-9')"/>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<div class="other_login">
|
<div class="other_login">
|
||||||
<div class="wechat-login">
|
<div class="wechat-login">
|
||||||
<el-button v-if="loginForm.bindId == null" type="text" :wxloading="loading" @click.native.prevent="weChatLogin">
|
<el-button v-if="loginForm.bindId == null" type="text" :wxloading="loading"
|
||||||
<svg-icon icon-class="wechat" style="color: #07c160" />
|
@click.native.prevent="weChatLogin">
|
||||||
|
<svg-icon icon-class="wechat" style="color: #07c160"/>
|
||||||
{{ $t('login.989807-34') }}
|
{{ $t('login.989807-34') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div class="other-opt">
|
<div class="other-opt">
|
||||||
<router-link v-if="!bindAccount" style="font-size: 14px" :to="{ path: '/register', query: this.$route.query }">{{ $t('login.989807-35') }}</router-link>
|
<router-link v-if="!bindAccount" style="font-size: 14px"
|
||||||
<router-link v-else style="font-size: 14px" :to="{ path: '/register', query: this.$route.query }">{{ $t('login.989807-36') }}</router-link>
|
:to="{ path: '/register', query: this.$route.query }">{{ $t('login.989807-35') }}
|
||||||
|
</router-link>
|
||||||
|
<router-link v-else style="font-size: 14px" :to="{ path: '/register', query: this.$route.query }">
|
||||||
|
{{ $t('login.989807-36') }}
|
||||||
|
</router-link>
|
||||||
<langSelect style="margin-left: 12px"></langSelect>
|
<langSelect style="margin-left: 12px"></langSelect>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-button class="form__button button submit" type="primary" :smsLoading="loading" @click.native.prevent="handleSmsLogin">
|
<el-button class="form__button button submit" type="primary" :smsLoading="loading"
|
||||||
|
@click.native.prevent="handleSmsLogin">
|
||||||
<span v-if="!loading">{{ $t('login.989807-3') }}</span>
|
<span v-if="!loading">{{ $t('login.989807-3') }}</span>
|
||||||
<span v-else>{{ $t('login.989807-13') }}</span>
|
<span v-else>{{ $t('login.989807-13') }}</span>
|
||||||
</el-button>
|
</el-button>
|
||||||
@@ -133,7 +146,7 @@
|
|||||||
<h2 class="switch__title title" style="margin-left: 10px">{{ $t('login.989807-37') }}</h2>
|
<h2 class="switch__title title" style="margin-left: 10px">{{ $t('login.989807-37') }}</h2>
|
||||||
</div>
|
</div>
|
||||||
<p class="switch__description description">{{ $t('login.989807-38') }}</p>
|
<p class="switch__description description">{{ $t('login.989807-38') }}</p>
|
||||||
<img src="../assets/images/login3.jpeg" alt="logo" style="width: 220px; height: 220px" />
|
<img src="../assets/images/login3.jpeg" alt="logo" style="width: 220px; height: 220px"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -143,20 +156,30 @@
|
|||||||
<script>
|
<script>
|
||||||
import 'element-ui/lib/theme-chalk/display.css';
|
import 'element-ui/lib/theme-chalk/display.css';
|
||||||
import logo from '@/assets/logo/logo.gif';
|
import logo from '@/assets/logo/logo.gif';
|
||||||
import { getCodeImg, checkBindId, getErrorMsg, socialLogin, bindLogin, getSmsLoginCaptcha, smsLogin } from '@/api/login';
|
import {
|
||||||
|
getCodeImg,
|
||||||
|
checkBindId,
|
||||||
|
getErrorMsg,
|
||||||
|
socialLogin,
|
||||||
|
bindLogin,
|
||||||
|
getSmsLoginCaptcha,
|
||||||
|
smsLogin,
|
||||||
|
logincas
|
||||||
|
} from '@/api/login';
|
||||||
import Cookies from 'js-cookie';
|
import Cookies from 'js-cookie';
|
||||||
import { encrypt, decrypt } from '@/utils/jsencrypt';
|
import {encrypt, decrypt} from '@/utils/jsencrypt';
|
||||||
import { setToken } from '@/utils/auth';
|
import {setToken, getToken, setAccessUser} from '@/utils/auth';
|
||||||
import langSelect from '@/layout/components/langSelect';
|
import langSelect from '@/layout/components/langSelect';
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Login',
|
name: 'Login',
|
||||||
components: { langSelect },
|
components: {langSelect},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
windowWidth: window.innerWidth,
|
windowWidth: window.innerWidth,
|
||||||
acountLogin: true,
|
acountLogin: true,
|
||||||
phoneLogin: true,
|
phoneLogin: false,
|
||||||
//控制密码可见
|
//控制密码可见
|
||||||
pwdtype: 'password',
|
pwdtype: 'password',
|
||||||
isGx: false,
|
isGx: false,
|
||||||
@@ -202,20 +225,7 @@ export default {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
password: [
|
password: [
|
||||||
{ required: true, message: this.$t('login.989807-21'), trigger: 'blur' },
|
{required: true, message: this.$t('login.989807-21'), trigger: 'blur'},
|
||||||
// { min: 5, max: 20, message: this.$t('user.index.098976-35'), trigger: 'blur' },
|
|
||||||
// {
|
|
||||||
// trigger: 'blur',
|
|
||||||
// validator: (rule, value, callback) => {
|
|
||||||
// // 两种及以上
|
|
||||||
// var passwordreg = /(?![A-Z]*$)(?![a-z]*$)(?![0-9]*$)(?![^a-zA-Z0-9]*$)/;
|
|
||||||
// if (!passwordreg.test(value)) {
|
|
||||||
// callback(new Error(this.$t('system.dept.780956-30')));
|
|
||||||
// } else {
|
|
||||||
// callback();
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
],
|
],
|
||||||
code: [
|
code: [
|
||||||
{
|
{
|
||||||
@@ -227,7 +237,7 @@ export default {
|
|||||||
},
|
},
|
||||||
smsRules: {
|
smsRules: {
|
||||||
phonenumber: [
|
phonenumber: [
|
||||||
{ required: true, message: this.$t('login.989807-23'), trigger: 'blur' },
|
{required: true, message: this.$t('login.989807-23'), trigger: 'blur'},
|
||||||
{
|
{
|
||||||
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
|
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
|
||||||
message: this.$t('login.989807-24'),
|
message: this.$t('login.989807-24'),
|
||||||
@@ -242,13 +252,15 @@ export default {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
loading: false,
|
|
||||||
// 验证码开关
|
// 验证码开关
|
||||||
captchaOnOff: true,
|
captchaOnOff: true,
|
||||||
bindAccount: false,
|
bindAccount: false,
|
||||||
// 注册开关
|
// 注册开关
|
||||||
register: true,
|
register: true,
|
||||||
redirect: undefined,
|
redirect: undefined,
|
||||||
|
rememberPsw: false,
|
||||||
|
otherQuery: {},
|
||||||
|
loading: false, // 控制系统loading框
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@@ -262,6 +274,7 @@ export default {
|
|||||||
created() {
|
created() {
|
||||||
const loginId = this.$route.query.loginId;
|
const loginId = this.$route.query.loginId;
|
||||||
if (loginId === undefined || loginId === null) {
|
if (loginId === undefined || loginId === null) {
|
||||||
|
// 延迟执行这些方法,确保loading先显示
|
||||||
this.checkBind();
|
this.checkBind();
|
||||||
this.getCode();
|
this.getCode();
|
||||||
this.checkErrorMsg();
|
this.checkErrorMsg();
|
||||||
@@ -271,14 +284,100 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
// 优化:延迟执行登录相关逻辑,避免阻塞页面渲染
|
||||||
|
this.handleLoginFocus();
|
||||||
|
this.handleCASLogin();
|
||||||
this.checkDevice(); // 组件加载时检查设备
|
this.checkDevice(); // 组件加载时检查设备
|
||||||
window.addEventListener('resize', this.checkDevice); // 添加resize事件监听
|
window.addEventListener('resize', this.checkDevice); // 添加resize事件监听
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
window.removeEventListener('resize', this.checkDevice); // 清除事件监听
|
window.removeEventListener('resize', this.checkDevice); // 清除事件监听
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
// 优化:提取CAS登录逻辑到单独方法
|
||||||
|
handleCASLogin() {
|
||||||
|
const ticket = this.$route.query.ticket;
|
||||||
|
const isLoggingOut = localStorage.getItem('is_logging_out') === 'true';
|
||||||
|
const token = getToken();
|
||||||
|
|
||||||
|
if (!ticket && !token) {
|
||||||
|
// 如果是登出后返回,清除标记并停止
|
||||||
|
if (isLoggingOut) {
|
||||||
|
localStorage.removeItem('is_logging_out');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 没有ticket且没有token,跳转统一身份认证
|
||||||
|
const isTs = true;
|
||||||
|
if (isTs) {
|
||||||
|
window.location.href = 'http://192.168.1.241/login?redirect=/lig/oauth2/oauth2/application&appid=330b4ecb60c9a6802b957fe1e5a5ecd3&url=http%3A%2F%2F192.168.1.241%3A9000%2Flogin'+(this.redirect?'&ssUrl='+this.redirect:'');
|
||||||
|
// window.location.href = 'http://localhost:81/login?redirect=/lig/oauth2/oauth2/application&appid=330b4ecb60c9a6802b957fe1e5a5ecd3&url=http%3A%2F%2Flocalhost%3A80%2Flogin' + (this.redirect ? '&ssUrl=' + this.redirect : '');
|
||||||
|
}
|
||||||
|
} else if (ticket && !token) {
|
||||||
|
// 有ticket但没有token,请求登录
|
||||||
|
this.logincasapi();
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handleLoginFocus() {
|
||||||
|
if (this.loginForm.loginName === "") {
|
||||||
|
if (this.$refs.loginName) {
|
||||||
|
this.$refs.loginName.focus();
|
||||||
|
}
|
||||||
|
} else if (this.loginForm.password === "") {
|
||||||
|
if (this.$refs.password) {
|
||||||
|
this.$refs.password.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 优化:CAS登录方法
|
||||||
|
async logincasapi() {
|
||||||
|
const ticket = this.$route.query.ticket;
|
||||||
|
if (!ticket) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const obj = {
|
||||||
|
loginName: ticket,
|
||||||
|
password: "demo",
|
||||||
|
verifyCode: "",
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const {code, data, token} = await logincas(obj);
|
||||||
|
|
||||||
|
if (code !== 200) {
|
||||||
|
this.$message.error('CAS登录失败: ' + (data?.msg || '未知错误'));
|
||||||
|
// 清除ticket参数,避免循环跳转
|
||||||
|
this.$router.push({
|
||||||
|
path: '/login',
|
||||||
|
query: {redirect: this.redirect}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setToken(token || data.token);
|
||||||
|
setAccessUser(data);
|
||||||
|
|
||||||
|
// 跳转到目标页面,清除ticket参数
|
||||||
|
const targetPath = this.redirect || "/";
|
||||||
|
this.$router.push({
|
||||||
|
path: targetPath,
|
||||||
|
query: this.otherQuery,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
// 优化:移除不必要的console.error
|
||||||
|
/* console.error('CAS登录错误:', error);
|
||||||
|
console.error('错误详情:', error.response || error.message); */
|
||||||
|
this.$message.error('CAS登录失败,请检查后端CAS配置');
|
||||||
|
// 清除ticket参数,避免循环跳转
|
||||||
|
this.$router.push({
|
||||||
|
path: '/login',
|
||||||
|
query: {redirect: this.redirect}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
changesmsForm() {
|
changesmsForm() {
|
||||||
this.acountLogin = !this.acountLogin;
|
this.acountLogin = !this.acountLogin;
|
||||||
this.phoneLogin = !this.phoneLogin;
|
this.phoneLogin = !this.phoneLogin;
|
||||||
@@ -331,7 +430,8 @@ export default {
|
|||||||
.push({
|
.push({
|
||||||
path: this.redirect || '/',
|
path: this.redirect || '/',
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {
|
||||||
|
});
|
||||||
if (this.captchaOnOff) {
|
if (this.captchaOnOff) {
|
||||||
this.getCode();
|
this.getCode();
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
@@ -362,9 +462,10 @@ export default {
|
|||||||
const errorId = this.$route.query.errorId;
|
const errorId = this.$route.query.errorId;
|
||||||
if (errorId !== undefined && errorId !== null) {
|
if (errorId !== undefined && errorId !== null) {
|
||||||
getErrorMsg(errorId)
|
getErrorMsg(errorId)
|
||||||
.then((res) => {})
|
.then((res) => {
|
||||||
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
this.$router.push({ query: {} });
|
this.$router.push({query: {}});
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -453,7 +554,8 @@ export default {
|
|||||||
.push({
|
.push({
|
||||||
path: '/',
|
path: '/',
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -486,7 +588,8 @@ export default {
|
|||||||
.push({
|
.push({
|
||||||
path: '/',
|
path: '/',
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
@@ -541,7 +644,8 @@ export default {
|
|||||||
.push({
|
.push({
|
||||||
path: this.redirect || '/',
|
path: this.redirect || '/',
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
@@ -1192,4 +1296,6 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 路由跳转 Loading 样式 */
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user