Merge branch 'master' into release

This commit is contained in:
Jay 2017-04-26 17:46:32 +08:00
commit c8c4c28dfc

View File

@ -13,6 +13,8 @@ const getDayTime = ()=>{
class WristbandPathInfo extends React.Component{ class WristbandPathInfo extends React.Component{
state = { state = {
list: [], list: [],
page: 1,
maxPage: 1,
stime: (getDayTime()), stime: (getDayTime()),
etime: (Date.now()) etime: (Date.now())
} }
@ -24,6 +26,8 @@ class WristbandPathInfo extends React.Component{
closeView = () => { closeView = () => {
this.setState({ this.setState({
list: [], list: [],
page: 1,
maxPage: 1,
stime: (getDayTime()), stime: (getDayTime()),
etime: (Date.now()) etime: (Date.now())
}, ()=>{ }, ()=>{
@ -41,14 +45,34 @@ class WristbandPathInfo extends React.Component{
.then(response=>response.json()) .then(response=>response.json())
.then(json => { .then(json => {
if(json.status != 1) return showDialog(json.message); if(json.status != 1) return showDialog(json.message);
let l = json.data.record || [];
this.setState({ this.setState({
list: json.data.record || [] list: l,
page: 1,
maxPage: Math.ceil(l.length / 20)
}) })
}) })
} }
nextPage = () => {
let {page, maxPage} = this.state;
this.setState({
page: page >= maxPage ? maxPage : page+1
})
}
prevPage = () => {
let {page} = this.state;
this.setState({
page: page <= 1 ? 1 : page-1
})
}
render() { render() {
let {closeModal, open} = this.props; let {closeModal, open} = this.props;
let tmpList = this.state.list.slice((this.state.page - 1) * 20, ((this.state.page - 1) * 20 + 20))
return ( return (
<Modal open={open} onClose={()=>{this.closeView()}}> <Modal open={open} onClose={()=>{this.closeView()}}>
<Modal.Header> <Modal.Header>
@ -94,7 +118,7 @@ class WristbandPathInfo extends React.Component{
</Table.Header> </Table.Header>
<Table.Body> <Table.Body>
{ {
this.state.list.map((t,idx) => { tmpList.map((t,idx) => {
return ( return (
<Table.Row key={idx}> <Table.Row key={idx}>
<Table.Cell>{parseInt(t.wphyloghr, 16)}</Table.Cell> <Table.Cell>{parseInt(t.wphyloghr, 16)}</Table.Cell>