|
|
@@ -12,8 +12,8 @@ import { isObjEmpty } from '../../../utils/common/common.util'
|
|
|
import SubscribeGroup
|
|
|
from '../../../components/private/subscribe/SubscribeGroup'
|
|
|
import { fetchPostObj } from '../../../utils/common/fetchRequest'
|
|
|
-import { _baseURL, _host, API } from '../../../configs/api.config'
|
|
|
-import { message } from 'antd'
|
|
|
+import { API } from '../../../configs/api.config'
|
|
|
+import { Empty, message } from 'antd'
|
|
|
import { saveListState } from '../../../redux/actions/listState'
|
|
|
import { LIST_PAGE_SIZE } from '../../../configs/constans.config'
|
|
|
|
|
|
@@ -27,7 +27,8 @@ class SubscribeList extends Component {
|
|
|
|
|
|
this.state = {
|
|
|
refreshing: true,
|
|
|
- // hasNextPage: true,
|
|
|
+ hasNextPage: true,
|
|
|
+ isEmpty: false,
|
|
|
height: document.documentElement.clientHeight,
|
|
|
subscribeDataSource: new ListView.DataSource({
|
|
|
rowHasChanged: (row1, row2) => row1 !== row2,
|
|
|
@@ -41,6 +42,7 @@ class SubscribeList extends Component {
|
|
|
this.setState({
|
|
|
height: hei,
|
|
|
refreshing: false,
|
|
|
+ isEmpty: false,
|
|
|
})
|
|
|
if (this.props.listState && !isObjEmpty(this.props.listState.listData)) {
|
|
|
mPageIndex = this.props.listState.pageIndex
|
|
|
@@ -48,14 +50,14 @@ class SubscribeList extends Component {
|
|
|
this.setState({
|
|
|
subscribeDataSource: this.state.subscribeDataSource.cloneWithRows(
|
|
|
mSubscribeList),
|
|
|
- // hasNextPage: this.props.listState.hasNextPage,
|
|
|
+ hasNextPage: this.props.listState.hasNextPage,
|
|
|
},
|
|
|
() => {
|
|
|
ReactDOM.findDOMNode(
|
|
|
this.lv).scrollTop = this.props.listState.scrollTop
|
|
|
- // if (this.state.hasNextPage) {
|
|
|
- this.loadSubscribeList()
|
|
|
- // }
|
|
|
+ if (this.state.hasNextPage) {
|
|
|
+ this.loadSubscribeList()
|
|
|
+ }
|
|
|
},
|
|
|
)
|
|
|
} else {
|
|
|
@@ -70,7 +72,13 @@ class SubscribeList extends Component {
|
|
|
}
|
|
|
|
|
|
render () {
|
|
|
- const { subscribeDataSource, height } = this.state
|
|
|
+ const {
|
|
|
+ subscribeDataSource,
|
|
|
+ height,
|
|
|
+ hasNextPage,
|
|
|
+ isEmpty,
|
|
|
+ } = this.state
|
|
|
+
|
|
|
const refreshLayout = this.getRefreshLayout()
|
|
|
return (
|
|
|
<div className='com-column-flex'>
|
|
|
@@ -79,7 +87,10 @@ class SubscribeList extends Component {
|
|
|
dataSource={subscribeDataSource}
|
|
|
initialListSize={LIST_PAGE_SIZE}
|
|
|
renderFooter={() => {
|
|
|
- return <LoadingMore/>
|
|
|
+ return (
|
|
|
+ hasNextPage ? <LoadingMore/> :
|
|
|
+ (isEmpty ? <Empty image={Empty.PRESENTED_IMAGE_SIMPLE}/> : '')
|
|
|
+ )
|
|
|
}}
|
|
|
renderRow={(rowData, sectionID, rowID) => {
|
|
|
return <SubscribeGroup
|
|
|
@@ -105,6 +116,8 @@ class SubscribeList extends Component {
|
|
|
onRefresh={() => {
|
|
|
this.setState({
|
|
|
refreshing: true,
|
|
|
+ isEmpty: false,
|
|
|
+ hasNextPage: true,
|
|
|
})
|
|
|
mPageIndex = 0
|
|
|
mSubscribeList = []
|
|
|
@@ -145,11 +158,19 @@ class SubscribeList extends Component {
|
|
|
this.setState({
|
|
|
subscribeDataSource: this.state.subscribeDataSource.cloneWithRows(
|
|
|
mSubscribeList),
|
|
|
- refreshing: false,
|
|
|
+ hasNextPage: response.data.list.length >= LIST_PAGE_SIZE,
|
|
|
+ isEmpty: false,
|
|
|
})
|
|
|
} else {
|
|
|
mPageIndex--
|
|
|
+ this.setState({
|
|
|
+ hasNextPage: false,
|
|
|
+ isEmpty: mPageIndex === 0,
|
|
|
+ })
|
|
|
}
|
|
|
+ this.setState({
|
|
|
+ refreshing: false,
|
|
|
+ })
|
|
|
}).catch(error => {
|
|
|
mPageIndex--
|
|
|
if (typeof error === 'string') {
|
|
|
@@ -178,14 +199,11 @@ class SubscribeList extends Component {
|
|
|
scrollTop: ReactDOM.findDOMNode(this.lv).scrollTop,
|
|
|
pageIndex: mPageIndex,
|
|
|
listData: mSubscribeList,
|
|
|
+ hasNextPage: this.state.hasNextPage,
|
|
|
})
|
|
|
- // window.open(
|
|
|
- // _baseURL + '/common/charts/mobileCharts.action?numId=' + subObj.NUM_ID_
|
|
|
- // + '&mainId=' + subObj.INSTANCE_ID_
|
|
|
- // + '&insId=' + subObj.ID_
|
|
|
- // + '&title=' + subObj.TITLE_, '_self',
|
|
|
- // )
|
|
|
- this.props.history.push('/subscribeChart/' + subObj.ID_ + '/' + subObj.NUM_ID_ + '/' + subObj.INSTANCE_ID_)
|
|
|
+ this.props.history.push(
|
|
|
+ '/subscribeChart/' + subObj.ID_ + '/' + subObj.NUM_ID_ + '/' +
|
|
|
+ subObj.INSTANCE_ID_)
|
|
|
}
|
|
|
}
|
|
|
}
|