Commit cdebe64f by jack

动态根据域名更换logo

1 parent 840fc479
No preview for this file type
<template> <template>
<div class="home-logo-wrapper"> <div class="home-logo-wrapper">
<img class="home-logo-img" src="@/assets/images/company-logo-sub.png" alt="home-logo" > <!-- <img class="home-logo-img" src="@/assets/images/company-logo-sub.png" alt="home-logo" > -->
<img class="home-logo-img" :src="smallLogo" alt="home-logo" >
<!-- <img v-show="collapsed" class="home-logo-img home-thumbnail-logo" src="@/assets/images/logo-thumbnail.png" alt="home-logo" > --> <!-- <img v-show="collapsed" class="home-logo-img home-thumbnail-logo" src="@/assets/images/logo-thumbnail.png" alt="home-logo" > -->
</div> </div>
</template> </template>
...@@ -14,7 +15,8 @@ ...@@ -14,7 +15,8 @@
// collapsed: Boolean // collapsed: Boolean
// }, // },
setup () { setup () {
const smallLogo = localStorage.getItem('smallLogo');
return {smallLogo}
} }
} }
</script> </script>
......
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
.header { .header {
width: 100%; width: 100%;
height: 139px !important; height: auto !important;
padding: 45px 50px 0 50px; padding: 20px 50px 0 50px;
background-color: #fff; background-color: #fff;
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
<template> <template>
<div class="home-logo-wrapper"> <div class="home-logo-wrapper">
<img class="home-logo-img" src="@/assets/images/company-logo.png" alt="company-logo"> <!-- <img class="home-logo-img" src="@/assets/images/company-logo.png" alt="company-logo"> -->
<img class="home-logo-img" :src="logoPath" alt="company-logo">
<span class="home-logo-title">{{ homeTitle }}</span> <span class="home-logo-title">{{ homeTitle }}</span>
</div> </div>
</template> </template>
...@@ -12,8 +13,8 @@ ...@@ -12,8 +13,8 @@
name: 'Logo', name: 'Logo',
setup () { setup () {
const homeTitle = ref(''); const homeTitle = ref('');
const logoPath = localStorage.getItem('logo')
return { homeTitle }; return { homeTitle,logoPath };
} }
} }
</script> </script>
...@@ -24,7 +25,8 @@ ...@@ -24,7 +25,8 @@
font-size: 20px; font-size: 20px;
.home-logo-img { .home-logo-img {
width: 480px; //width: 480px;
height:67px;
margin-right: 10px; margin-right: 10px;
} }
......
<template> <template>
<div class="login-form-wrapper"> <div class="login-form-wrapper">
<div class="login-content"> <div class="login-content">
<div class="login-card-left"> <div class="login-card-left">
<login-left-side></login-left-side> <login-left-side></login-left-side>
</div>
<div class="login-card">
<!-- <img class="home-logo-img" src="@/assets/images/company-logo.png" alt="company-logo"> -->
<div>
<img class="home-logo-img" :src="logo" alt="company-logo" />
</div> </div>
<div class="login-card"> <h1 class="login-title">{{title}}</h1>
<img class="home-logo-img" src="@/assets/images/company-logo.png" alt="company-logo"> <div v-if="showAlert">
<h1 class="login-title">试乘试驾管理平台</h1> <el-alert v-for="(item, index) in alertArr" :key="index" :title="item" type="error" show-icon />
<div v-if="showAlert"> </div>
<el-alert v-for="(item, index) in alertArr" <el-form>
:key="index" <el-form-item class="username-wrapper" prop="name">
:title="item" type="error" show-icon /> <el-input class="login-input username-input" placeholder="请输入用户名" maxLength="50" v-model="formInline.user">
</div> </el-input>
<el-form> </el-form-item>
<el-form-item <el-form-item class="form-wrapper pwd-wrapper" prop="pass">
class="username-wrapper" <el-input class="login-input" placeholder="请输入密码" v-model="formInline.password" maxLength="20" show-password autocomplete="off">
prop="name"> </el-input>
<el-input </el-form-item>
class="login-input username-input" <!-- <a-form-item class="form-wrapper captcha-wrapper">
placeholder="请输入用户名"
maxLength="50"
v-model="formInline.user">
</el-input>
</el-form-item>
<el-form-item
class="form-wrapper pwd-wrapper"
prop="pass">
<el-input
class="login-input"
placeholder="请输入密码"
v-model="formInline.password"
maxLength="20"
show-password
autocomplete="off">
</el-input>
</el-form-item>
<!-- <a-form-item class="form-wrapper captcha-wrapper">
<a-input class="login-input" size="large" :max="6" v-model:value="formInline.captcha" placeholder="验证码"></a-input> <a-input class="login-input" size="large" :max="6" v-model:value="formInline.captcha" placeholder="验证码"></a-input>
<div class="captcha-content" @click="updateCaptcha"> <div class="captcha-content" @click="updateCaptcha">
<img class="captcha-img" :src="`data:image/jpeg;base64,${captchaUrl}`" alt="验证码" /> <img class="captcha-img" :src="`data:image/jpeg;base64,${captchaUrl}`" alt="验证码" />
</div> </div>
</a-form-item> --> </a-form-item> -->
<el-form-item class="login-button-wrapper" @keyup.enter="handleSubmit" @click.native.prevent="handleSubmit"> <el-form-item class="login-button-wrapper" @keyup.enter="handleSubmit" @click.native.prevent="handleSubmit">
<el-button <el-button class="login-button" type="primary" html-type="submit">
class="login-button" 登录
type="primary" </el-button>
html-type="submit" </el-form-item>
> </el-form>
登录 </div>
</el-button>
</el-form-item>
</el-form>
</div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import LoginLeftSide from './LoginLeftSide'; import LoginLeftSide from "./LoginLeftSide";
import { trimSpace, validate_username, import { trimSpace, validate_username, debounce } from "@/utils/tools/tools";
debounce } from '@/utils/tools/tools'; import LoginService from "@/services/Login";
import LoginService from '@/services/Login';
// import { UserOutlined, LockOutlined } from '@ant-design/icons-vue'; // import { UserOutlined, LockOutlined } from '@ant-design/icons-vue';
import { reactive, toRefs, getCurrentInstance, computed, onBeforeMount } from 'vue'; import {
import { useStore } from 'vuex'; reactive,
import { useRouter } from 'vue-router'; toRefs,
getCurrentInstance,
computed,
onBeforeMount,
} from "vue";
import { useStore } from "vuex";
import { useRouter } from "vue-router";
export default { export default {
components: { components: {
...@@ -75,43 +63,43 @@ export default { ...@@ -75,43 +63,43 @@ export default {
// UserOutlined, // UserOutlined,
// LockOutlined, // LockOutlined,
}, },
setup(props, {attrs, emit, slots}) { setup(props, { attrs, emit, slots }) {
const router = useRouter(); const router = useRouter();
const store = useStore(); const store = useStore();
const state = reactive({ const state = reactive({
// captchaUrl: '', // captchaUrl: '',
// captchaId: '', // 后台需要的字段 // captchaId: '', // 后台需要的字段
alertMsg: '', alertMsg: "",
showAlert: false, showAlert: false,
alertArr: [], alertArr: [],
randomVal: '0', randomVal: "0",
formInline: { formInline: {
user: '', user: "",
password: '', password: "",
captcha: '', captcha: "",
} },
}); });
const { ctx: _this } = getCurrentInstance() const { ctx: _this } = getCurrentInstance();
const loginService = new LoginService(); const loginService = new LoginService();
onBeforeMount(()=>{ onBeforeMount(() => {
document.onkeydown = e => { document.onkeydown = (e) => {
if (e.keyCode === 13) { if (e.keyCode === 13) {
handleSubmit() handleSubmit();
} }
} };
}) });
const validatePass = (rule, value, callback) => { const validatePass = (rule, value, callback) => {
if (value === '') { if (value === "") {
callback(new Error('请输入密码')); callback(new Error("请输入密码"));
} else { } else {
if (state.ruleForm.checkPass !== '') { if (state.ruleForm.checkPass !== "") {
// this.$refs.ruleForm.validateField('checkPass'); // this.$refs.ruleForm.validateField('checkPass');
} }
callback(); callback();
} }
} };
// const getCaptcha = () => { // const getCaptcha = () => {
// // 初始化获取验证码 // // 初始化获取验证码
...@@ -130,14 +118,14 @@ export default { ...@@ -130,14 +118,14 @@ export default {
// 登录提交验证 用户名只限制长度50 验证码暂时屏蔽 // 登录提交验证 用户名只限制长度50 验证码暂时屏蔽
const handleSubmit = async () => { const handleSubmit = async () => {
const value = state.formInline, const value = state.formInline,
captchaId = state.captchaId, captchaId = state.captchaId,
{ user, password, captcha } = value; { user, password, captcha } = value;
state.alertArr = []; state.alertArr = [];
state.showAlert = false; state.showAlert = false;
if(trimSpace(user).length <= 0) { if (trimSpace(user).length <= 0) {
state.alertArr.push('请输入用户名'); state.alertArr.push("请输入用户名");
state.showAlert = true; state.showAlert = true;
return false; return false;
} }
...@@ -148,8 +136,8 @@ export default { ...@@ -148,8 +136,8 @@ export default {
// return false; // return false;
// } // }
if(trimSpace(password).length <= 0) { if (trimSpace(password).length <= 0) {
state.alertArr.push('请输入密码'); state.alertArr.push("请输入密码");
state.showAlert = true; state.showAlert = true;
return false; return false;
} }
...@@ -160,23 +148,26 @@ export default { ...@@ -160,23 +148,26 @@ export default {
// return false; // return false;
// } // }
// params: captcha, captchaId 验证码暂时屏蔽 // params: captcha, captchaId 验证码暂时屏蔽
store.dispatch('app/showLoading', true); store.dispatch("app/showLoading", true);
const params = { account: user, password}; const params = { account: user, password };
await loginService.loginAction(params).then((res) => { await loginService.loginAction(params).then(
store.dispatch('app/showLoading', false); (res) => {
if(res.code === 200) { store.dispatch("app/showLoading", false);
const { token, user } = res.data; if (res.code === 200) {
store.dispatch('app/setUserInfo', user); const { token, user } = res.data;
store.dispatch('app/setToken', token); store.dispatch("app/setUserInfo", user);
} else { store.dispatch("app/setToken", token);
const { message } = res; } else {
state.alertArr.push(message); const { message } = res;
state.showAlert = true; state.alertArr.push(message);
store.dispatch('app/showLoading', false); state.showAlert = true;
store.dispatch("app/showLoading", false);
}
},
(err) => {
store.dispatch("app/showLoading", false);
} }
}, (err) => { );
store.dispatch('app/showLoading', false);
})
}; };
// 点击刷新验证码 // 点击刷新验证码
...@@ -184,12 +175,17 @@ export default { ...@@ -184,12 +175,17 @@ export default {
// getCaptcha(); // getCaptcha();
// }, 1000, true); // }, 1000, true);
const logo = localStorage.getItem("logo");
const title = localStorage.getItem('title')
return { return {
...toRefs(state), ...toRefs(state),
handleSubmit, handleSubmit,
logo,
title
// updateCaptcha // updateCaptcha
} };
} },
}; };
</script> </script>
<style scoped> <style scoped>
...@@ -203,7 +199,7 @@ export default { ...@@ -203,7 +199,7 @@ export default {
} }
</style> </style>
<style lang="less" scoped> <style lang="less" scoped>
@import 'styles/mixins.less'; @import "styles/mixins.less";
.login-form-wrapper { .login-form-wrapper {
margin-top: 100px; margin-top: 100px;
...@@ -216,77 +212,74 @@ export default { ...@@ -216,77 +212,74 @@ export default {
} }
.login-card { .login-card {
position: relative; position: relative;
display: -webkit-box; display: -webkit-box;
display: -ms-flexbox; display: -ms-flexbox;
.flex-column; .flex-column;
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
-webkit-box-direction: normal; -webkit-box-direction: normal;
min-width: 0; min-width: 0;
word-wrap: break-word; word-wrap: break-word;
background-color: #fff; background-color: #fff;
background-clip: border-box; background-clip: border-box;
border-left: none; border-left: none;
border-radius: 4px; border-radius: 4px;
max-width: 320px; max-width: 320px;
min-width: 320px; min-width: 320px;
padding: 45px; padding: 45px;
margin-left: 50px; margin-left: 50px;
.el-alert { .el-alert {
margin-bottom: 15px; margin-bottom: 15px;
} }
.home-logo-img {
margin-bottom: 15px;
}
.login-title { .home-logo-img {
height: 55px; max-width:100%;
font-size: 22px; height: 50px;
color: #333; //margin-bottom: 15px;
font-weight: bold; }
}
.login-input { .login-title {
} height: 55px;
font-size: 22px;
color: #333;
font-weight: bold;
}
.username-input { .username-input {
margin-top: 0; margin-top: 0;
} }
.captcha-wrapper { .captcha-wrapper {
.v-center; .v-center;
justify-content: space-between; justify-content: space-between;
.login-input { .login-input {
width: 200px; width: 200px;
} }
.captcha-content { .captcha-content {
flex: 1; flex: 1;
margin-top: 30px; margin-top: 30px;
height: 40px; height: 40px;
cursor: pointer; cursor: pointer;
.captcha-img { .captcha-img {
width: 100%; width: 100%;
height: 100%; height: 100%;
}
} }
} }
}
.login-button-wrapper {
margin-top: 45px;
.login-button-wrapper { .login-button {
margin-top: 45px; width: 100%;
.login-button { height: 40px;
width: 100%; background-color: #003457;
height: 40px; border-color: transparent;
background-color: #003457;
border-color: transparent;
}
} }
}
} }
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -4,14 +4,33 @@ import router from './router' ...@@ -4,14 +4,33 @@ import router from './router'
import store from './store' import store from './store'
import elementUI from '@/utils/globalUI/element' import elementUI from '@/utils/globalUI/element'
import 'element-plus/lib/theme-chalk/index.css'
import 'element-plus/lib/theme-chalk/index.css';
// import './assets/css/resets.css' // import './assets/css/resets.css'
const app = createApp(App); const app = createApp(App)
const URL =
'https://oss-config.test.glsx.com.cn/mock/5be17454f31545347559d499/config'
const getConfig = (url = URL + '/e-sheild-portal-config') => {
return new Promise((resolve) => {
const xhr = new XMLHttpRequest()
xhr.onreadystatechange = () => {
if (xhr.readyState === 4 && xhr.status === 200) {
let o = xhr.responseText ? JSON.parse(xhr.responseText) : {}
console.log(o.logo)
localStorage.setItem('logo', o.logo)
localStorage.setItem('title', o.title)
localStorage.setItem('smallLogo',o.smallLogo)
// window.localStorage.setItem(
// 'GLSX_COMMODITY_CENTER_CONFIG',
// xhr.responseText,
// )
}
}
xhr.open('GET', url)
xhr.send()
})
}
app.use(store) getConfig()
.use(router)
.use(elementUI)
.mount('#app');
\ No newline at end of file \ No newline at end of file
app.use(store).use(router).use(elementUI).mount('#app')
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!