Commit d45dbd0b by 张杰

Merge branch 'dev_zj_1.7.0' into 'v1.7.0'

优化登录页面,兼容手机端

See merge request !9
2 parents f54e4ebc a5ee353a

682 KB | W: | H:

440 KB | W: | H:

src/assets/images/car-bg.png
src/assets/images/car-bg.png
src/assets/images/car-bg.png
src/assets/images/car-bg.png
  • 2-up
  • Swipe
  • Onion skin
<template> <template>
<el-container class="container"> <el-container class="container">
<home-header></home-header> <!-- <home-header></home-header>
<home-content></home-content> <home-content></home-content>
<home-footer></home-footer> <home-footer></home-footer> -->
<div class="login_page">
<div class="login_header">
<img class="home-logo-img" :src="logoPath" :key="logoPath" alt="company-logo">
<span class="home-logo-title">{{ homeTitle }}</span>
</div>
<div class="login_box">
<div class="left"></div>
<div class="right">
<div class="login_card">
<div class="small_logo">
<img class="home-logo-img" :src="logo" :key="logo" alt="company-logo" />
</div>
<h1 class="login-title">{{title}}</h1>
<div v-if="showAlert">
<el-alert v-for="(item, index) in alertArr" :key="index" :title="item" type="error" show-icon />
</div>
<el-form>
<el-form-item class="username-wrapper" prop="name">
<el-input class="login-input username-input" 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>
<el-form-item class="login-button-wrapper" @keyup.enter="handleSubmit" @click.native.prevent="handleSubmit">
<el-button class="login-button" type="primary" html-type="submit">
登录
</el-button>
</el-form-item>
</el-form>
</div>
</div>
</div>
<div class="login_footer">
Copyright ©2012-2021 粤ICP备12034057号 深圳广联赛讯有限公司 版权所有
</div>
</div>
</el-container> </el-container>
</template> </template>
<script> <script>
import HomeHeader from 'components/Header/HomeHeader'; import HomeHeader from "components/Header/HomeHeader";
import HomeContent from 'components/HomeContent/HomeContent'; import HomeContent from "components/HomeContent/HomeContent";
import HomeFooter from 'components/Footer/HomeFooter'; import HomeFooter from "components/Footer/HomeFooter";
import { onMounted } from 'vue'; import {
onMounted,
watch,
reactive,
toRefs,
getCurrentInstance,
onBeforeMount,
} from "vue";
import { useStore } from "vuex";
import LoginService from "@/services/Login";
import { trimSpace } from "@/utils/tools/tools";
export default { export default {
name: "LoginPage", name: "LoginPage",
components: { components: {
HomeHeader, HomeHeader,
HomeContent, HomeContent,
HomeFooter HomeFooter,
},
setup() {
const store = useStore();
const state = reactive({
logoPath: store.state.app.logo,
homeTitle: "",
alertMsg: "",
showAlert: false,
alertArr: [],
randomVal: "0",
formInline: {
user: "",
password: "",
captcha: "",
}, },
setup () { title: store.state.app.title,
onMounted(() => { logo: store.state.app.logo,
}); });
let logoPath = store.state.app.logo;
const { ctx: _this } = getCurrentInstance();
const loginService = new LoginService();
onBeforeMount(() => {
document.onkeydown = (e) => {
if (e.keyCode === 13) {
handleSubmit();
} }
} };
});
// 登录提交验证 用户名只限制长度50 验证码暂时屏蔽
const handleSubmit = async () => {
const value = state.formInline,
captchaId = state.captchaId,
{ user, password, captcha } = value;
state.alertArr = [];
state.showAlert = false;
if (trimSpace(user).length <= 0) {
state.alertArr.push("请输入用户名");
state.showAlert = true;
return false;
}
// if(!validate_username(user)) {
// state.alertArr.push('用户名格式不正确');
// state.showAlert = true;
// return false;
// }
if (trimSpace(password).length <= 0) {
state.alertArr.push("请输入密码");
state.showAlert = true;
return false;
}
// if(trimSpace(captcha).length <= 0) {
// state.alertArr.push('请输入验证码');
// state.showAlert = true;
// return false;
// }
// params: captcha, captchaId 验证码暂时屏蔽
store.dispatch("app/showLoading", true);
const params = { account: user, password };
await loginService.loginAction(params).then(
(res) => {
store.dispatch("app/showLoading", false);
if (res.code === 200) {
const { token, user } = res.data;
store.dispatch("app/setUserInfo", user);
store.dispatch("app/setToken", token);
} else {
const { message } = res;
state.alertArr.push(message);
state.showAlert = true;
store.dispatch("app/showLoading", false);
}
},
(err) => {
store.dispatch("app/showLoading", false);
}
);
};
watch(
() => store.state.app.logo,
(n, o) => {
state.logoPath = n;
console.log("logoPath:", n);
}
);
watch(
() => store.state.app.logo,
(n, o) => {
state.logo = n;
}
);
watch(
() => store.state.app.title,
(n, o) => {
state.title = n;
}
);
console.log(logoPath);
return { ...toRefs(state), handleSubmit };
},
};
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
@import 'styles/variables.less'; @import "styles/variables.less";
.container { // .container {
position: fixed; // position: fixed;
height: 100%; // height: 100%;
top: 0; // top: 0;
left: 0; // left: 0;
// width: 100%;
// min-width: 1190px;
// overflow-y: scroll;
// }
.login_page {
height: 100vh;
width: 100%;
display: flex;
flex-direction: column;
.login_header {
height: 60px;
}
.login_box {
width: 100%;
height: calc(100vh - 120px);
//background: url("../../assets/images/car-bg.png") no-repeat;
background: url("../assets/images/car-bg.png") no-repeat;
background-size: cover;
display: flex;
justify-content: space-between;
.right{
flex:2;
display:flex;
align-items: center;
justify-content: flex-end;
padding:0 60px 0 0;
}
.login_card {
background-color: #fff;
background-clip: border-box;
border-radius: 4px;
width: 410px;
padding: 45px;
box-sizing: border-box;
.home-logo-img {
max-width: 100%;
height: 50px;
}
.login-title {
height: 55px;
font-size: 22px;
color: #333;
font-weight: bold;
}
.login-input {
width: 100%; width: 100%;
min-width: 1190px; border:0;
overflow-y: scroll; }
.login-button-wrapper {
margin-top: 45px;
.login-button {
width: 100%;
height: 40px;
background-color: #003457;
border-color: transparent;
}
}
}
}
.login_footer {
height: 60px;
line-height: 60px;
font-size: 12px;
text-align: center;
color: #999;
}
}
</style>
<style scoped>
.login_box >>> .el-input__inner {
border: none;
border-radius: 0;
border-bottom: 1px solid #97979742;
}
.login_box >>> .el-input__inner:-webkit-autofill {
-webkit-box-shadow: 0 0 0px 1000px #fff inset;
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!