follow.jsx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. expert:thisdata.expert,
  41. introduce:thisdata.introduction&&thisdata.introduction.length>40?thisdata.introduction.substr(0,40)+'...':thisdata.introduction,
  42. img: thisdata.headPortraitUrl, //编号
  43. });
  44. };
  45. };
  46. this.setState({
  47. loading:false,
  48. dataList:theArr,
  49. total:data.data.data.totalCount
  50. })
  51. })
  52. }
  53. componentWillMount(){
  54. this.loadDataService(1)
  55. }
  56. tabFun(e){
  57. this.setState({ nub: e.target.value })
  58. switch(e.target.value){
  59. case '1':
  60. this.loadDataService(1)
  61. break;
  62. }
  63. }
  64. //分页
  65. onShowSizeChange(current, pageSize){
  66. this.setState({
  67. current:current,
  68. pageSize:pageSize
  69. })
  70. }
  71. jump(item){
  72. let url='';
  73. switch(item.expert){
  74. case 1:
  75. url = globalConfig.context+`/portal/subscriberDetail.html?uid=${item.id}&type=0`;
  76. break;
  77. case 2:
  78. url = globalConfig.context+`/portal/adviser/adviserDetail?id=${item.id}`;
  79. break;
  80. default:return;
  81. }
  82. window.open(url);
  83. }
  84. render() {
  85. const dataList =this.state.dataList || [];
  86. return <div className="user-content">
  87. <div className="title" >
  88. 我的关注
  89. </div>
  90. <div>
  91. <p style={{fontSize:16,marginBottom:15}}>智者,您困惑中的指明灯</p>
  92. </div>
  93. <div className="imgList">
  94. <Spin spinning={this.state.loading}>
  95. {dataList.length?<Row>
  96. {dataList.map((item,index)=>{
  97. return<Col span={5} key={index} onClick={(e)=>{this.jump(item)}}>
  98. <div className="img">
  99. <div className="imgHeader">
  100. <div className={item.expert=='1'?"popImgBj":'adviserInit'}>
  101. {item.img?<img src={globalConfig.avatarHost+'/upload'+item.img} alt=""/>:''}
  102. </div>
  103. <div className="divP"><p>{item.introduce}</p></div>
  104. </div>
  105. <p className="txt">{item.name?item.name:'佚名'}<span>{item.expert==1?' - (专家)':' - (顾问)'}</span></p>
  106. </div>
  107. </Col>
  108. })
  109. }
  110. </Row>:
  111. <Row style={{color:'#333'}}>暂无数据</Row>}
  112. </Spin>
  113. {this.state.total?<Pagination className="page" pageSize={8} current={this.state.current} total={this.state.total} onChange={this.onShowSizeChange.bind(this)}/>:''}
  114. </div>
  115. </div>
  116. }
  117. }
  118. export default Collection;