feat: 新增备用登录路由

This commit is contained in:
wangsongsole 2023-03-17 18:22:28 +08:00
parent 065e302f67
commit 7ed34f7548
6 changed files with 300 additions and 292 deletions

View File

@ -1,24 +1,25 @@
import React, { Component } from 'react'
import { HashRouter as Router, Route } from 'react-router-dom'
import './App.css'
import './assets/comm.css'
import { Redirect } from 'react-router-dom'
import { lazy, Suspense } from 'react'
import { FullScreenLoading } from 'zent'
const Home = lazy(() => import('./pages/home/home'))
const Login = lazy(() => import('./pages/login/login'))
const ErrPage = lazy(() => import('./pages/errpage/errpage'))
import React, { Component } from 'react';
import { HashRouter as Router, Route } from 'react-router-dom';
import './App.css';
import './assets/comm.css';
import { Redirect } from 'react-router-dom';
import { lazy, Suspense } from 'react';
import { FullScreenLoading } from 'zent';
const Home = lazy(() => import('./pages/home/home'));
const LoginOrigin = lazy(() => import('./pages/login/login-origin'));
const Login = lazy(() => import('./pages/login/login'));
const ErrPage = lazy(() => import('./pages/errpage/errpage'));
const EdittemPlate = lazy(() =>
import('./pages/exchangepage/edittemplate/main.js')
)
);
export default class App extends Component {
state = {
pathname: ''
}
};
componentWillMount() {
const pathname = window.location.href.lastIndexOf('/')
const pathnamestr = window.location.href.substr(pathname)
this.setState({ pathname: `${pathnamestr}` })
const pathname = window.location.href.lastIndexOf('/');
const pathnamestr = window.location.href.substr(pathname);
this.setState({ pathname: `${pathnamestr}` });
}
render() {
@ -29,6 +30,7 @@ export default class App extends Component {
<FullScreenLoading loading icon='circle' iconText='加载中...' />
}>
<Route path='/login' exact={true} component={Login} />
<Route path='/login-standby' exact={true} component={LoginOrigin} />
<Route path='/edittemplate' exact={true} component={EdittemPlate} />
<Route path='/home' component={Home} />
<Route
@ -38,6 +40,6 @@ export default class App extends Component {
<Route component={ErrPage} />
</Suspense>
</Router>
)
);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,19 @@
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 './login-origin.less';
import '@/assets/comm.css';
import LoginForm from './loginform';
import LoginPhone from './loginPhone';
export default class App extends Component {
constructor(props) {
super(props);
window["react"] = this;
window['react'] = this;
}
state = {
pathname: "",
pathname: '',
loginWay: 1
};
componentWillMount() {
const pathname = window.location.href.lastIndexOf("/");
const pathname = window.location.href.lastIndexOf('/');
const pathnamestr = window.location.href.substr(pathname);
this.setState({ pathname: `${pathnamestr}` });
}
@ -22,7 +22,7 @@ export default class App extends Component {
}
render() {
return (
<div className='loginPage'>
<div className='loginPage-origin'>
<div className='login-title'>
<div className='login-title-icon'>
<img src='https://lsxdemall.oss-cn-beijing.aliyuncs.com/Marketing/logo.svg' />

View File

@ -1,4 +1,4 @@
.loginPage {
.loginPage-origin {
width: 100%;
height: 100%;
background-color: #f5f9ff;

View File

@ -148,7 +148,7 @@ export default class App extends Component {
<BlockLoading
className='loading'
icon='circle'
iconText='拼命跳转中...'
iconText='拼命跳转中 ····'
loading
iconSize={30}
/>

View File

@ -1,16 +1,16 @@
import React, { useEffect, useRef } from "react";
import "./login.less";
import { withRouter } from "react-router-dom";
import "@/assets/comm.css";
import React, { useEffect, useRef } from 'react';
import './login.less';
import { withRouter } from 'react-router-dom';
import '@/assets/comm.css';
import {
postLogin,
getAllEnum,
handelResponse,
getProductInfoSelect,
postsendLoginCode,
postLoginCode,
postLoginStandby,
getVoucherWarningAccount
} from "@/assets/api.js";
} from '@/assets/api.js';
import {
FormInputField,
Form,
@ -18,20 +18,20 @@ import {
Validators,
Button,
Notify
} from "zent";
} from 'zent';
function FormDom(props) {
const form = Form.useForm(FormStrategy.View);
const [disabled, setDisabled] = React.useState(true);
const [yzmcode, setYzmcode] = React.useState(false); //控制图形验证码
const [acc, setAcc] = React.useState("");
const [pwd, setPwd] = React.useState("");
const [piccode, setPiccode] = React.useState("");
const [smscode, setSmscode] = React.useState("获取验证码");
const [uniquestr, setUniquestr] = React.useState("");
const [auth, setAuth] = React.useState("");
const [acc, setAcc] = React.useState('');
const [pwd, setPwd] = React.useState('');
const [piccode, setPiccode] = React.useState('');
const [smscode, setSmscode] = React.useState('获取验证码');
const [uniquestr, setUniquestr] = React.useState('');
const [auth, setAuth] = React.useState('');
const [Imgstr, setImgstr] = React.useState("");
const [Imgstr, setImgstr] = React.useState('');
const code_unique_str = useRef(uniquestr);
code_unique_str.current = uniquestr;
@ -41,9 +41,9 @@ function FormDom(props) {
const getAccountList = () => {
getVoucherWarningAccount().then((res) => {
if (!res) {
sessionStorage.setItem("isEarlyWarningMan", false);
sessionStorage.setItem('isEarlyWarningMan', false);
} else {
sessionStorage.setItem("isEarlyWarningMan", true);
sessionStorage.setItem('isEarlyWarningMan', true);
}
});
};
@ -53,42 +53,42 @@ function FormDom(props) {
code: value.notecode,
authorization: authorizationCode.current
};
postLoginCode(subdata)
postLoginStandby(subdata)
.then((res) => {
handelResponse(
res,
(response, msg) => {
sessionStorage.setItem("authorization", response.authorization);
sessionStorage.setItem('authorization', response.authorization);
Notify.clear();
Notify.success(msg);
getAllEnum().then((res) => {
handelResponse(res, (response, msg) => {
sessionStorage.setItem("enmu", JSON.stringify(response));
sessionStorage.setItem('enmu', JSON.stringify(response));
});
});
//首次进来进行商品获取
getProductList();
getAccountList();
sessionStorage.setItem("showflag", true);
sessionStorage.setItem('showflag', true);
let menuList = response.menu;
if (response.menu && response.menu.length > 0) {
sessionStorage.setItem(
"activeMenu",
'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('linkshowname', '营销计划管理');
sessionStorage.setItem('pathname2', '/home/plan-list');
sessionStorage.setItem(
"menulinklist",
'menulinklist',
JSON.stringify(market[0].children)
);
setTimeout(() => {
props.history.replace("/home/plan-list");
props.history.replace('/home/plan-list');
}, 1000);
} else {
try {
@ -96,29 +96,29 @@ function FormDom(props) {
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('pathname2', it.router);
sessionStorage.setItem('linkshowname', item.title);
sessionStorage.setItem(
"menulinklist",
'menulinklist',
JSON.stringify(item.children)
);
setTimeout(() => {
props.history.replace(it.router);
}, 1000);
throw "终止循环";
throw '终止循环';
}
});
} else {
Notify.clear();
Notify.warn("请先联系管理员配置权限菜单");
Notify.warn('请先联系管理员配置权限菜单');
}
});
} catch (e) {}
}
} else {
Notify.clear();
Notify.warn("请先联系管理员配置权限菜单");
Notify.warn('请先联系管理员配置权限菜单');
}
},
(err) => {
@ -137,7 +137,7 @@ function FormDom(props) {
const forgetFn = () => {
Notify.clear();
Notify.warn("请联系管理员");
Notify.warn('请联系管理员');
};
useEffect(() => {
codeyzm();
@ -150,23 +150,23 @@ function FormDom(props) {
const codeyzm = () => {
console.log(145, window.baseurl);
const xhr = new XMLHttpRequest();
xhr.open("GET", window.baseurl + "/auth/login/verify");
xhr.open('GET', window.baseurl + '/auth/login/verify');
// xhr.setRequestHeader("Version", "v1.3.0");
xhr.responseType = "arraybuffer";
xhr.responseType = 'arraybuffer';
xhr.onreadystatechange = function (response) {
response.header = {
Accept: "application/json",
"Content-Type": "application/x-www-form-urlencoded;charset=utf-8"
Accept: 'application/json',
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
};
let uniques = xhr.getResponseHeader("Unique-Str");
let uniques = xhr.getResponseHeader('Unique-Str');
setUniquestr(uniques);
var img = document.getElementById("captcha_img");
var img = document.getElementById('captcha_img');
var byteArray = new Uint8Array(response.target.response);
var binary = "";
var binary = '';
for (var i = 0; i < byteArray.byteLength; i++) {
binary += String.fromCharCode(byteArray[i]);
}
let str = "data:image/png;base64," + window.btoa(binary);
let str = 'data:image/png;base64,' + window.btoa(binary);
setImgstr(str);
if (img) {
img.src = str;
@ -246,10 +246,10 @@ function FormDom(props) {
let timecount = setInterval(() => {
let timerId = timer--;
if (timerId > 0) {
setSmscode(timerId + "s");
setSmscode(timerId + 's');
setDisabled(true);
} else {
setSmscode("获取验证码");
setSmscode('获取验证码');
setDisabled(false);
clearInterval(timecount);
}
@ -280,8 +280,8 @@ function FormDom(props) {
handelResponse(
res,
(req, msg) => {
sessionStorage.setItem("updatetime", Date.now());
sessionStorage.setItem("productsList", JSON.stringify(req.data));
sessionStorage.setItem('updatetime', Date.now());
sessionStorage.setItem('productsList', JSON.stringify(req.data));
},
(err) => {}
);
@ -298,52 +298,52 @@ function FormDom(props) {
<FormInputField
name='user_name'
props={{
placeholder: "请输入用户名",
placeholder: '请输入用户名',
maxLength: 50
}}
onChange={sendAcc}
validators={[Validators.required("请输入用户名")]}
/>{" "}
validators={[Validators.required('请输入用户名')]}
/>{' '}
<FormInputField
name='password'
props={{
type: "password",
placeholder: "请输入密码",
type: 'password',
placeholder: '请输入密码',
maxLength: 16,
autoComplete: "new-password"
autoComplete: 'new-password'
}}
onChange={sendPwd}
validators={[Validators.required("请输入密码")]}
/>{" "}
validators={[Validators.required('请输入密码')]}
/>{' '}
{yzmcode == true ? (
<div className='yzmcodeIpt'>
<FormInputField
style={{
width: "60%",
marginRight: "2%"
width: '60%',
marginRight: '2%'
}}
name='code'
props={{
placeholder: "请输入图形验证码",
placeholder: '请输入图形验证码',
maxLength: 5
}}
onChange={sendPicCode}
validators={[Validators.required("请输入图形验证码")]}
/>{" "}
validators={[Validators.required('请输入图形验证码')]}
/>{' '}
<img
src={Imgstr}
className='yzmcode'
id='captcha_img'
onClick={codeyzm}
/>{" "}
/>{' '}
</div>
) : null}
<div className='yzmcodeIpt'>
<FormInputField
style={{ width: "60%", marginRight: "2%" }}
style={{ width: '60%', marginRight: '2%' }}
name='notecode'
props={{ placeholder: "请输入短信验证码", maxLength: 6 }}
validators={[Validators.required("请点击右边按钮获取验证码")]}
props={{ placeholder: '请输入短信验证码', maxLength: 6 }}
validators={[Validators.required('请点击右边按钮获取验证码')]}
/>
<div className='yzmcode' id='captcha_img'>
<Button disabled={disabled} onClick={sendCode}>
@ -352,10 +352,10 @@ function FormDom(props) {
</div>
</div>
<div className='forget' onClick={forgetFn}>
{" "}
</div>{" "}
{' '}
</div>{' '}
<button className='loginBtn' htmltype='submit'>
<span className='login-Btntxt'>登录 </span>{" "}
<span className='login-Btntxt'>登录 </span>{' '}
</button>
</Form>
</>