follow.jsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import React, { Component } from 'react';
  2. import { Button,Radio ,message,Row,Col, Spin,Pagination} from 'antd';
  3. import axios from 'axios';
  4. import './collection.less';
  5. class Collection extends Component {
  6. constructor(props) {
  7. super(props);
  8. this.state = {
  9. loading:false,
  10. current:1,
  11. nub:'1'
  12. };
  13. }
  14. //服务
  15. loadDataService(page){
  16. this.setState({
  17. loading:true,
  18. })
  19. let url = globalConfig.context + '/api/user/portal/listInterestedInExpert'
  20. axios.get(url,{
  21. params:{
  22. pageNo:page||1,
  23. pageSize:8
  24. }
  25. })
  26. .then(data=>{
  27. let theData=data.data.data,
  28. theArr = [];
  29. if (!data.data || !data.data.data.list) {
  30. if (data.data.error && data.data.error.length) {
  31. message.warning(data.data.error[0].message);
  32. };
  33. } else {
  34. for (let i = 0; i < theData.list.length; i++) {
  35. let thisdata = theData.list[i];
  36. theArr.push({
  37. key: i,
  38. id: thisdata.uid,
  39. name:thisdata.username,
  40. introduce:thisdata.introduction&&thisdata.introduction.length>40?thisdata.introduction.substr(0,40)+'...':thisdata.introduction,
  41. img: thisdata.headPortraitUrl, //编号
  42. });
  43. };
  44. };
  45. this.setState({
  46. loading:false,
  47. dataList:theArr,
  48. total:data.data.data.totalCount
  49. })
  50. })
  51. }
  52. componentWillMount(){
  53. this.loadDataService(1)
  54. }
  55. tabFun(e){
  56. this.setState({ nub: e.target.value })
  57. switch(e.target.value){
  58. case '1':
  59. this.loadDataService(1)
  60. break;
  61. }
  62. }
  63. //分页
  64. onShowSizeChange(current, pageSize){
  65. this.setState({
  66. current:current,
  67. pageSize:pageSize
  68. })
  69. }
  70. jump(item){
  71. let url='';
  72. switch(this.state.nub){
  73. case '1':
  74. url = globalConfig.context+`/portal/subscriberDetail.html?uid=${item.id}&type=0`;
  75. break;
  76. }
  77. window.open(url);
  78. }
  79. render() {
  80. const dataList =this.state.dataList || [];
  81. return <div className="user-content">
  82. <div className="title" >
  83. 我的关注
  84. </div>
  85. <div>
  86. <p style={{fontSize:16,marginBottom:15}}>智者,您困惑中的指明灯</p>
  87. </div>
  88. <div className="imgList">
  89. <Spin spinning={this.state.loading}>
  90. {dataList.length?<Row>
  91. {dataList.map((item,index)=>{
  92. return<Col span={6} key={index} onClick={(e)=>{this.jump(item)}}>
  93. <div className="img">
  94. <div className="imgHeader">
  95. <div className="popImgBj">
  96. {item.img?<img src={globalConfig.avatarHost+'/upload'+item.img} alt=""/>:''}
  97. </div>
  98. <div className="divP"><p>{item.introduce}</p></div>
  99. </div>
  100. <p className="txt">{item.name?item.name:'佚名'}</p>
  101. </div>
  102. </Col>
  103. })
  104. }
  105. </Row>:
  106. <Row style={{color:'#333'}}>暂无数据</Row>}
  107. </Spin>
  108. {this.state.total?<Pagination className="page" pageSize={8} current={this.state.current} total={this.state.total} onChange={this.onShowSizeChange.bind(this)}/>:''}
  109. </div>
  110. </div>
  111. }
  112. }
  113. export default Collection;