zhgdyun/src/views/home/login_v1.vue
2022-09-30 15:10:32 +08:00

807 lines
23 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<!-- 登录 -->
<div>
<div class="login" v-if="projectType == 'common'">
<div class="title flex">
<div class="title_l flex2">
<img
v-if="systemInfo.loginLogo"
:src="systemInfo.loginLogo"
class="logo"
/>
<img
v-else-if="LOGO"
:src="'./img/logo/' + LOGO + '.png'"
class="logo"
/>
<span v-if="systemInfo.platformName && company != 'nanchang'">{{
systemInfo.platformName
}}</span
><!--智慧工地云平台-->
<span v-if="!systemInfo.platformName && company != 'nanchang'">{{
$t("message.login.title")
}}</span
><!--智慧工地云平台-->
<!-- 南昌地铁登录页不显示智慧工地云平台字样 -->
<span v-if="company == 'nanchang'"></span>
</div>
<div class="title_r">
<el-button
type="primary"
plain
size="small"
class="backBtn"
@click="goBackBtn"
>返回到首页</el-button
>
</div>
</div>
<div class="content flex2">
<img
class="contentBG"
v-if="systemInfo.loginBackgroundImage"
:src="systemInfo.loginBackgroundImage"
alt=""
/>
<img
class="contentBG"
v-else
src="../../assets/images/login_bg.webp"
alt=""
/>
<div class="login_info">
<div class="info_title flex">
<p
:class="loginType == 1 ? 'border_bottom' : 'placeholder'"
@click="
() => {
loginType = 1;
}
"
>
{{ $t("message.login.passwordLogin") }}
</p>
<p
:class="loginType == 2 ? 'border_bottom' : 'placeholder'"
@click="
() => {
loginType = 2;
}
"
>
{{ $t("message.login.sMSLogin") }}
</p>
</div>
<div class="info_content" v-show="loginType == 1">
<el-form :model="form" :rules="rules" ref="form" label-width="0px">
<el-form-item label="" prop="account">
<el-input
v-model="form.account"
style="height: 53px; font-size: 16px"
:placeholder="$t('message.login.account_placeholder')"
>
<img
slot="prefix"
src="../../assets/images/accountNumber.png"
class="inputIcon"
/>
</el-input>
</el-form-item>
<el-form-item style="margin-top: 25px" label="" prop="password">
<el-input
v-model="form.password"
style="height: 53px; font-size: 16px"
type="password"
:placeholder="$t('message.login.password_placeholder')"
@keyup.enter.native="loginFn"
>
<img
slot="prefix"
src="../../assets/images/password.png"
class="inputIcon"
/>
</el-input>
</el-form-item>
</el-form>
</div>
<div class="info_content" v-show="loginType == 2">
<el-form
:model="form2"
:rules="rules2"
ref="form2"
label-width="0px"
>
<el-form-item label="" prop="phone">
<el-input
v-model="form2.phone"
style="height: 53px; font-size: 16px"
:placeholder="$t('message.login.phone_placeholder')"
>
<img
slot="prefix"
src="../../assets/images/accountNumber.png"
class="inputIcon"
/>
</el-input>
</el-form-item>
<el-form-item
style="margin-top: 25px"
label=""
prop="verificationCode"
>
<el-input
v-model="form2.verificationCode"
style="height: 53px; font-size: 16px"
:placeholder="
$t('message.login.verificationCode_placeholder')
"
@keyup.enter.native="loginFn"
>
<img
slot="prefix"
src="../../assets/images/password.png"
class="inputIcon"
/>
<div slot="suffix" style="margin: 6px 10px 0 0">
<getcode :phone="form2.phone" type="theme2"></getcode>
</div>
</el-input>
</el-form-item>
</el-form>
</div>
<div style="margin-top: 25px">
<!-- <el-button type="success" plain class="logo_btn" :disabled="verificateBtn" @click="verificateFn"
>{{ verificateBtn==false?'立即点击验证':'验证成功'}}
</el-button> -->
<el-button type="success" v-if="verificateBtn==false" plain class="logo_btn" :disabled="verificateBtn" @click="verificateFn"
><div class="point"></div> 立即点击验证
</el-button>
<el-button type="success" v-else plain class="logo_btn" :disabled="verificateBtn"
><i class="el-icon-success"></i> 验证成功
</el-button>
</div>
<div style="margin-top: 25px">
<el-button type="primary" :disabled="pass" class="logo_btn" @click="loginFn"
>{{ $t("message.login.login") }}
</el-button>
</div>
<div class="info_bottom">
友情提示win7以上操作系统浏览器使用Chrome电脑屏幕分辩率>=1440X900达到最佳浏览视觉
</div>
<!-- <div class="info_bottom">为了平台效果展示更好请使用屏幕分辩率>=1440X900</div> -->
<div class="info_bottom flex" style="display: none">
<div
class="flex2"
@click="
() => {
automaticLogin = !this.automaticLogin;
}
"
>
<img
src="../../assets/images/no_checked.png"
v-if="!automaticLogin"
/>
<img
src="../../assets/images/checked.png"
v-if="automaticLogin"
/>
<span style="margin-left: 12px">{{
$t("message.login.automaticLogon")
}}</span>
</div>
<div>
<span style="margin-right: 5px">{{
$t("message.login.forgetThePassword")
}}</span>
<span class="span_placeholder"></span>
<el-button type="text" style="margin-left: 5px" @click="goSignIn">
{{ $t("message.login.clickRegister") }}
</el-button>
</div>
</div>
</div>
<!-- 滑动验证 -->
<div class="mask" v-if="showVerify" @click.self="showVerify = false">
<div class="slideContainer">
<slide-verify
:l="42"
:r="10"
:w="330"
:h="175"
slider-text="向右滑动滑块填充拼图"
ref="slideverify"
@success="onSuccess"
@fail="onFail"
@refresh="onRefresh"
></slide-verify>
</div>
</div>
</div>
</div>
<div class="zjsjLogin" v-if="projectType == 'zjsj'">
<div class="zjsjcontent">
<img
class="contentBGI"
src="../../assets/images/zjsj/zjsj_loginBgc.jpg"
alt=""
/>
<LoginInfo
class="leftContent"
ref="LoginInfo"
:form="form"
:rules="rules"
@loginFn="loginFn"
></LoginInfo>
</div>
</div>
</div>
</template>
<script>
import vueMatomo from "vue-matomo";
import {
loginPhoneApi,
loginApi,
getUserByUidApi,
companyLoginApi,
projectLoginApi,
} from "@/assets/js/api/loginSign";
import { selectSystemLogoConfigApi } from "@/assets/js/api/jxjadmin";
import getcode from "@/components/getMsgCode";
import { getOneComputerAuthApi } from "@/assets/js/api/loginSign";
import { selectNoticeRemindSoundApi } from "@/assets/js/api/configManage";
import LoginInfo from "./components/loginInfo.vue";
export default {
name: "login",
components: { getcode, LoginInfo },
data() {
return {
msg: '',
show: false,
showVerify:false,
verificateBtn:false,//验证按钮
pass:true,
input: "",
radio: "",
projectType: "",
LOGO: LOGO,
loginType: 1,
automaticLogin: false,
form: {
account: "",
password: "",
},
form2: {
phone: "",
verificationCode: "",
},
rules: {
account: [
{
required: true,
message: this.$t("message.login.rules.account_message"),
trigger: "blur",
},
],
password: [
{
required: true,
message: this.$t("message.login.rules.password_message"),
trigger: "blur",
},
],
},
rules2: {
phone: [
{
required: true,
message: this.$t("message.login.rules2.phone_message"),
trigger: "blur",
},
],
verificationCode: [
{
required: true,
message: this.$t("message.login.rules2.verificationCode_message"),
trigger: "blur",
},
],
},
systemInfo: {
loginBackgroundImage: "",
loginLogo: "",
platformLogo: "",
platformName: "",
},
};
},
watch: {
loginType(newDate, oldDate) {
console.log(newDate);
console.log(oldDate);
if (newDate === 1) {
window._paq.push(["trackEvent", "点击", "登录", "使用密码登录"]);
} else {
window._paq.push(["trackEvent", "点击", "登录", "使用账号登录"]);
}
},
},
created() {
this.company = COMPANY;
this.projectType = PROJECT_TYPE;
},
mounted() {
this.$bus.$on('resetSlideVerify',this.onReset)
delete this.$http.defaults.headers.common["Authorization"];
if (window.location.href.indexOf("type=lgzbdp") != -1) {
window.localStorage.setItem("isIframe", "1");
} else {
if (window.localStorage.getItem("isIframe")) {
window.localStorage.removeItem("isIframe");
}
}
//兼容第三方平台接入 ---做免码登录
if (window.location.href.indexOf("UID") != -1) {
// debugger;
this.$store.commit("setUid", true);
// let str = window.location.href.split("UID=")[1];
let uid = window.location.href.split("UID=")[1];
// let uid = str.substring(0, str.length - 7);
let data = {
uid,
};
//获取到用户信息
getUserByUidApi(data).then((res) => {
if (res.code == 200) {
//赋值
this.parseLoginData(res.result);
} else {
this.$message.error(res.message);
}
});
} else {
this.$store.commit("setUid", false);
this.getDetail();
this.getData();
}
},
methods: {
onReset() {
//重置图片验证组件
this.$refs.slideverify.reset();
},
onSuccess(){
setTimeout(()=>{
this.showVerify = false
this.verificateBtn = true
this.pass = false
},500)
},
onFail(){
this.msg = '验证失败'
},
onRefresh(){
this.msg = ''
},
getData() {
getOneComputerAuthApi().then((res) => {
if (res.result) {
} else {
this.$router.push({ path: "/authorization" });
}
});
},
getDetail() {
selectSystemLogoConfigApi().then((res) => {
if (res.result) {
console.log("查看有没有背景图", res);
console.log(window.location.protocol);
this.systemInfo = res.result;
if (this.systemInfo.loginLogo) {
this.systemInfo.loginLogo =
window.location.protocol +
"//" +
res.result.loginLogo.split("//")[1];
}
localStorage.setItem("systemInfo", JSON.stringify(res.result));
if (res.result.fileStorageType !== "0") {
this.$store.commit("setFILEURL", "");
}
}
});
},
goBackBtn() {
this.$router.push({ path: "/" });
},
goSignIn() {
this.$router.push({ path: "/sign" });
},
// 验证
verificateFn(){
this.showVerify = true,
this.$bus.$emit('resetSlideVerify')
},
loginFn() {
// 1系统管理员2企业管理员账号3企业区账号4企业市账号5项目账号 6项目子账号 7项目部账号
if (this.loginType == 1) {
this.$nextTick(() => {
if (this.projectType == "zjsj") {
this.$refs["LoginInfo"].$refs["form"].validate((valid) => {
// console.log("this.$refs['LoginInfo']:", this.$refs["LoginInfo"]);
if (valid) {
if (LOGINTYPE == 1) {
loginApi(this.form).then((res) => {
console.log("--------------------10");
console.log(res.result);
this.parseLoginData(res.result);
});
} else if (LOGINTYPE == 2) {
console.log(2222222222222);
companyLoginApi(this.form).then((res) => {
this.parseLoginData(res.result);
});
} else if (LOGINTYPE == 3) {
console.log(333333333);
projectLoginApi(this.form).then((res) => {
this.parseLoginData(res.result);
});
}
} else {
console.log("error submit!!");
return false;
}
});
} else if (this.projectType == "common") {
this.$refs["form"].validate((valid) => {
if (valid) {
if (LOGINTYPE == 1) {
loginApi(this.form).then((res) => {
console.log("--------------------10");
console.log(res.result);
this.parseLoginData(res.result);
});
} else if (LOGINTYPE == 2) {
console.log(2222222222222);
companyLoginApi(this.form).then((res) => {
this.parseLoginData(res.result);
});
} else if (LOGINTYPE == 3) {
console.log(333333333);
projectLoginApi(this.form).then((res) => {
this.parseLoginData(res.result);
});
}
} else {
console.log("error submit!!");
return false;
}
});
}
});
} else {
this.$refs["form2"].validate((valid) => {
if (valid) {
loginPhoneApi(this.form2).then((res) => {
this.parseLoginData(res.result);
});
} else {
console.log("error submit!!");
return false;
}
});
}
},
selectMp3FileList() {
selectNoticeRemindSoundApi({
projectSn: this.$store.state.projectSn,
}).then((res) => {
console.log(res);
if (res.code == 200) {
// this.MP4FileList = res.result
localStorage.setItem("soundList", JSON.stringify(res.result));
console.log(localStorage.getItem("soundList"));
}
});
},
parseLoginData(data) {
console.log("登录进来的data", data);
window._paq.push(["trackEvent", "点击", "登录", "登录账号"]);
this.$message.success(this.$t("message.login.login_success_msg")); //登录成功!
this.$http.defaults.headers.common["Authorization"] =
"Bearer" + " " + data.token;
this.$http.defaults.headers.common["operateId"] = data.userId;
this.$store.commit("setUserInfo", data);
var moduleList = data.menuAuthority.moduleList
? data.menuAuthority.moduleList
: [];
var companyModule = [];
if (moduleList.length == 0 && data.accountType != 1) {
this.$message.warning("当前账号还没分配权限");
return false;
}
moduleList.forEach((element) => {
if (element.moduleType == 1) {
companyModule.push(element);
}
});
var menu2 = [
{
menuName: "企业管理",
id: 9199,
path: "/registerAudit",
},
{
menuName: "模块菜单管理",
id: 9299,
path: "/moduleMenuManage",
},
{
menuName: "app版本管理",
id: 9297,
path: "/operateManage",
},
{
menuName: "塔吊模型管理",
id: 9298,
path: "/brand",
},
];
switch (data.accountType) {
case 1:
this.$store.commit("setMenuList", menu2);
this.$store.commit("setProjectManageMenuList", menu2);
console.log("-----------", menu2);
this.$store.commit("setIsShowBackIndex", false);
this.$router.push("/registerAudit");
break;
case 2:
this.$store.commit("setMenuList", companyModule);
this.$store.commit("setProjectManageMenuList", companyModule);
this.$store.commit("setIsShowBackIndex", false);
this.$router.push(companyModule[0].modulePath);
break;
case 3:
this.$store.commit("setMenuList", companyModule);
this.$store.commit("setProjectManageMenuList", companyModule);
this.$store.commit("setIsShowBackIndex", false);
this.$router.push(companyModule[0].modulePath);
break;
case 4:
this.$store.commit("setMenuList", companyModule);
this.$store.commit("setProjectManageMenuList", companyModule);
this.$store.commit("setIsShowBackIndex", false);
this.$router.push(companyModule[0].modulePath);
break;
case 7:
this.$store.commit("setMenuList", companyModule);
this.$store.commit("setProjectManageMenuList", companyModule);
this.$store.commit("setIsShowBackIndex", false);
this.$router.push(companyModule[0].modulePath);
break;
case 5:
// styleType == 3 衢州版
if (data.styleType == 1 || !data.styleType) {
this.$router.push("/projectIndex");
} else if (data.styleType == 2) {
this.$router.push("/projectV2/taskList");
} else {
this.$router.push("/projectV3/taskList");
}
this.$store.commit("setProjectSn", data.sn);
break;
case 6:
if (data.styleType == 1 || !data.styleType) {
this.$router.push("/projectIndex");
} else if (data.styleType == 2) {
this.$router.push("/projectV2/taskList");
} else {
this.$router.push("/projectV3/taskList");
}
this.$store.commit("setProjectSn", data.sn);
break;
}
this.selectMp3FileList();
},
},
};
</script>
<style lang="less" scoped>
.zjsjLogin {
width: 100%;
height: 100%;
.zjsjcontent {
width: 100%;
height: 100%;
position: relative;
.contentBGI {
width: 100%;
height: 100%;
}
}
}
.flex {
display: flex;
align-items: center;
justify-content: space-between;
}
.flex2 {
display: flex;
align-items: center;
}
.contentBG {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
}
.login {
width: 100%;
height: 100%;
background: #fff;
.title {
padding: 42px 35px 0;
font-family: PingFangSC-Semibold;
font-size: 24px;
color: @--color-black;
letter-spacing: 0;
.logo {
// width: 25px;
height: 37px;
margin-right: 20px;
}
.backBtn {
width: 114px;
font-size: 14px;
}
}
.content {
width: 100%;
height: 652px;
margin-top: 90px;
// background-image: url("../../assets/images/login_bg.png");
flex-direction: row-reverse;
position: relative;
.mask {
position: fixed;
left: 0%;
top: 0%;
width: 100%;
height: 100%;
z-index: 100;
overflow: hidden;
background-color: rgba(0, 0, 0, 0.3);
}
.mask .slideContainer {
display: flex;
justify-content: center;
align-items: center;
position: absolute;
left: 55%;
top: 50%;
transform: translate(-50%,-50%);
width: 380px;
height: 250px;
background-color: rgb(255, 255, 255);
}
.login_info {
width: 444px;
height: 445px;
background: #ffffff;
box-shadow: 0 0 31px 0 rgba(13, 28, 91, 0.28);
border-radius: 5px;
margin-right: 123px;
box-sizing: border-box;
padding: 37px 33.5px 0;
position: relative;
z-index: 2;
p {
width: 50%;
margin: 0;
box-sizing: border-box;
padding-bottom: 13px;
font-weight: 600;
}
.border_bottom {
border-bottom: 2px solid @--color-primary;
color: @--color-primary;
}
.placeholder {
padding: 0 0 15px;
}
.info_title {
justify-content: space-around;
font-family: PingFangSC-Medium;
font-size: 16px;
color: #aeafb9;
text-align: center;
cursor: pointer;
border-bottom: 1px solid #edeff2;
}
.info_content {
margin-top: 25px;
img {
width: 16.8px;
height: 24px;
}
}
.logo_btn {
height: 53px;
width: 100%;
font-family: PingFangSC-Regular;
font-size: 20px;
// .point::after{
// -webkit-animation-delay: .4s;
// animation-delay: .4s;
// }
// .point::before{
// content: "";
// display: block;
// width: 20px;
// height: 20px;
// background: #67c23a;
// position: absolute;
// left: 30%;
// // -webkit-animation: shield-breathing 1.4s ease infinite;
// // animation: shield-breathing 1.4s ease infinite;
// border-radius: 50%;
// }
}
.info_bottom {
font-family: PingFangSC-Regular;
font-size: 14px;
color: #8e8e8e;
cursor: pointer;
margin-top: 8px;
}
.span_placeholder {
display: inline-block;
width: 1px;
height: 15px;
margin-bottom: -3px;
background: rgba(142, 142, 142, 0.8);
}
/deep/ .el-input__inner {
height: 53px;
height: 53px;
padding-left: 45px;
}
}
}
}
.inputIcon {
margin-top: 14px;
margin-left: 10px;
}
.tipsBox {
text-align: center;
padding: 20px 0;
position: fixed;
left: 50%;
bottom: 0;
transform: translateX(-50%);
}
</style>