React Native 版本执行0.57的规则
数据相关的控制
分页的实现,首先规定每页显示几条,也是后台接口的必传参数,如果请求回来的数据大于这个长度就认为还有数据,否则就是到底了没有数据了。
this.state = {
isLoading: false,
myVipData: [{
//订单列表tab文案
tabName: '全部',
type: ''
}, {
tabName: '待付款',
type: 'c010101'
}, {
tabName: '待发货',
type: 'c010102'
}, {
tabName: '待收货',
type: 'c010103'
}, {
tabName: '待评价',
type: 't01',
}, {
tabName: '退款/售后',
type: 'c010105'
}],
pageNum: 1,// 页码
pageSize: 10,// 每页条数
activeIndex: 0, // tab切换默认index
getorderArr: [], // 我的订单数据
time: "", //15分钟倒计时dom绑定
dataFlag: true,// 是否还有下一页
isRefresh: false,// 加载图标
}
componentWillMount() {
//接受一级页面数据
this.setState({
activeIndex: this.props.navigation.state.params.index
})
}
componentDidMount() {
// 调取商品列表方法
this._getorder(this.state.myVipData[this.state.activeIndex].type, this.state.pageNum)
}
componentWillUnmount() {
// this.timer && clearTimeout(this.timer);
}
_getorder(type, pageNum) {
if (pageNum == 1) {
this.setState({
getorderArr: [],
})
}
this.setState({
isLoading: true,
})
Fetch(requestUrl.getorder, {
'userId': UserInfo.id,
'type': type,
'pageNum': pageNum,
'pageSize': this.state.pageSize
}).then(data => {
if (data.status == 'SUCCESS') {
if (data.data.length >= this.state.pageSize) {
let tempArr = this.state.getorderArr;
tempArr = tempArr.concat(data.data);
this.setState({
dataFlag: true,
getorderArr: tempArr,
isLoading: false
})
} else {
let tempArr =