import * as React from 'react'; import PutOrGetBountyTable from './putOrGetBountyTable'; import CashBountyTable from './cashBountyTable'; import Paging from "@beisen/paging"; import ScrollWrap from '&/components/common/scrollWrap' import NoData from '&/components/common/noDataView'; import { getApiUrl, taker } from '&/helper'; interface Props{ data: any, tabIndex: number } export default class Tables extends React.Component{ lassName=['put-bounty-table','get-bounty-table','cash-bounty-table']; tableComs = [PutOrGetBountyTable,PutOrGetBountyTable,CashBountyTable]; // nullTool = ['尚未有任何打赏哦','尚未收到任何赏金哦','尚未提现哦'] // datas = ['in','in','cash'] state = { page: 1, //控制页数 STEP: 15, data: this.props.data.toJS() } constructor(p:Props){ super(p); this.onIndexChange = this.onIndexChange.bind(this); this.onCapacityChange = this.onCapacityChange.bind(this); } changePage=()=>{ this.setState({page:1,STEP:15}) } async onIndexChange(index:number){ const url1 = getApiUrl(`wx/pay/record?page_num=${index}&page_size=${this.state.STEP}&type=${this.props.tabIndex+1}`); const response1 = await taker(url1); const data = response1.Data; this.setState({ page: index,data:data }) } async onCapacityChange(index:number){ //页面容量变化 const step = [15, 30, 60]; const url1 = getApiUrl(`wx/pay/record?page_num=${1}&page_size=${step[index]}&type=${this.props.tabIndex+1}`); const response1 = await taker(url1); const data = response1.Data; this.setState({ STEP: step[index],page:1,data:data }) } componentDidUpdate(){ this.tabIndex = this.props.tabIndex; } tabIndex = 0; render(){ const {tabIndex} = this.props; const {page,STEP} = this.state; let Com = this.tableComs[tabIndex]; let data = this.tabIndex == tabIndex ? this.state.data:this.props.data.toJS(); const total = data.total || 0; const pagingSetting = { hidden: false, // 是否渲染 默认false total: total % STEP == 0 ? Math.floor(total / STEP) : Math.floor(total / STEP) + 1 , //总页数 currentPage: page, // 当前页数 visiblePages: 5, // 显示的页数 min = 5 capacity: STEP, // 每页条数,页面容量 capacityList: [15, 30, 60], //可选的页面容量 } const startStep = page == 1 ? 1 : (page-1) * STEP+1; // const startStep = 0; const endStep = page * STEP + 1; if(total == 0) return ; return
显示{ startStep }-{ endStep < total ? endStep : total }项,共{ total }项
{ total > STEP && }
} }