From feac093bdaabe32753c94d63f838a5bea32d526c Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 26 Apr 2017 17:46:25 +0800 Subject: [PATCH] update --- .../WristbandInfo/WristbandHealthInfo.js | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/components/AdminPage/Wristband/WristbandInfo/WristbandHealthInfo.js b/src/components/AdminPage/Wristband/WristbandInfo/WristbandHealthInfo.js index 53c1f3b..e699903 100644 --- a/src/components/AdminPage/Wristband/WristbandInfo/WristbandHealthInfo.js +++ b/src/components/AdminPage/Wristband/WristbandInfo/WristbandHealthInfo.js @@ -13,6 +13,8 @@ const getDayTime = ()=>{ class WristbandPathInfo extends React.Component{ state = { list: [], + page: 1, + maxPage: 1, stime: (getDayTime()), etime: (Date.now()) } @@ -24,6 +26,8 @@ class WristbandPathInfo extends React.Component{ closeView = () => { this.setState({ list: [], + page: 1, + maxPage: 1, stime: (getDayTime()), etime: (Date.now()) }, ()=>{ @@ -41,14 +45,34 @@ class WristbandPathInfo extends React.Component{ .then(response=>response.json()) .then(json => { if(json.status != 1) return showDialog(json.message); + let l = json.data.record || []; 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() { let {closeModal, open} = this.props; + + let tmpList = this.state.list.slice((this.state.page - 1) * 20, ((this.state.page - 1) * 20 + 20)) + return ( {this.closeView()}}> @@ -94,7 +118,7 @@ class WristbandPathInfo extends React.Component{ { - this.state.list.map((t,idx) => { + tmpList.map((t,idx) => { return ( {parseInt(t.wphyloghr, 16)}