Commit f208c47f authored by 张烨's avatar 张烨

refactor: 💡 add userlogin api request

parent 32336b41
import React, { useState } from 'react';
import axios from 'axios';
import { Alert, Checkbox } from 'antd';
import { login } from '../../../services/user/api';
import { USER_MODE } from '../../../utils/constants';
import LoginForm from './components/Login';
import styles from './style.less';
......@@ -18,7 +17,6 @@ const LoginMessage = ({ content }) => (
showIcon
/>
);
const basicUrl = 'http://localhost:8080/Cityinterface/rest/services/OMS.svc/';
const Login = props => {
const { userLogin = {}, submitting } = props;
......@@ -28,27 +26,22 @@ const Login = props => {
const handleSubmit = values => {
/* eslint-disable no-console */
console.log(values); // eg:{userName: "123", password: "123"}
axios
.get(
`${basicUrl}L_GetCheckUser?loginName=${values.userName}&password=${
values.password
}`,
)
.then(result => {
console.log(result.data);
if (result.data.success === true && result.data.pass === true) {
const { userMode } = result.data;
localStorage.setItem('userMode', userMode);
if (userMode === 'admin' || userMode === 'super') {
window.location.href = '/dbm/dbInit/';
}
if (userMode === 'common') {
window.location.href = '/ou/orgList/';
}
} else {
alert('错误,没有权限');
const { userName: loginName, password } = values;
login({ loginName, password }).then(result => {
console.log(result.data);
if (result.data.success === true && result.data.pass === true) {
const { userMode } = result.data;
localStorage.setItem('userMode', userMode);
if (userMode === USER_MODE.ADMIN || userMode === USER_MODE.SUPER) {
window.location.href = '/dbm/dbInit/';
}
if (userMode === USER_MODE.COMMON) {
window.location.href = '/ou/orgList/';
}
});
} else {
alert('错误,没有权限');
}
});
};
return (
......
// import {get, post} from '../index'
import { get, post } from '../index';
// export const getUserInfo = param => {
// return get('/cityinterface/getUserinfo', param)
// }
export const getUserInfo = param => get('/cityinterface/getUserinfo', param);
export const login = param =>
get(`/Cityinterface/rest/services/OMS.svc/L_GetCheckUser`, param);
export const RESTART_ON_REMOUNT = '@@saga-injector/restart-on-remount';
export const DAEMON = '@@saga-injector/daemon';
export const ONCE_TILL_UNMOUNT = '@@saga-injector/once-till-unmount';
export const USER_MODE = {
ADMIN: 'admin',
SUPER: 'super',
COMMON: 'common',
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment