Commit 4364d292 authored by Sixiang_Zzb's avatar Sixiang_Zzb

测试后的bug处理

parent 6cb9bebd
import { message } from 'antd'; import { message } from 'antd';
import { routerRedux } from 'dva/router' import { routerRedux } from 'dva/router';
export default { export default {
namespace: 'History', namespace: 'History',
state: { state: {
pageData: null, pageData: null,
history_url:null, history_url: null,
}, },
reducers: { reducers: {
...@@ -14,29 +14,26 @@ export default { ...@@ -14,29 +14,26 @@ export default {
return { ...state, pageData }; return { ...state, pageData };
}, },
returnURL(state, { history_url }) { returnURL(state, { history_url }) {
return { ...state, history_url}; return { ...state, history_url };
}, },
}, },
effects: { effects: {
//页面处理 //页面处理
*PAGE({playload}, {put}) { *PAGE({ playload }, { put }) {
let pageData = playload; let pageData = playload;
yield put({ type: 'PageData', pageData, }); yield put({ type: 'PageData', pageData });
}, },
//链接 //链接
*URL({ playload }, { put }) { *URL({ playload }, { put }) {
let history_url = playload; let history_url = playload;
console.log("保存地址"+JSON.stringify(playload)); console.log('保存地址' + JSON.stringify(playload));
yield put({ type: 'returnURL', history_url}); yield put({ type: 'returnURL', history_url });
},
*URLCLEAR({}, { put }) {
let history_url = null;
yield put({ type: 'returnURL', history_url });
}, },
*URLCLEAR({ }, { put }) {
let history_url = null;
yield put({ type: 'returnURL', history_url});
}
}, },
}; };
...@@ -26,7 +26,7 @@ const goToName = ['Reply', 'Detail']; ...@@ -26,7 +26,7 @@ const goToName = ['Reply', 'Detail'];
const module = 'CommunityService'; const module = 'CommunityService';
// 页码 // 页码
let pageNum: number = 1; let pageNum: any = 1;
const PropertyServices = (props: any) => { const PropertyServices = (props: any) => {
const { dispatch, location, Data } = props; const { dispatch, location, Data } = props;
...@@ -162,8 +162,8 @@ const PropertyServices = (props: any) => { ...@@ -162,8 +162,8 @@ const PropertyServices = (props: any) => {
columns={columns} columns={columns}
dataSource={Data != null ? Data.data.rows : []} dataSource={Data != null ? Data.data.rows : []}
pagination={{ pagination={{
defaultPageSize: 15, pageSize: Data != null ? Data.data.page.curPageSize : 0,
defaultCurrent: pageNum, current: parseInt(pageNum),
total: Data != null ? Data.data.page.totalRow : 0, total: Data != null ? Data.data.page.totalRow : 0,
showSizeChanger: false, showSizeChanger: false,
}} }}
......
...@@ -12,8 +12,7 @@ import { objectColumns, stringTab } from '@/utils/string'; ...@@ -12,8 +12,7 @@ import { objectColumns, stringTab } from '@/utils/string';
import { timestampToTime } from '@/utils/time'; import { timestampToTime } from '@/utils/time';
const module = 'CommunityService'; const module = 'CommunityService';
let pageNum: number = 1; let pageNum: any = 1;
const Renovation = (props: any) => { const Renovation = (props: any) => {
// const decoration_status = [[0, "待处理"], [1, "已批准"], [2, "已拒绝"]] // const decoration_status = [[0, "待处理"], [1, "已批准"], [2, "已拒绝"]]
const decoration_status = [ const decoration_status = [
...@@ -59,9 +58,10 @@ const Renovation = (props: any) => { ...@@ -59,9 +58,10 @@ const Renovation = (props: any) => {
const { dispatch, Data8, location } = props; const { dispatch, Data8, location } = props;
useEffect(() => { useEffect(() => {
pageNum = 1;
//分页设置 //分页设置
if (location.query.pageNum != null) { if (location.query.pageNum != null) {
pageNum = parseInt(location.query.pageNum); pageNum = location.query.pageNum;
} else { } else {
pageNum = 1; pageNum = 1;
} }
...@@ -111,6 +111,7 @@ const Renovation = (props: any) => { ...@@ -111,6 +111,7 @@ const Renovation = (props: any) => {
tmp['pageNum'] = values.current; tmp['pageNum'] = values.current;
history.push(location.pathname + urlEncode(tmp)); history.push(location.pathname + urlEncode(tmp));
}; };
return ( return (
<div style={{ width: '100%', minWidth: 1020, padding: 34, backgroundColor: '#ffffff' }}> <div style={{ width: '100%', minWidth: 1020, padding: 34, backgroundColor: '#ffffff' }}>
<> <>
...@@ -130,8 +131,8 @@ const Renovation = (props: any) => { ...@@ -130,8 +131,8 @@ const Renovation = (props: any) => {
columns={columns} columns={columns}
onChange={PageChange} onChange={PageChange}
pagination={{ pagination={{
current: pageNum, current: parseInt(pageNum),
defaultPageSize: 15, pageSize: Data8 !== null ? Data8.data.page.curPageSize : null,
total: Data8 !== null ? Data8.data.page.totalRow : null, total: Data8 !== null ? Data8.data.page.totalRow : null,
showSizeChanger: false, showSizeChanger: false,
}} }}
......
...@@ -159,7 +159,7 @@ const ChargeManager = (props: any) => { ...@@ -159,7 +159,7 @@ const ChargeManager = (props: any) => {
loading={loading} loading={loading}
onChange={changePage} onChange={changePage}
pagination={{ pagination={{
defaultPageSize: 15, pageSize: Data !== null ? Data.page.curPageSize : 0,
showSizeChanger: false, showSizeChanger: false,
total: Data !== null ? Data.page.totalRow : '', total: Data !== null ? Data.page.totalRow : '',
current: Data !== null ? Data.page.currentPage : 1, current: Data !== null ? Data.page.currentPage : 1,
......
...@@ -181,7 +181,8 @@ const Edit = (props: any) => { ...@@ -181,7 +181,8 @@ const Edit = (props: any) => {
message: 'Please enter the name of the person in charge!', message: 'Please enter the name of the person in charge!',
}, },
{ {
len: 2, min: 2,
max: 30,
message: 'It must be between 2 and 30', message: 'It must be between 2 and 30',
}, },
]} ]}
......
...@@ -23,7 +23,7 @@ let readyData: any = { ...@@ -23,7 +23,7 @@ let readyData: any = {
providerName: '', providerName: '',
}; };
// 节流阀 // 节流阀
let flag = false; let flag: boolean = false;
const ServiceProviderManagement = (props: any) => { const ServiceProviderManagement = (props: any) => {
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
...@@ -183,13 +183,6 @@ const ServiceProviderManagement = (props: any) => { ...@@ -183,13 +183,6 @@ const ServiceProviderManagement = (props: any) => {
return tmp; return tmp;
}; };
// table组件配置
const pagination = {
current: readyData.pageNum,
total: Data !== null ? Data.page.totalRow : null,
showSizeChanger: false,
};
return ( return (
<div className={styles.base}> <div className={styles.base}>
{/* 头部组件 */} {/* 头部组件 */}
...@@ -224,18 +217,24 @@ const ServiceProviderManagement = (props: any) => { ...@@ -224,18 +217,24 @@ const ServiceProviderManagement = (props: any) => {
</div> </div>
{/* 列表组件 */} {/* 列表组件 */}
<Spin spinning={Data != null ? false : true}> <Table
<Table rowKey={'id'}
size="small" style={{ marginTop: 16 }}
rowKey={'id'} loading={loading}
style={{ marginTop: 16 }} columns={columns}
loading={loading} dataSource={Data != null ? dataSource(Data.rows) : []}
columns={columns} pagination={
dataSource={Data != null ? dataSource(Data.rows) : null} Data != null
pagination={Data != null ? pagination : {}} ? {
onChange={pageChange} current: parseInt(readyData.pageNum),
/> total: Data.page.totalRow,
</Spin> showSizeChanger: false,
pageSize: Data.page.curPageSize,
}
: {}
}
onChange={pageChange}
/>
</div> </div>
); );
}; };
......
...@@ -22,6 +22,7 @@ export interface LoginProps { ...@@ -22,6 +22,7 @@ export interface LoginProps {
} }
interface LoginType extends React.FC<LoginProps> { interface LoginType extends React.FC<LoginProps> {
//
Tab: typeof LoginTab; Tab: typeof LoginTab;
Submit: typeof LoginSubmit; Submit: typeof LoginSubmit;
UserName: React.FunctionComponent<LoginItemProps>; UserName: React.FunctionComponent<LoginItemProps>;
...@@ -57,13 +58,18 @@ const Login: LoginType = (props) => { ...@@ -57,13 +58,18 @@ const Login: LoginType = (props) => {
<LoginContext.Provider <LoginContext.Provider
value={{ value={{
tabUtil: { tabUtil: {
// 将参数id添加到tabs中,根据tabs是否为空来判断是否渲染Tab组件
addTab: (id) => { addTab: (id) => {
setTabs([...tabs, id]); setTabs([...tabs, id]);
}, },
// 剔除id
removeTab: (id) => { removeTab: (id) => {
setTabs(tabs.filter((currentId) => currentId !== id)); setTabs(tabs.filter((currentId) => currentId !== id));
}, },
}, },
// 参数传递activeItem,根据Login的active属性判断
// 如果active[type]存在 则将activeItem添加到active[type]中
// 如果不存在,则active[type]设置为Array属性,并将activeItem添加进去
updateActive: (activeItem) => { updateActive: (activeItem) => {
if (!active) return; if (!active) return;
if (active[type]) { if (active[type]) {
......
import { import { ArrowLeftOutlined } from '@ant-design/icons';
AlipayCircleOutlined,
TaobaoCircleOutlined,
WeiboCircleOutlined,
ArrowLeftOutlined,
} from '@ant-design/icons';
import { Alert, Checkbox, Input, message, Form, Button } from 'antd'; import { Alert, Checkbox, Input, message, Form, Button } from 'antd';
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect, useCallback } from 'react';
import { Link, connect, Dispatch, history, Redirect } from 'umi'; import { Link, connect, Dispatch, history, Redirect } from 'umi';
import { StateType } from '@/models/login'; import { StateType } from '@/models/login';
import { LoginParamsType } from '@/services/login'; import { LoginParamsType, getFakeCaptcha } from '@/services/login';
import { ConnectState } from '@/models/connect'; import { ConnectState } from '@/models/connect';
import LoginForm from './components/Login';
import styles from './style.less'; import styles from './style.less';
import e from 'express';
const { Tab, UserName, Password, Mobile, Captcha, Submit } = LoginForm;
interface LoginProps { interface LoginProps {
dispatch: Dispatch; dispatch: Dispatch;
userLogin: StateType; userLogin: StateType;
submitting?: boolean; submitting?: boolean;
} }
let flag = false;
const Login: React.FC<LoginProps> = (props) => { const Login: React.FC<LoginProps> = (props) => {
const { userLogin = {}, submitting } = props; const { userLogin = {}, submitting, dispatch } = props;
const { status, type: loginType } = userLogin; const { status, type: loginType } = userLogin;
const [type, setType] = useState<string>('account');
const [userName, setUsername] = useState(''); const [userName, setUsername] = useState('');
// const [password, setPasswd] = useState('');
const [forgetflag, setForgetFlag] = useState(false); const [forgetflag, setForgetFlag] = useState(false);
const { dispatch } = props; const [count, setCount] = useState<number>(60);
const [timing, setTiming] = useState(false);
// 提交按钮
const handleSubmit = (values: LoginParamsType) => { const handleSubmit = (values: LoginParamsType) => {
console.log(values); console.log(values);
if (forgetflag) { if (forgetflag) {
...@@ -49,33 +39,35 @@ const Login: React.FC<LoginProps> = (props) => { ...@@ -49,33 +39,35 @@ const Login: React.FC<LoginProps> = (props) => {
message.error('The username or password cannot be empty!'); message.error('The username or password cannot be empty!');
} }
}; };
// 用户名
const usernameHandle = (e: any) => { const usernameHandle = (e: any) => {
setUsername(e.target.value); setUsername(e.target.value);
}; };
// const passwdHandle = (e: any) => {
// setPasswd(e.target.value);
// };
// 登录
const returnHandle = (e: any) => { const returnHandle = (e: any) => {
history.push('/user/login'); history.push('/user/login');
}; };
// 忘记密码
const gotoForgetHandle = (e: any) => { const gotoForgetHandle = (e: any) => {
history.push('/user/forget'); history.push('/user/forget');
}; };
const handleSend = (e: any) => { const handleSend = (e: any) => {
console.log(userName); if (timing) return;
if ( if (
userName !== '' && userName !== '' &&
/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(userName) /^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(userName)
) { ) {
console.log('邮箱正确!'); console.log('邮箱正确!');
flag = true; onGetCaptcha('mobile');
} else { } else {
message.warning('Please enter the correct email address!'); message.warning('Please enter the correct email address!');
} }
}; };
// 监听路由
useEffect(() => { useEffect(() => {
if (location.pathname == '/user/forget') { if (location.pathname == '/user/forget') {
setForgetFlag(true); setForgetFlag(true);
...@@ -84,63 +76,39 @@ const Login: React.FC<LoginProps> = (props) => { ...@@ -84,63 +76,39 @@ const Login: React.FC<LoginProps> = (props) => {
} }
}, [location.pathname]); }, [location.pathname]);
const timeOut = () => { const onGetCaptcha = useCallback(async (mobile: string) => {
if (flag) { const result = await getFakeCaptcha(mobile);
let number = 60; console.log(result);
let timeId = setTimeout(() => {
number--; if (result === false) {
if (number === 0) { return;
flag = false;
clearTimeout(timeId);
}
}, 60000);
return number;
} }
}; message.success('获取验证码成功!验证码为:1234');
setTiming(true);
}, []);
useEffect(() => {
console.log('计算秒数');
let interval: number = 0;
console.log(timing);
if (timing) {
interval = window.setInterval(() => {
setCount((preSecond) => {
if (preSecond <= 1) {
setTiming(false);
clearInterval(interval);
// 重置秒数
return 60;
}
return preSecond - 1;
});
}, 1000);
}
return () => clearInterval(interval);
}, [timing]);
return ( return (
<div> <div>
{/* {forgetflag ? (
<div style={{ position: 'absolute', top: -50, cursor: 'pointer' }} onClick={returnHandle}>
<ArrowLeftOutlined style={{ fontSize: '28px' }} />
</div>
) : (
<div />
)}
<LoginForm activeKey={type} onTabChange={setType} onSubmit={handleSubmit}>
<div className={styles.box1}>
{forgetflag ? 'Please enter email address' : 'Account Name'}
</div>
<input className={styles.input} onChange={usernameHandle} />
<div className={styles.box1}>
{forgetflag ? 'Please enter a verification code' : 'Password'}
</div>
{forgetflag ? (
<div className={styles.box2}>
<input className={styles.input5} onChange={passwdHandle} />
<div className={styles.button2} style={{ float: 'right' }} onClick={handleSend}>
Send
</div>
</div>
) : (
<div>
<input className={styles.input2} onChange={passwdHandle} type="password" />
<div>
<div className={styles.input3} onClick={gotoForgetHandle}>
Forget Password
</div>
<div className={styles.input4}>
{status === 'error' && loginType === 'account' && !submitting && (
<div>Wrong account or password</div>
)}
</div>
</div>
</div>
)}
<Submit className={styles.button} loading={submitting} style={{ width: 330 }}>
{forgetflag ? 'Next' : '登录'}
</Submit>
</LoginForm> */}
{forgetflag ? ( {forgetflag ? (
<div style={{ position: 'absolute', top: -50, cursor: 'pointer' }} onClick={returnHandle}> <div style={{ position: 'absolute', top: -50, cursor: 'pointer' }} onClick={returnHandle}>
<ArrowLeftOutlined style={{ fontSize: '28px' }} /> <ArrowLeftOutlined style={{ fontSize: '28px' }} />
...@@ -153,7 +121,7 @@ const Login: React.FC<LoginProps> = (props) => { ...@@ -153,7 +121,7 @@ const Login: React.FC<LoginProps> = (props) => {
{forgetflag ? 'Please enter email address' : 'Account Name'} {forgetflag ? 'Please enter email address' : 'Account Name'}
</div> </div>
<Form.Item name="userName"> <Form.Item name="userName">
<input className={styles.input} onChange={usernameHandle} /> <input className={styles.input} value={userName || ''} onChange={usernameHandle} />
</Form.Item> </Form.Item>
<div className={styles.box1}> <div className={styles.box1}>
{forgetflag ? 'Please enter a verification code' : 'Password'} {forgetflag ? 'Please enter a verification code' : 'Password'}
...@@ -162,7 +130,7 @@ const Login: React.FC<LoginProps> = (props) => { ...@@ -162,7 +130,7 @@ const Login: React.FC<LoginProps> = (props) => {
<div className={styles.box2}> <div className={styles.box2}>
<input className={styles.input5} /> <input className={styles.input5} />
<div className={styles.button2} style={{ float: 'right' }} onClick={handleSend}> <div className={styles.button2} style={{ float: 'right' }} onClick={handleSend}>
{flag ? timeOut : 'Send'} {timing ? `${count} 秒` : 'Send'}
</div> </div>
</div> </div>
) : ( ) : (
......
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