import React ,{Component}from 'react'; import { Radio,Card,Row,Col,Icon,Pagination, message } from 'antd'; import $ from 'jquery/src/ajax'; import '@/account/demand/techDemand.less'; import '@/administration/news/news.less'; import "./coupon.less"; class DemandList extends Component { constructor(props) { super(props); this.state = { loading: false, code:'', timeV:'0', dataSource:[], nubJu:0, pagination: { defaultCurrent: 1, defaultPageSize: 10, showQuickJumper: true, pageSize:6, onChange: function (page) { this.loadData(page); }.bind(this), showTotal: function (total) { return '共' + total + '条数据'; } }, } } loadData(pageNo,state,type,time) { this.state.data = []; this.setState({ state:state, page:pageNo, loading: true, }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/user/voucher/selectDetailList", data: { pageNo: pageNo || 1, pageSize: this.state.pagination.pageSize, status: state|| 0, //状态 sort:type, sortType:time }, success: function (data) { let theArr = []; if (!data.data || !data.data.list) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; } else { for (let i = 0; i < data.data.list.length; i++) { let thisdata = data.data.list[i]; theArr.push({ key: i, id: thisdata.id, name: thisdata.name,//名称 money: thisdata.money,//面额 source: thisdata.source,//来源 starTime: thisdata.starTime,//领取时间 endTime: thisdata.endTime,//截止时间 useTime: thisdata.useTime, //使用时间 status: thisdata.status,//状态 userMobile: thisdata.userMobile,//使用人手机号 durationDay: thisdata.durationDay,//期限 }); }; }; this.state.pagination.current = data.data.pageNo; this.state.pagination.total = data.data.totalCount; if(!state){ this.setState({ nubJu:data.data.totalCount }) } if(data.data&&data.data.list&&!data.data.list.length){ this.state.pagination.current=0; this.state.pagination.total=0; }; this.setState({ total:data.data.totalCount, dataSource: theArr, pagination: this.state.pagination }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); } codeData(){ $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/user/InvitationCode", data: { } }).done(function (data) { if (!data.error.length) { this.setState({ code:data.data }) } else { message.warning(data.error[0].message); }; }.bind(this)); } handleSizeChange(e){ this.setState({ timeV:e.target.value }) this.loadData(0,e.target.value); } componentWillMount() { this.loadData(); this.codeData(); } moneyFun(state,item){ this.loadData(1,this.state.state,state,item) } render() { return (
我的抵用券

{this.state.nubJu} 张

抵用券

{this.state.code}

我的邀请码

优惠金额

{this.moneyFun(0,0)}}/> {this.moneyFun(0,1)}} />

生效时间

{this.moneyFun(1,0)}}/> {this.moneyFun(1,1)}}/>
可使用 已使用 已失效 } style={{marginTop:10}} >
{ this.state.dataSource.map(item=>{ return

技淘币:{parseInt(item.money)}

有效天数 : {item.durationDay}

名称 : {item.name}

有效日期 : {(item.starTime.split(' ')[0]).replace(/-/g,'.')} - {(item.endTime.split(' ')[0]).replace(/-/g,'.')}

}) }
{this.state.total?:''}
); } }; export default DemandList;