Commit 3699ba57 authored by 1271610056@qq.com's avatar 1271610056@qq.com

物业费管理时间格式处理

parent a1294638
import { stringify } from 'querystring';
import { history, Reducer, Effect } from 'umi';
import { AccountLogin,AccountCheckLogin,AccountOut } from '@/services/login';
import { AccountLogin, AccountCheckLogin, AccountOut } from '@/services/login';
import { setAuthority } from '@/utils/authority';
import { getPageQuery } from '@/utils/utils';
......@@ -28,7 +28,6 @@ export interface LoginModelType {
};
}
const Model: LoginModelType = {
namespace: 'login',
......@@ -36,7 +35,7 @@ const Model: LoginModelType = {
status: undefined,
token: '',
userName: '',
password:'',
password: '',
},
reducers: {
......@@ -48,9 +47,9 @@ const Model: LoginModelType = {
type: payload.type,
};
},
saveToken(state, { token,userName,password }) {
return{...state,token,userName,password}
}
saveToken(state, { token, userName, password }) {
return { ...state, token, userName, password };
},
},
effects: {
......@@ -61,20 +60,25 @@ const Model: LoginModelType = {
payload: response,
});
// Login successfully response.status === 'ok'
if (response.token !=null) {
console.log("用户名密码登录成功")
console.log(response)
const userMessage = yield call(AccountCheckLogin, payload);//请求时间网络
console.log(userMessage)
console.log(userMessage.token)
setCookie("token", userMessage.token)
if (response.token != null) {
console.log('用户名密码登录成功');
console.log(response);
const userMessage = yield call(AccountCheckLogin, payload); //请求时间网络
console.log(userMessage);
console.log(userMessage.token);
setCookie('token', userMessage.token);
// tosUserName: "admin"
// tosUserPhone: "18818881888"
setCookie("name", response.token.tosUserName)
setCookie("phone", response.token.tosUserPhone)
setCookie("id", response.token.id)
console.log("获取到Token:" + getCookie("token"))
yield put({type: 'saveToken',token: userMessage.token,userName:payload.userName,password:payload.password});
setCookie('name', response.token.tosUserName);
setCookie('phone', response.token.tosUserPhone);
setCookie('id', response.token.id);
console.log('获取到Token:' + getCookie('token'));
yield put({
type: 'saveToken',
token: userMessage.token,
userName: payload.userName,
password: payload.password,
});
const urlParams = new URL(window.location.href);
const params = getPageQuery();
let { redirect } = params as { redirect: string };
......@@ -92,12 +96,12 @@ const Model: LoginModelType = {
}
history.replace(redirect || '/');
} else {
console.error(response)
message.error("Login Error! Username or Password is wrong!",3)
console.error(response);
message.error('Login Error! Username or Password is wrong!', 3);
}
},
*logout({},{call,put}) {
*logout({}, { call, put }) {
const { redirect } = getPageQuery();
// Note: There may be security issues, please note
// const response = yield call(AccountOut, payload);
......@@ -111,8 +115,6 @@ const Model: LoginModelType = {
}
},
},
};
export default Model;
import React, { useState, useEffect } from 'react';
import styles from './ChargeDetail.less';
import { Input ,Menu,Table,Space,Pagination,Tooltip } from 'antd';
import { Input, Menu, Table, Space, Pagination, Tooltip } from 'antd';
import { Link, useIntl, connect, Dispatch } from 'umi';
import PDF from 'react-pdf-js';//
import PDF from 'react-pdf-js'; //
import { render } from 'react-dom';
import { Document } from 'react-pdf/dist/entry.webpack';
......@@ -16,75 +15,82 @@ import { timestampToTime2 } from '../../utils/time';
import TitleBack from '../../components/TitleBack/TitleBack';
const ChargeDetail = (props: any) => {
const { CurData } = props;
const { formatMessage } = useIntl();
const [scale, setState] = useState(1.3)
const [pages,setPages] = useState(1)
const [curpage,setCurpage]=useState(1)
const [scale, setState] = useState(1.3);
const [pages, setPages] = useState(1);
const [curpage, setCurpage] = useState(1);
const pdfpages = (pages: any) => {
setPages(pages)
setPages(pages);
//alert(pages)
}
};
const lookup = () => {
if (scale == 1.3) {
setState(2)
setState(2);
} else {
setState(1.3)
}
setState(1.3);
}
};
const pageChange = (curpage: any) => {
setCurpage(curpage)
}
setCurpage(curpage);
};
const goToReturn = () => {
history.back()
}
history.back();
};
console.log(CurData);
return (
<div className={styles.base}>
{/* 组件 */}
{CurData ? (
<>
<TitleBack
title="Payment Settings"
sublist={['Upload Time ' + timestampToTime2(CurData.updateTime.time)]}
/>
<TitleBack title="Payment Settings" sublist={['Upload Time '+timestampToTime2(CurData.updateTime.time)]}/>
<div className={styles.box2}>
<div className={styles.item21}>Project</div>
<div className={styles.item21}>Project (community)</div>
<div className={styles.item22}>{CurData.billName}</div>
<div className={styles.item23}>{CurData.communityName}</div>
<div className={styles.item234}>#</div>
<div className={styles.item24}>{CurData.floorNumber}</div>
<div className={styles.item245}>——</div>
<div className={styles.item234}>#</div>
<div className={styles.item25}>{CurData.roomNumber}</div>
<div className={styles.item245}>——</div>
<div className={styles.item26}>{CurData.tosOwnerName}</div>
</div>
<>{stringSplit(CurData.billFileUrl, "m/cash")}</>
<>{stringSplit(CurData.billFileUrl, 'm/cash')}</>
<div className={styles.box4}>
<Pagination simple defaultCurrent={curpage} total={pages*10} onChange={pageChange} />
<Pagination simple defaultCurrent={curpage} total={pages * 10} onChange={pageChange} />
</div>
<><Tooltip title={scale == 1.3 ?"点击放大查看"+CurData.billFileUrl:"还原视图"}>
<div className={scale == 1.3 ?styles.box3out:null}>
< div className={ scale == 1.3 ?styles.box3:styles.box3of} onClick={ lookup } >
<PDF key="pdfjs" file={ stringSplit(CurData.billFileUrl,"m/cash")} workerSrc = "//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.2.228/pdf.worker.js" scale={scale} page={curpage} onDocumentComplete={pdfpages} />
<>
<Tooltip title={scale == 1.3 ? '点击放大查看' + CurData.billFileUrl : '还原视图'}>
<div className={scale == 1.3 ? styles.box3out : null}>
<div className={scale == 1.3 ? styles.box3 : styles.box3of} onClick={lookup}>
<PDF
key="pdfjs"
file={stringSplit(CurData.billFileUrl, 'm/cash')}
workerSrc="//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.2.228/pdf.worker.js"
scale={scale}
page={curpage}
onDocumentComplete={pdfpages}
/>
</div>
</div>
</Tooltip></>
</Tooltip>
</>
</>
) : null}
</div>
);
};
function mapStateToProps(state:any) {
function mapStateToProps(state: any) {
const { CurData } = state.PropertyManagement;
return {
CurData
CurData,
};
}
export default connect(mapStateToProps)(ChargeDetail);
......@@ -157,6 +157,7 @@ const Users = (props:any) => {
ownerName:location.query.ownerName != undefined ? (location.query.ownerName) : null,
communityArray: CommunityList
}, module, dispatch);
console.log("发送请求了123123123123123")
},[location])
......
import { AlipayCircleOutlined, TaobaoCircleOutlined, WeiboCircleOutlined,ArrowLeftOutlined } from '@ant-design/icons';
import {
AlipayCircleOutlined,
TaobaoCircleOutlined,
WeiboCircleOutlined,
ArrowLeftOutlined,
} from '@ant-design/icons';
import { Alert, Checkbox, Input } from 'antd';
import React, { useState,useEffect } from 'react';
import { Link, connect, Dispatch,history, Redirect } from 'umi';
import React, { useState, useEffect } from 'react';
import { Link, connect, Dispatch, history, Redirect } from 'umi';
import { StateType } from '@/models/login';
import { LoginParamsType } from '@/services/login';
import { ConnectState } from '@/models/connect';
......@@ -22,80 +27,102 @@ const Login: React.FC<LoginProps> = (props) => {
const { status, type: loginType } = userLogin;
const [type, setType] = useState<string>('account');
const [userName, setUsername] = useState("");
const [password, setPasswd] = useState("");
const [userName, setUsername] = useState('');
const [password, setPasswd] = useState('');
const handleSubmit = (values: LoginParamsType) => {
const { dispatch } = props;
console.log({ ...values, type,userName,password })
console.log({ ...values, type, userName, password });
console.log(props);
console.log(dispatch, 'dispatch');
dispatch({
type: 'login/login',
payload: {userName,password },
payload: { userName, password },
});
};
const usernameHandle = (e: any) => {
setUsername(e.target.value)
}
setUsername(e.target.value);
};
const passwdHandle = (e: any) => {
setPasswd(e.target.value)
}
setPasswd(e.target.value);
};
const returnHandle = (e: any)=> {
history.push("/user/login")
}
const gotoForgetHandle = (e: any)=> {
history.push("/user/forget")
const returnHandle = (e: any) => {
history.push('/user/login');
};
const gotoForgetHandle = (e: any) => {
history.push('/user/forget');
};
const handleSend = (e: any) => {
console.log('触发了发送事件', e);
console.log(password);
if (
password !== '' &&
/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(password)
) {
console.log('邮箱正确!');
} else {
console.log('邮箱格式错误!');
}
};
const { location } = props;
const [forgetflag,setForgetFlag]=useState(false)
const [forgetflag, setForgetFlag] = useState(false);
useEffect(() => {
if (location.pathname=="/user/forget") {
setForgetFlag(true)
if (location.pathname == '/user/forget') {
setForgetFlag(true);
} else {
setForgetFlag(false)
setForgetFlag(false);
}
}, [location.pathname]);
return (
<div>
{
forgetflag?(
<div style={{ position: "absolute", top: -50, cursor: "pointer" }} onClick={returnHandle}><ArrowLeftOutlined style={{ fontSize: '28px' }} /></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}>Account Number</div>
<input className={styles.input} onChange={usernameHandle}/>
<div className={styles.box1}>{forgetflag?("Next"):("Password")}</div>
{
forgetflag ? (
<input className={styles.input} onChange={usernameHandle} />
<div className={styles.box1}>{forgetflag ? 'Please enter email address' : 'Password'}</div>
{forgetflag ? (
<div className={styles.box2}>
<input className={styles.input5} onChange={passwdHandle} type="password" />
<div className={styles.button2} style={{float:"right"}}>Send</div>
<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"/>
<input className={styles.input2} onChange={passwdHandle} type="password" />
<div>
<div className={styles.input3} onClick={gotoForgetHandle}>Forget 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>
</div>
)}
<Submit className={styles.button} loading={submitting} style={{ width: 330 }}>
{forgetflag ? 'Next' : '登录'}
</Submit>
</LoginForm>
</div>
);
};
export default connect(({ login, loading }: ConnectState) => ({
export default connect(({ login, loading }: ConnectState) => {
return {
userLogin: login,
submitting: loading.effects['login/login'],
}))(Login);
};
})(Login);
......@@ -17,8 +17,9 @@ export async function getFakeCaptcha(mobile: string) {
}
export async function AccountLogin(params: LoginParamsType) {
console.log("登录请求")
return request('/tos/user/login', { method: 'POST', data: params, });
console.log('登录请求');
console.log(params);
return request('/tos/user/login', { method: 'POST', data: params });
}
export async function AccountOut() {
......@@ -31,6 +32,6 @@ export interface LoginCheckParamsType {
userId: string;
}
export async function AccountCheckLogin(params: LoginCheckParamsType) {
console.log("登录确认请求")
return request('/tos/user/newCurrentUser', { method: 'POST', data: params, });
console.log('登录确认请求');
return request('/tos/user/newCurrentUser', { method: 'POST', data: params });
}
import moment from 'moment';
const format = 'HH:mm';
//2020/7/14/18:09:00
export const timestampToTime2=(timestamp:any)=>{
var date = new Date(timestamp);//*1000//getHours getMinutes getSeconds
export const timestampToTime2 = (timestamp: any) => {
var date = new Date(timestamp); //*1000//getHours getMinutes getSeconds
return (
date.getFullYear() +
'/' +
(date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) +
' ' +
date.getDate()
);
// return date.getFullYear()+'/' + (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + ' '+date.getDate()+' '+date.getHours()+':'+date.getMinutes()+':'+date.getSeconds()
};
return date.getFullYear()+'/' + (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + ' '+date.getDate()+' '+date.getHours()+':'+date.getMinutes()+':'+date.getSeconds()
}
//月份补零
function addTZero(time) {
let tmp = time + 1 < 10 ? '0' + (time+1) : (time + 1)
return tmp
let tmp = time + 1 < 10 ? '0' + (time + 1) : time + 1;
return tmp;
}
function addZero(time) {
let tmp = time + 1 < 10 ? '0' + time : time
return tmp
let tmp = time + 1 < 10 ? '0' + time : time;
return tmp;
}
const month = ("Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sept,Oct,Nov,Dec").split(",")
const MonthTurnNum = (values:any) => {
const month = 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sept,Oct,Nov,Dec'.split(',');
const MonthTurnNum = (values: any) => {
var i = 0;
month.map((item, index) => {
if (values == item) {
i=index+1
i = index + 1;
}
})
return i
}
export const getStringToTime = (time:any) => {
var date = time.split(" ")
var result = addTZero(MonthTurnNum(date[0])) + "-" + addZero(parseInt(date[1].slice(0, date[1].length - 1))) + " " + date[2]
return result
}
});
return i;
};
export const getStringToTime = (time: any) => {
var date = time.split(' ');
var result =
addTZero(MonthTurnNum(date[0])) +
'-' +
addZero(parseInt(date[1].slice(0, date[1].length - 1))) +
' ' +
date[2];
return result;
};
//03-08-2020 13:26
export const timestampToTime4 = (timestamp: any) => {
var date = new Date(timestamp);//*1000//getHours getMinutes getSeconds
var date = new Date(timestamp); //*1000//getHours getMinutes getSeconds
return addZero(date.getDate()) + '-'+ (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-'+date.getFullYear()+ ' '+addZero(date.getHours())+ ':'+addZero(date.getMinutes())
}
return (
addZero(date.getDate()) +
'-' +
(date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) +
'-' +
date.getFullYear() +
' ' +
addZero(date.getHours()) +
':' +
addZero(date.getMinutes())
);
};
// 03-06 13:26
export const timestampToTime3=(timestamp:any)=>{
var date = new Date(timestamp);//*1000//getHours getMinutes getSeconds
export const timestampToTime3 = (timestamp: any) => {
var date = new Date(timestamp); //*1000//getHours getMinutes getSeconds
return addZero(date.getDate()) + '-'+ addTZero(date.getMonth()) + ' '+addZero(date.getHours())+ ':'+addZero(date.getMinutes());
}
return (
addZero(date.getDate()) +
'-' +
addTZero(date.getMonth()) +
' ' +
addZero(date.getHours()) +
':' +
addZero(date.getMinutes())
);
};
// 03-08-2020
export const timestampToTime = (timestamp: any) => {
var date = new Date(timestamp);//*1000//getHours getMinutes getSeconds
var date = new Date(timestamp); //*1000//getHours getMinutes getSeconds
return addZero(date.getDate()) + '-'+ (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-'+date.getFullYear();
}
return (
addZero(date.getDate()) +
'-' +
(date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) +
'-' +
date.getFullYear()
);
};
//时间转换
// 时间的拆分 var tmp = ["10:00-12:00", "13:00-14:00"]
export const timeToMoment = (tmp: any) => {
if (tmp == null) return null
if (tmp == null) return null;
// var result = new Array()
// tmp.map((item:any, index:any) => {
// var piece = item.split('-')
// result.push([moment(piece[0], format), moment(piece[1], format)])
// })
// return result;
var piece = tmp.split('-')
return [moment(piece[0], format), moment(piece[1], format)]
}
var piece = tmp.split('-');
return [moment(piece[0], format), moment(piece[1], format)];
};
export const MomentToTime= (tmp: any) => {
if (tmp == null) return null
export const MomentToTime = (tmp: any) => {
if (tmp == null) return null;
return (tmp.format("YYYY-MM-DD HH:mm:ss"))
}
export const TimeToMoment2= (tmp: any) => {
if (tmp == null) return null
return tmp.format('YYYY-MM-DD HH:mm:ss');
};
export const TimeToMoment2 = (tmp: any) => {
if (tmp == null) return null;
return moment(tmp, "YYYY-MM-DD HH:mm:ss")
}
return moment(tmp, 'YYYY-MM-DD HH:mm:ss');
};
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