Commit 4364d292 authored by Sixiang_Zzb's avatar Sixiang_Zzb

测试后的bug处理

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