class Order extends React.Component {
constructor(props) {
super(props);
this.state = {
listOptions: [{name: "全部", type: 0}, {name: "已完成", type: 5}, {name: "待付款", type: 1}, {name: "已取消", type: 3}],
allData: {},
activeIndex: 0
}
}
render() {
//生成tabTitle结构
let { activeIndex } = this.state;
var listTabTitle = this.state.listOptions.map(function(item, index) {
return <li key={index} data-index={index} className={"swiper-slide " + (index == activeIndex ? "active-nav" : "")} style={{margin:'0 0.5rem'}}>{item.name}</li>
});
//生成tabContent结构
return (
<Panel>
<Panel.header>
<Header headerLeft="back" headerLeftClick={this.goBack.bind(this)} navigationBack={this.props.navigationBack} headerTitle={Utils.getQueryString("title") || "行业报告"}></Header>
</Panel.header>
<Panel.body>
<ListTab currentName="rankingList" listTabTitle={listTabTitle} sliderChanged={this.sliderChanged.bind(this)}>
{ listTabContent }
</ListTab>
</Panel.body>
</Panel>
)
}
goBack() {
if(!!this.props.hideThis) {
this.props.hideThis();
}else {
return true;
}
}
//存储数据
requestData(orderStatus=1) {
let _this = this;
let { requestPost } = this.props;
let { allData, listOptions, activeIndex } = this.state;
requestPost(
"/auth/user/order/list",
{
page: 1,
orderStatus:orderStatus
},
function(res) {
let data = res.data;
console.log(allData);
let type = listOptions[activeIndex].type.toString();
allData[type] = data;
_this.setState({
allData: allData
});
}
)
}
把数据渲染到这上面,根据里面的type,打印出来的数据为
现在就是不知道怎么根据里面的orderState的序号把数据渲染出来,求助!! react新手, 若能解决,有偿!!