feat: 修改登录页面 调试单点登录

This commit is contained in:
wangsongsole 2023-03-14 11:06:25 +08:00
parent 2014e172af
commit b2a6982c37
2 changed files with 149 additions and 174 deletions

View File

@ -1,43 +1,163 @@
import React, { Component } from "react";
import "./login.less";
import "@/assets/comm.css";
import LoginForm from "./loginform";
import LoginPhone from "./loginPhone";
import React, { Component } from "react";
import {
getAllEnum,
handelResponse,
getProductInfoSelect,
postLoginCode,
getVoucherWarningAccount
} from "@/assets/api.js";
import { Notify, BlockLoading } from "zent";
export default class App extends Component {
constructor(props) {
super(props);
window["react"] = this;
}
state = {
pathname: "",
loginWay: 1
authorization: ""
};
componentWillMount() {
const pathname = window.location.href.lastIndexOf("/");
const pathnamestr = window.location.href.substr(pathname);
this.setState({ pathname: `${pathnamestr}` });
const tokenString = this.props.location.search;
const authorization = tokenString.substring(tokenString.indexOf("=") + 1);
if (tokenString) {
this.setState({ authorization });
this.onSubmit();
return;
}
this.toUnifiedLogin();
}
logintype(type) {
this.setState({ loginWay: type });
/* 跳转统一登录平台 */
toUnifiedLogin() {
setTimeout(() => {
window.location.href =
"http://192.168.7.199:4000/#/login?url=http://192.168.7.199:3000/#/";
}, 1500);
}
//获取预警人权限
getAccountList() {
getVoucherWarningAccount().then((res) => {
if (!res) {
sessionStorage.setItem("isEarlyWarningMan", false);
} else {
sessionStorage.setItem("isEarlyWarningMan", true);
}
});
}
onSubmit() {
let subdata = {
authorization: this.state.authorization
};
postLoginCode(subdata)
.then((res) => {
handelResponse(
res,
(response, msg) => {
sessionStorage.setItem("authorization", response.authorization);
Notify.clear();
Notify.success(msg);
getAllEnum().then((res) => {
handelResponse(res, (response, msg) => {
sessionStorage.setItem("enmu", JSON.stringify(response));
});
});
this.getProductList();
this.getAccountList();
sessionStorage.setItem("showflag", true);
let menuList = response.menu;
if (response.menu && response.menu.length > 0) {
sessionStorage.setItem(
"activeMenu",
JSON.stringify(response.menu)
);
let market = menuList.filter((item) => item.id == 16);
if (market && market[0].children.length > 0) {
//菜单有营销计划
sessionStorage.setItem("linkshowname", "营销计划管理");
sessionStorage.setItem("pathname2", "/home/plan-list");
sessionStorage.setItem(
"menulinklist",
JSON.stringify(market[0].children)
);
setTimeout(() => {
this.props.history.replace("/home/plan-list");
}, 1000);
} else {
try {
menuList.forEach((item) => {
if (item.children && item.children.length > 0) {
item.children.forEach((it) => {
if (it.level == 5) {
sessionStorage.setItem("pathname2", it.router);
sessionStorage.setItem("linkshowname", item.title);
sessionStorage.setItem(
"menulinklist",
JSON.stringify(item.children)
);
setTimeout(() => {
this.props.history.replace(it.router);
}, 1000);
throw "终止循环";
}
});
} else {
Notify.clear();
Notify.warn("请先联系管理员配置权限菜单");
}
});
} catch (e) {}
}
} else {
Notify.clear();
Notify.warn("请先联系管理员配置权限菜单");
}
},
(err) => {
if (res.code == -2) {
this.toUnifiedLogin();
Notify.error(res.message);
} else {
this.toUnifiedLogin();
Notify.clear();
Notify.error(res.message);
}
}
);
})
.catch((err) => {});
}
/* 获取商品 */
getProductList() {
getProductInfoSelect().then((res) => {
handelResponse(
res,
(req, msg) => {
sessionStorage.setItem("updatetime", Date.now());
sessionStorage.setItem("productsList", JSON.stringify(req.data));
},
(err) => {}
);
});
}
render() {
return (
<div className='loginPage'>
<div className='login-title'>
<div className='login-title-icon'>
<img src='https://lsxdemall.oss-cn-beijing.aliyuncs.com/Marketing/logo.svg' />
</div>
<div className='login-title-label'>营销管理系统</div>
</div>
<div className='login-box'>
<div className='box-title'>
<div>
<span onClick={() => this.logintype(1)}>账号密码登录</span>
{/* <span className={this.state.loginWay==2?'activeLogin':''} onClick={()=>this.logintype(2)}>验证码登录</span> */}
</div>
</div>
{this.state.loginWay == 1 ? <LoginForm /> : <LoginPhone />}
</div>
<BlockLoading
className='loading'
icon='circle'
iconText='努力跳转中...'
loading
iconSize={30}
/>
</div>
);
}

View File

@ -1,158 +1,13 @@
.loginPage {
width: 100%;
height: 100%;
background-color: #f5f9ff;
// background-color: #f5f9ff;
overflow: hidden;
.zent-form-reactive {
width: 60% !important;
}
.login-box .zent-input-wrapper.zent-input--size-normal,
.login-box .zent-input {
width: 100% !important;
border-radius: 4px;
}
}
.login-title {
width: 400px;
height: 40px;
margin: 80px auto;
display: flex;
align-items: center;
justify-content: center;
}
.login-title-label {
font-size: 32px;
}
.login-title-icon img {
width: auto;
height: 40px;
padding-right: 20px;
}
.login-box {
margin: 0 auto;
width: 520px;
background-color: #fff;
box-sizing: border-box;
overflow: hidden;
border-radius: 8px;
box-shadow: 0px 0px 5px rgba(0, 60, 179, 0.12);
text-align: center;
display: flex;
justify-content: center;
flex-wrap: wrap;
align-items: center;
transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
&:hover {
box-shadow: 0px 0px 20px rgba(0, 60, 179, 0.12);
transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1)
.loading {
width: 200px;
}
.zent-input-wrapper.zent-input--size-normal,
.zent-input {
width: 268px !important;
height: 40px !important;
}
.zent-btn-disabled[data-zv="9.11.0"],
.zent-btn-disabled[data-zv="9.11.0"][disabled] {
background-color: #f7f7f7 !important;
border: 1px solid #e0e0e0 !important;
}
}
.loginBtn {
width: 100% !important;
width: 272px;
height: 41px;
line-height: 41px;
color: #FFF;
background-color: #1e6fff;
border: none;
outline: none;
border-radius: 2px;
text-align: center;
font-size: 17px;
text-align: center;
cursor: pointer;
margin-bottom: 70px;
margin-top: 5px;
.login-Btntxt {
display: inline-block;
letter-spacing: 50px;
text-indent: 50px;
}
}
.box-title {
width: 100%;
height: 52px;
font-size: 20px;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 40px;
border-bottom: 1px solid rgba(44, 114, 255, 0.1);
}
.box-title>div {
width: 60%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.box-title>div span {
cursor: pointer;
height: 100%;
display: flex;
border-bottom: 2px solid transparent;
align-items: center;
&.activeLogin {
color: #1e6fff;
border-bottom: 2px solid #1e6fff;
}
}
.yzmcodeIpt {
height: 40px;
.zent-form-control[data-zv="9.11.0"] {
float: left;
}
margin-bottom: 30px;
display: flex;
}
.yzmcode {
width: 38%;
height: 40px;
float: left;
.zent-btn {
height: 100% !important;
width: 100%;
}
}
.forget {
text-align: right;
display: block;
margin-bottom: 10px;
margin-top: 30px;
color: #1e6fff;
cursor: pointer;
}