Commit ae9d3590 authored by Sixiang_Zzb's avatar Sixiang_Zzb

添加权限,修改测试发现的bug

parent 96206495
......@@ -48,6 +48,11 @@ export default defineConfig({
path: '/user/forget',
component: './user/login',
},
{
name: 'login',
path: '/user/login2',
component: './user/login/login2',
},
],
},
{
......
......@@ -53,59 +53,11 @@ class SecurityLayout extends React.Component<SecurityLayoutProps, SecurityLayout
// const isLogin = currentUser && currentUser.name;//isLogin为关键点
const routeAuth = [
[1, '/manager/data/lookUp'],
[2, '/manager/account/lookUp'],
[3, '/manager/account/edit'],
[4, '/manager/account/addProfile'],
[5, '/manager/account/logOutProfile'],
[6, '/manager/vps/lookUp'],
[7, '/manager/vps/edit'],
[8, '/manager/vps/add'],
[9, '/manager/vps/logOut'],
[10, '/manager/tosMoney/lookUp'],
[11, '/manager/tosMoney/add'],
[12, '/manager/tosServices/lookUp'],
[13, '/manager/tosServices/edit'],
[14, '/manager/tosServices/logOut'],
[15, '/manager/order/lookUp'],
[16, '/manager/order/edit'],
[17, '/manager/contract/lookUp'],
[18, '/manager/contract/edit'],
[19, '/manager/contract/add'],
[20, '/manager/village/lookUp'],
[21, '/manager/village/edit'],
[22, '/manager/village/add'],
[23, '/manager/notice/lookUp'],
[24, '/manager/notice/edit'],
[25, '/manager/notice/add'],
[26, '/manager/visitor/lookUp'],
[27, '/manager/bookingService/lookUp'],
[28, '/manager/bookingService/edit'],
[29, '/manager/bookingService/add'],
[30, '/manager/backgroundAccount/lookUp'],
[31, '/manager/backgroundAccount/edit'],
[32, '/manager/lifeAccount/lookUp'],
[33, '/manager/lifeAccount/edit'],
[34, '/manager/lifeAccount/add'],
[35, '/manager/lifeAccount/logOut'],
[36, '/manager/lifeAccount/familyMembers/add'],
[37, '/manager/lifeAccount/familyMembers/logOut'],
];
var isLogin = false;
// 权限判断
let auth = false;
if (getCookie('token').length != 0) {
console.log('是否有权限');
// console.log('是否有权限');
isLogin = true;
// console.log(currentUser?.permission);
// console.log(location.pathname);
// const flag = routeAuth.some((v) => {
// return v[1] === location.pathname;
// });
// console.log(flag);
}
const queryString = stringify({
......@@ -117,10 +69,9 @@ class SecurityLayout extends React.Component<SecurityLayoutProps, SecurityLayout
return <PageLoading />;
}
if (!isLogin && window.location.pathname !== '/user/login') {
// message.error('Please Re Login!', 3, () => {
console.log('未登录返回登录页!');
message.error('Please Re Login!', 3);
// console.log('未登录返回登录页!');
return <Redirect to={`/user/login?${queryString}`} />;
// });
}
return children;
}
......
......@@ -31,6 +31,7 @@ export default {
return { ...state, CurData };
},
returnCurDataDetail(state: object, { CurDataDetail }: any) {
console.log(state);
return { ...state, CurDataDetail };
},
returnPage7(state: object, { Data7 }: any) {
......@@ -70,11 +71,9 @@ export default {
switch (playload.index) {
case 21:
{
var tmp = resp.data.rows[0].tosOwerModel;
var tmp2 = resp.data.rows[0];
console.log(resp.data.rows[0].replyImgUrl);
console.log(Fromate(resp.data.rows[0].replyImgUrl, [['url', null]]));
var tmp = resp.data.tosOwerModel;
var tmp2 = resp.data;
console.log(resp);
var CurDataDetail = {
community: tmp.communityName,
address: tmp.addressAndpostalCode,
......@@ -82,9 +81,9 @@ export default {
name: tmp.owerName,
phone: tmp.accountLogin != null ? tmp.accountLogin : tmp.owerPhone,
email: tmp.owerEmail,
content: resp.data.rows[0].serviceContent,
replyContent: resp.data.rows[0].replyContent,
replyImgUrl: Fromate(resp.data.rows[0].replyImgUrl, [['url', null]]),
content: resp.data.serviceContent,
replyContent: resp.data.replyContent,
replyImgUrl: Fromate(resp.data.replyImgUrl, [['url', null]]),
status: tmp2.handleStatus,
pictrues: picFromate(tmp2.imgUrl),
time: timestampToTime4(tmp2.createTime.time),
......
......@@ -67,7 +67,7 @@ const Model: LoginModelType = {
console.log(userMessage);
console.log(userMessage.token);
setCookie('token', userMessage.token);
setCookie('permission', userMessage.permission);
localStorage.setItem('permission', JSON.stringify(userMessage.permission));
console.log('获取到Token:' + getCookie('token'));
yield put({
type: 'saveToken',
......
import React, { useState, useEffect, useRef } from 'react';
import { Input, Tabs, Table, Space, Button } from 'antd';
import { Input, Tabs, Table, Space, Button, message } from 'antd';
const { TabPane } = Tabs;
import { connect, history } from 'umi';
......@@ -21,7 +21,7 @@ let readyData: any = {
const module = 'CommunityService';
const Card = (props: any) => {
const { dispatch, Data7, location } = props;
const permissionArr = JSON.parse(localStorage.getItem('permission') || '');
const [loading, setLoading] = useState(false);
// const apply_status = [[0, "审核中"], [1, "批准"], [2, "拒绝"], [3, "领取"]]
const apply_status = [
......@@ -90,6 +90,10 @@ const Card = (props: any) => {
}, [Data7]);
const goToDetail = (values: any, e: any) => {
if (permissionArr.indexOf('12') < 0) {
message.error('No Permissions!!!', 3);
return;
}
SA(values, module, dispatch);
history.push('./AccessCardApplication/Detail');
};
......
......@@ -222,7 +222,9 @@ const Detail = (props: any) => {
</div>
</Spin>
</>
) : null}
) : (
<></>
)}
</div>
);
};
......
......@@ -29,6 +29,7 @@ const module = 'CommunityService';
let pageNum: any = 1;
const PropertyServices = (props: any) => {
const permissionArr = JSON.parse(localStorage.getItem('permission') || '');
const { dispatch, location, Data } = props;
const [loading, setLoading] = useState(false);
......@@ -74,6 +75,10 @@ const PropertyServices = (props: any) => {
];
const goToDetail = (value: any, record: any, e: any) => {
if (permissionArr.indexOf('12') < 0) {
message.error('No Permissions!!!', 3);
return;
}
//页面递进
history.push(
location.pathname +
......
import React, { useState, useEffect, useRef } from 'react';
import { Input, Tabs, Table, Space, Button } from 'antd';
import { Input, Tabs, Table, Space, Button, message } from 'antd';
const { TabPane } = Tabs;
import { connect, history } from 'umi';
......@@ -14,6 +14,7 @@ const module = 'CommunityService';
let pageNum: any = 1;
const Renovation = (props: any) => {
const permissionArr = JSON.parse(localStorage.getItem('permission') || '');
// const decoration_status = [[0, "待处理"], [1, "已批准"], [2, "已拒绝"]]
const decoration_status = [
[0, 'Pending'],
......@@ -101,6 +102,10 @@ const Renovation = (props: any) => {
};
const goToDetail = (values: any, e: any) => {
if (permissionArr.indexOf('12') < 0) {
message.error('No Permissions!!!', 3);
return;
}
SA(values, module, dispatch);
history.push('./RenovationApplication/Detail?id=' + values.id);
};
......
......@@ -35,6 +35,11 @@ const ChargeManager = (props: any) => {
const [loading, setLoading] = useState(false);
const goToDetail = (values: any) => {
const permissionArr = JSON.parse(localStorage.getItem('permission') || '');
if (permissionArr.indexOf('10') < 0) {
message.error('No Permissions!!!', 3);
return;
}
getById(values);
history.push('/PropertyManagementDetail');
};
......
......@@ -23,6 +23,8 @@ import {
import PageData from '@/models/Common/PageData';
console.log('检查是否有权限');
const module = 'User';
const module2 = 'History';
const module3 = 'PageData';
......@@ -40,13 +42,13 @@ let readyData: any = {
owerName: '',
communityArray: [],
};
// 节流阀
let flag: boolean = false;
const Users = (props: any) => {
const permissionArr = JSON.parse(localStorage.getItem('permission') || '');
const { formatMessage } = useIntl();
const { dispatch, location, Data, CommunityList, pageData, history_url } = props;
const SA = (values: any) => {
dispatch({ type: 'User/SA', playload: values });
};
......@@ -180,17 +182,29 @@ const Users = (props: any) => {
}, [Data]);
const goToDetail = (values: any, e: any) => {
if (permissionArr.indexOf('2') < 0) {
message.error('No Permissions!!!', 3);
return;
}
SA(values);
history.push(location.pathname + '/Detail');
};
const goToEdit = (values: any, e: any) => {
if (permissionArr.indexOf('3') < 0) {
message.error('No Permissions!!!', 3);
return;
}
SA(values);
URL({ pathname: location.pathname + '/Edit', status: 1 }, module2, dispatch);
history.push(location.pathname + '/Edit');
};
const goToAdd = () => {
if (permissionArr.indexOf('4') < 0) {
message.error('No Permissions!!!', 3);
return;
}
URL({ pathname: location.pathname + '/Add', status: 1 }, module2, dispatch);
history.push(location.pathname + '/Add');
};
......
......@@ -155,6 +155,11 @@ const UsersDetail = (props: any) => {
};
const deleteUnit = (values: any) => {
const permissionArr = JSON.parse(localStorage.getItem('permission'));
if (permissionArr.indexOf('5') < 0) {
message.error('No Permissions!!!', 3);
return;
}
confirm({
title: 'Are you sure delete this infomation?',
icon: <ExclamationCircleOutlined />,
......
......@@ -29,6 +29,11 @@ const AccoutingContent = (props: {
}, []);
const handleClick = (id: string) => {
const permissionArr = JSON.parse(localStorage.getItem('permission') || '');
if (permissionArr.indexOf('9') < 0) {
message.error('No Permissions!!!', 3);
return;
}
confirm({
title: 'Warning',
icon: <ExclamationCircleOutlined />,
......
......@@ -56,6 +56,11 @@ const Detail = (props: any) => {
];
const handleClick = (id: string) => {
const permissionArr = JSON.parse(localStorage.getItem('permission') || '');
if (permissionArr.indexOf('9') < 0) {
message.error('No Permissions!!!', 3);
return;
}
confirm({
title: 'Warning',
icon: <ExclamationCircleOutlined />,
......@@ -105,7 +110,7 @@ const Detail = (props: any) => {
)}
<div className={styles.bigbox}>
<div className={styles.box0}>
<div className={styles.box0item1}></div>
{/* <div className={styles.box0item1}></div> */}
{/* <div className={styles.box0item2}>{SaveChooseData.serviceCommunityList}</div> */}
</div>
<div className={styles.box1}>
......
import React, { useState, useEffect, useRef } from 'react';
import styles from './index.less';
import { Form, Input, Spin, Table, Space, Button } from 'antd';
import { Form, Input, Spin, Table, Space, Button, message } from 'antd';
import { LoadingOutlined } from '@ant-design/icons';
import { urlEncode, filterObj, filterObjbyTg, RA } from '@/utils/method';
......@@ -26,6 +26,8 @@ let readyData: any = {
let flag: boolean = false;
const ServiceProviderManagement = (props: any) => {
const permissionArr = JSON.parse(localStorage.getItem('permission') || '');
const [loading, setLoading] = useState(false);
const { dispatch, location, Data, CommunityList, DataServices } = props;
......@@ -35,6 +37,10 @@ const ServiceProviderManagement = (props: any) => {
};
const goToDetail = (values: any, e: any) => {
if (permissionArr.indexOf('6') < 0) {
message.error('No Permissions!!!', 3);
return;
}
values.serviceScope = options[values.serviceScopeList[0]][1];
SaveChooseData(values);
if (values.serviceScopeList[0] === '0') {
......@@ -46,6 +52,10 @@ const ServiceProviderManagement = (props: any) => {
}
};
const goToEdit = (values: any, e: any) => {
if (permissionArr.indexOf('7') < 0) {
message.error('No Permissions!!!', 3);
return;
}
SaveChooseData(values);
history.push(location.pathname + '/Edit');
// if (values.serviceScopeList[0] === '0') {
......@@ -56,6 +66,10 @@ const ServiceProviderManagement = (props: any) => {
// }
};
const goToCreate = () => {
if (permissionArr.indexOf('8') < 0) {
message.error('No Permissions!!!', 3);
return;
}
SaveChooseData(null);
history.push(location.pathname + '/Edit');
};
......
......@@ -3,7 +3,7 @@ import { Alert, Checkbox, Input, message, Form, Button } from 'antd';
import React, { useState, useEffect, useCallback } from 'react';
import { Link, connect, Dispatch, history, Redirect } from 'umi';
import { StateType } from '@/models/login';
import { LoginParamsType, getFakeCaptcha } from '@/services/login';
import { LoginParamsType, getFakeCaptcha, getCaptcha, ValidateCaptcha } from '@/services/login';
import { ConnectState } from '@/models/connect';
import styles from './style.less';
......@@ -27,16 +27,21 @@ const Login: React.FC<LoginProps> = (props) => {
const handleSubmit = (values: LoginParamsType) => {
console.log(values);
if (forgetflag) {
console.log('验证码!');
}
if (values.userName && values.password) {
dispatch({
type: 'login/login',
payload: { ...values },
});
console.log('校验验证码!');
// ValidateCaptcha({account,code})
if (true) {
console.log('通过跳转到修改密码页面');
history.push('login2');
}
} else {
message.error('The username or password cannot be empty!');
if (values.userName && values.password) {
dispatch({
type: 'login/login',
payload: { ...values },
});
} else {
message.error('The username or password cannot be empty!');
}
}
};
......@@ -61,7 +66,7 @@ const Login: React.FC<LoginProps> = (props) => {
/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(userName)
) {
console.log('邮箱正确!');
onGetCaptcha('mobile');
onGetCaptcha(userName);
} else {
message.warning('Please enter the correct email address!');
}
......@@ -76,10 +81,14 @@ const Login: React.FC<LoginProps> = (props) => {
}
}, [location.pathname]);
const onGetCaptcha = useCallback(async (mobile: string) => {
const result = await getFakeCaptcha(mobile);
// 获取验证码
const onGetCaptcha = useCallback(async (email: string) => {
// getFakeCaptcha
// getCaptcha
const result = await getCaptcha({ account: email });
console.log(result);
return;
if (result === false) {
return;
}
......@@ -120,8 +129,8 @@ const Login: React.FC<LoginProps> = (props) => {
<div className={styles.box1}>
{forgetflag ? 'Please enter email address' : 'Account Name'}
</div>
<Form.Item name="userName">
<input className={styles.input} defaultValue={userName || ''} onChange={usernameHandle} />
<Form.Item name="userName" initialValue={userName || ''}>
<input className={styles.input} onChange={usernameHandle} />
</Form.Item>
<div className={styles.box1}>
{forgetflag ? 'Please enter a verification code' : 'Password'}
......
import React from 'react';
import { message, Form, Input, Button } from 'antd';
import styles from './style.less';
interface Password {
password: stirng;
}
const Login2 = (props: any) => {
const { history } = props;
// 修改密码
const onFinish = (values: Password) => {
console.log('修改密码');
message.success('modify successfully!', 3);
history.push('/user/login');
};
return (
<div>
<Form layout="vertical" onFinish={onFinish} requiredMark={false}>
<Form.Item
name="password"
label="Password"
rules={[
{
required: true,
message: 'Please input your password!',
},
]}
hasFeedback
className={styles.passStyle}
>
<Input.Password bordered={false} />
</Form.Item>
<Form.Item
name="confirm"
label="Confirm Password"
dependencies={['password']}
hasFeedback
className={styles.passStyle}
rules={[
{
required: true,
message: 'Please confirm your password!',
},
({ getFieldValue }) => ({
validator(rule, value) {
if (!value || getFieldValue('password') === value) {
return Promise.resolve();
}
return Promise.reject('The two passwords that you entered do not match!');
},
}),
]}
>
<Input.Password bordered={false} />
</Form.Item>
<Form.Item className={styles.passBtn}>
<Button size="large" type="primary" shape="round" htmlType={'submit'}>
Accomplish
</Button>
</Form.Item>
</Form>
</div>
);
};
export default Login2;
......@@ -38,92 +38,121 @@
}
}
.box1{
font-size:20px;
font-family:"PingFang SC";
font-weight:800;
color:rgba(129,152,177,1);
.box1 {
font-size: 20px;
font-family: 'PingFang SC';
font-weight: 800;
color: rgba(129, 152, 177, 1);
margin-bottom: 20px;
}
.input{
border:none;
background:none;
.input {
border: none;
background: none;
outline: none;
border-bottom: 1px solid rgba(78,80,105,1);
width:330px;
border-bottom: 1px solid rgba(78, 80, 105, 1);
width: 330px;
margin-bottom: 20px;
font-size:20px;
font-family:"PingFang SC";
font-weight:800;
color:rgba(0,26,84,1);
font-size: 20px;
font-family: 'PingFang SC';
font-weight: 800;
color: rgba(0, 26, 84, 1);
}
.input2{
border:none;
background:none;
.input2 {
border: none;
background: none;
outline: none;
border-bottom: 1px solid rgba(78,80,105,1);
width:330px;
font-size:20px;
font-family:"PingFang SC";
font-weight:800;
color:rgba(0,26,84,1);
border-bottom: 1px solid rgba(78, 80, 105, 1);
width: 330px;
font-size: 20px;
font-family: 'PingFang SC';
font-weight: 800;
color: rgba(0, 26, 84, 1);
}
.input3{
.input3 {
cursor: pointer;
font-size:20px;
font-family:"PingFang SC";
font-weight:800;
color:rgba(0,26,84,1);
opacity:0.3;
font-size: 20px;
font-family: 'PingFang SC';
font-weight: 800;
color: rgba(0, 26, 84, 1);
opacity: 0.3;
}
.input4{
width:400px;
height:20px;
font-size:20px;
font-family:PingFang SC;
font-weight:800;
color:rgba(255,56,56,1);
.input4 {
width: 400px;
height: 20px;
font-size: 20px;
font-family: PingFang SC;
font-weight: 800;
color: rgba(255, 56, 56, 1);
}
.button{
width:100px;
height:51px;
background:rgba(64,101,224,1);
border-radius:26px;
.button {
width: 100px;
height: 51px;
background: rgba(64, 101, 224, 1);
border-radius: 26px;
border: none;
}
.input5{
border:none;
background:none;
.input5 {
border: none;
background: none;
outline: none;
border-bottom: 1px solid rgba(78,80,105,1);
width:176px;
font-size:20px;
font-family:"PingFang SC";
font-weight:800;
color:rgba(0,26,84,1);
border-bottom: 1px solid rgba(78, 80, 105, 1);
width: 176px;
font-size: 20px;
font-family: 'PingFang SC';
font-weight: 800;
color: rgba(0, 26, 84, 1);
}
.button2{
.button2 {
width: 120px;
height: 34px;
border-radius:26px;
background:none;
border: 1px solid rgba(78,80,105,1);
border-radius: 26px;
background: none;
border: 1px solid rgba(78, 80, 105, 1);
line-height: 34px;
text-align: center;
position: absolute;
cursor: pointer;
top:0;
top: 0;
left: 196px;
font-size:20px;
font-family:"PingFang SC";
font-weight:800;
color:rgba(0,26,84,1);
font-size: 20px;
font-family: 'PingFang SC';
font-weight: 800;
color: rgba(0, 26, 84, 1);
}
.box2{
.box2 {
width: 100%;
height: 34px;
position: relative;
margin-bottom: 45px;
}
\ No newline at end of file
}
.passStyle {
:global {
.ant-form-item-required {
font-size: 20px;
font-family: 'PingFang SC';
font-weight: 800;
color: rgba(129, 152, 177, 1);
}
.ant-form-item-control-input {
width: 330px;
border-bottom: 1px solid rgba(78, 80, 105, 1);
box-shadow: none;
}
.ant-input-affix-wrapper-focused {
box-shadow: none;
}
}
}
.passBtn {
:global {
.ant-btn {
width: 330px;
height: 51px;
font-size: 20px;
}
}
}
import React, { useState, useEffect } from 'react';
import styles from './index.less';
import { Input ,Menu,Table,Space,Pagination,Tooltip, Button } from 'antd';
import { Input, Menu, Table, Space, Pagination, Tooltip, Button } from 'antd';
import { Link, useIntl, connect, Dispatch } from 'umi';
const Login2 = () => {
return (
<div className={styles.base}>
<div className={styles.box}>
<div>please input a password</div>
<input type="password" className={styles.input} placeholder="" />
<div className={styles.item1}>
<Button type="primary" className={styles.item2}>提交</Button>
<Button type="primary" className={styles.item2}>
提交
</Button>
</div>
</div>
</div>
);
};
export default Login2;
......@@ -4,7 +4,10 @@ export interface LoginParamsType {
userName: string;
password: string;
}
export interface CodeType {
account: string;
code: string;
}
// export async function fakeAccountLogin(params: LoginParamsType) {
// return request('/api/login/account', {
// method: 'POST',
......@@ -12,10 +15,6 @@ export interface LoginParamsType {
// });
// }
export async function getFakeCaptcha(mobile: string) {
return request(`/api/login/captcha?mobile=${mobile}`);
}
export async function AccountLogin(params: LoginParamsType) {
console.log('登录请求');
console.log(params);
......@@ -35,3 +34,19 @@ export async function AccountCheckLogin(params: LoginCheckParamsType) {
console.log('登录确认请求');
return request('/tos/user/newCurrentUser', { method: 'POST', data: params });
}
export async function getFakeCaptcha(mobile: string) {
return request(`/api/login/captcha?mobile=${mobile}`);
}
export async function getCaptcha(email: object) {
console.log('获取验证码');
console.log(email);
return request('/tos/send/code', { method: 'POST', data: email });
}
export async function ValidateCaptcha(params: CodeType) {
console.log('校验验证码');
console.log(params);
return request('/tos/validate/code', { method: 'POST', data: params });
}
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