coupon.jsx 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. import React ,{Component}from 'react';
  2. import { Radio,Card,Row,Col,Icon,Pagination, message } from 'antd';
  3. import $ from 'jquery/src/ajax';
  4. import '@/account/demand/techDemand.less';
  5. import '@/administration/news/news.less';
  6. import "./coupon.less";
  7. class DemandList extends Component {
  8. constructor(props) {
  9. super(props);
  10. this.state = {
  11. loading: false,
  12. code:'',
  13. timeV:'0',
  14. dataSource:[],
  15. nubJu:0,
  16. pagination: {
  17. defaultCurrent: 1,
  18. defaultPageSize: 10,
  19. showQuickJumper: true,
  20. pageSize:6,
  21. onChange: function (page) {
  22. this.loadData(page);
  23. }.bind(this),
  24. showTotal: function (total) {
  25. return '共' + total + '条数据';
  26. }
  27. },
  28. }
  29. }
  30. loadData(pageNo,state,type,time) {
  31. this.state.data = [];
  32. this.setState({
  33. state:state,
  34. page:pageNo,
  35. loading: true,
  36. });
  37. $.ajax({
  38. method: "get",
  39. dataType: "json",
  40. crossDomain: false,
  41. url: globalConfig.context + "/api/user/voucher/selectDetailList",
  42. data: {
  43. pageNo: pageNo || 1,
  44. pageSize: this.state.pagination.pageSize,
  45. status: state|| 0, //状态
  46. sort:type,
  47. sortType:time
  48. },
  49. success: function (data) {
  50. let theArr = [];
  51. if (!data.data || !data.data.list) {
  52. if (data.error && data.error.length) {
  53. message.warning(data.error[0].message);
  54. };
  55. } else {
  56. for (let i = 0; i < data.data.list.length; i++) {
  57. let thisdata = data.data.list[i];
  58. theArr.push({
  59. key: i,
  60. id: thisdata.id,
  61. name: thisdata.name,//名称
  62. money: thisdata.money,//面额
  63. source: thisdata.source,//来源
  64. starTime: thisdata.starTime,//领取时间
  65. endTime: thisdata.endTime,//截止时间
  66. useTime: thisdata.useTime, //使用时间
  67. status: thisdata.status,//状态
  68. userMobile: thisdata.userMobile,//使用人手机号
  69. durationDay: thisdata.durationDay,//期限
  70. });
  71. };
  72. };
  73. this.state.pagination.current = data.data.pageNo;
  74. this.state.pagination.total = data.data.totalCount;
  75. if(!state){
  76. this.setState({
  77. nubJu:data.data.totalCount
  78. })
  79. }
  80. if(data.data&&data.data.list&&!data.data.list.length){
  81. this.state.pagination.current=0;
  82. this.state.pagination.total=0;
  83. };
  84. this.setState({
  85. total:data.data.totalCount,
  86. dataSource: theArr,
  87. pagination: this.state.pagination
  88. });
  89. }.bind(this),
  90. }).always(function () {
  91. this.setState({
  92. loading: false
  93. });
  94. }.bind(this));
  95. }
  96. codeData(){
  97. $.ajax({
  98. method: "get",
  99. dataType: "json",
  100. crossDomain: false,
  101. url: globalConfig.context + "/api/user/InvitationCode",
  102. data: {
  103. }
  104. }).done(function (data) {
  105. if (!data.error.length) {
  106. this.setState({
  107. code:data.data
  108. })
  109. } else {
  110. message.warning(data.error[0].message);
  111. };
  112. }.bind(this));
  113. }
  114. handleSizeChange(e){
  115. this.setState({
  116. timeV:e.target.value
  117. })
  118. this.loadData(0,e.target.value);
  119. }
  120. componentWillMount() {
  121. this.loadData();
  122. this.codeData();
  123. }
  124. moneyFun(state,item){
  125. this.loadData(1,this.state.state,state,item)
  126. }
  127. render() {
  128. return (
  129. <div className="user-content" >
  130. <div className="content-title">
  131. <span>我的抵用券</span>
  132. </div>
  133. <div className="user-search">
  134. <Card >
  135. <Row>
  136. <Col span={6}>
  137. <p>{this.state.nubJu} 张</p>
  138. <p>抵用券</p>
  139. </Col>
  140. <Col span={6}>
  141. <p>{this.state.code}</p>
  142. <p>我的邀请码</p>
  143. </Col>
  144. <Col span={12}>
  145. <div className="discount">
  146. <p>优惠金额</p>
  147. <div className="discountMoney">
  148. <Icon type="caret-up" className="up" onClick={()=>{this.moneyFun(0,0)}}/>
  149. <Icon type="caret-down" className="down" onClick={()=>{this.moneyFun(0,1)}} />
  150. </div>
  151. </div>
  152. <div className="effective">
  153. <p>生效时间</p>
  154. <div className="time">
  155. <Icon type="caret-up" className="up" onClick={()=>{this.moneyFun(1,0)}}/>
  156. <Icon type="caret-down" className="down" onClick={()=>{this.moneyFun(1,1)}}/>
  157. </div>
  158. </div>
  159. </Col>
  160. </Row>
  161. </Card>
  162. <Card title={<Radio.Group value={this.state.timeV} onChange={this.handleSizeChange.bind(this)}>
  163. <Radio.Button value="0">可使用</Radio.Button>
  164. <Radio.Button value="1">已使用</Radio.Button>
  165. <Radio.Button value="2">已失效</Radio.Button>
  166. </Radio.Group>} style={{marginTop:10}}
  167. >
  168. <div className="cardCode">
  169. <Row gutter={20}>
  170. {
  171. this.state.dataSource.map(item=>{
  172. return <Col span={8} style={{marginBottom:10}}>
  173. <Card>
  174. <div className="discountList">
  175. <p>技淘币:<span>{parseInt(item.money)}</span> 枚</p>
  176. <div className="discountListTxt">
  177. <p>有效天数 : {item.durationDay}</p>
  178. <p>名称 : {item.name}</p>
  179. <p>有效日期 : {(item.starTime.split(' ')[0]).replace(/-/g,'.')} - {(item.endTime.split(' ')[0]).replace(/-/g,'.')}</p>
  180. </div>
  181. </div>
  182. </Card>
  183. </Col>
  184. })
  185. }
  186. </Row>
  187. </div>
  188. {this.state.total?<Pagination className="page" {...this.state.pagination}/>:''}
  189. </Card>
  190. </div>
  191. </div >
  192. );
  193. }
  194. };
  195. export default DemandList;