follow.jsx 4.6 KB

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