subscriber.jsx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. import React from 'react';
  2. import { Carousel, Icon, message, Row, Col, Select, Radio, Checkbox, Input, InputNumber, Button, Table, Spin, Pagination } from 'antd';
  3. import '../portal.less';
  4. import logoImg from '../../../../image/logo.png';
  5. import searchImg from '../../../../image/search.png';
  6. import slideImg from '../../../../image/slide_img_1.png';
  7. import { techFieldList, getTechField } from '../../DicTechFieldList';
  8. import { provinceList, getProvince } from '../../NewDicProvinceList';
  9. import { companySearch } from '../../tools';
  10. import ajax from 'jquery/src/ajax/xhr.js';
  11. import $ from 'jquery/src/ajax';
  12. import avatarImg from '../../../../image/avatarImg.png';
  13. const SubContent = React.createClass({
  14. loadData(pageNo) {
  15. this.setState({
  16. loading: true
  17. });
  18. $.ajax({
  19. method: "get",
  20. dataType: "json",
  21. url: globalConfig.context + "/portal/search/subscriberList",
  22. data: {
  23. "level": this.state.level, //认证状态 (0--未认证,1--认证)
  24. "type": this.state.type, //用户类型 (0--个人用户,1--组织用户)
  25. "field": this.state.firstField ? ((this.state.firstField || '') + ',' + (this.state.secondField || '') + ',' + (this.state.thirdField || '')) : null,
  26. "province": this.state.province,
  27. "city": this.state.city,
  28. "area": this.state.area,
  29. "name": this.state.searchName,
  30. "pageNo": pageNo || 1,
  31. "pageSize": this.state.pagination.pageSize
  32. },
  33. success: function (data) {
  34. let theArr = [];
  35. if (!data.data || !data.data.list) {
  36. if (data.error && data.error.length) {
  37. message.warning(data.error[0].message);
  38. };
  39. } else {
  40. for (let i = 0; i < data.data.list.length; i++) {
  41. let thisdata = data.data.list[i];
  42. theArr.push({
  43. key: i,
  44. uid: thisdata.uid, //用户ID
  45. identityId: thisdata.identityId, //认证ID (详情接口传入ID)
  46. username: thisdata.username,// 用户名称
  47. unitName: thisdata.unitName,
  48. type: this.state.type,
  49. personPortraitUrl: thisdata.personPortraitUrl,//用户头像URL
  50. logoUrl: thisdata.logoUrl,
  51. achievementNum: thisdata.achievementNum, //科技成果数量
  52. demandNum: thisdata.demandNum, //科技需求数量
  53. province: thisdata.province
  54. });
  55. };
  56. };
  57. this.state.pagination.pageNo = data.data.pageNo;
  58. this.state.pagination.total = data.data.totalCount;
  59. this.setState({
  60. dataSource: theArr,
  61. pagination: this.state.pagination
  62. });
  63. }.bind(this),
  64. }).done(function (data) {
  65. if (data.error && data.error.length) {
  66. message.warning(data.error[0].message);
  67. };
  68. this.setState({
  69. loading: false
  70. });
  71. }.bind(this));
  72. },
  73. getInitialState() {
  74. return {
  75. loading: false,
  76. type: 0,
  77. pagination: {
  78. pageNo: 1,
  79. pageSize: 15,
  80. total: 0
  81. },
  82. dataSource: []
  83. };
  84. },
  85. componentWillMount() {
  86. let theFieldArr = [], theProvinceArr = [];
  87. techFieldList.map((item) => {
  88. theFieldArr.push(
  89. <Select.Option key={item.value}>{item.label}</Select.Option>
  90. )
  91. });
  92. provinceList.map((item) => {
  93. theProvinceArr.push(
  94. <Select.Option key={item.id}>{item.name}</Select.Option>
  95. )
  96. });
  97. this.state.fieldFirstOption = theFieldArr;
  98. this.state.provinceOption = theProvinceArr;
  99. this.loadData();
  100. },
  101. fieldFirstChange(e) {
  102. let theArr = [];
  103. techFieldList.map((item) => {
  104. if (item.value == e) {
  105. item.children.map((children) => {
  106. theArr.push(
  107. <Select.Option key={children.value}>{children.label}</Select.Option>
  108. )
  109. });
  110. }
  111. });
  112. this.setState({
  113. fieldSecondOption: theArr,
  114. firstField: e,
  115. secondField: undefined,
  116. thirdField: undefined
  117. })
  118. },
  119. fieldSecondChange(e) {
  120. let theArr = [], _me = this;
  121. techFieldList.map((item) => {
  122. if (item.value == _me.state.firstField) {
  123. item.children.map((children) => {
  124. if (children.value == e) {
  125. children.children.map((third) => {
  126. theArr.push(
  127. <Select.Option key={third.value}>{third.label}</Select.Option>
  128. )
  129. })
  130. }
  131. });
  132. }
  133. });
  134. this.setState({
  135. fieldThirdOption: theArr,
  136. secondField: e,
  137. thirdField: undefined
  138. })
  139. },
  140. provinceChange(e) {
  141. let theArr = [];
  142. provinceList.map((item) => {
  143. if (item.id == e) {
  144. item.cityList.map((city) => {
  145. theArr.push(
  146. <Select.Option key={city.id}>{city.name}</Select.Option>
  147. )
  148. });
  149. }
  150. });
  151. this.setState({
  152. cityOption: theArr,
  153. province: e,
  154. city: undefined,
  155. area: undefined
  156. })
  157. },
  158. cityChange(e) {
  159. let theArr = [], _me = this;
  160. provinceList.map((item) => {
  161. if (item.id == _me.state.province) {
  162. item.cityList.map((city) => {
  163. if (city.id == e) {
  164. city.areaList.map((area) => {
  165. theArr.push(
  166. <Select.Option key={area.id}>{area.name}</Select.Option>
  167. )
  168. });
  169. };
  170. });
  171. };
  172. });
  173. this.setState({
  174. areaOption: theArr,
  175. city: e,
  176. area: undefined
  177. })
  178. },
  179. tableRowClick(record, index) {
  180. window.open(globalConfig.context + '/user/subscriberDetail.html?rid=' + record.uid + '&type=' + record.type);
  181. },
  182. interest(e) {
  183. this.setState({
  184. loading: true
  185. });
  186. $.ajax({
  187. method: "POST",
  188. dataType: "json",
  189. url: globalConfig.context + "/api/user/interest/interestUser",
  190. data: {
  191. toUid: e
  192. }
  193. }).done(function (data) {
  194. if (data.error && data.error.length) {
  195. message.warning(data.error[0].message);
  196. };
  197. this.setState({
  198. loading: false
  199. });
  200. }.bind(this));
  201. },
  202. cancelInterest(e) {
  203. this.setState({
  204. loading: true
  205. });
  206. $.ajax({
  207. method: "POST",
  208. dataType: "json",
  209. url: globalConfig.context + "/api/user/interest/cancelInterest",
  210. data: {
  211. interestId: e
  212. }
  213. }).done(function (data) {
  214. if (data.error && data.error.length) {
  215. message.warning(data.error[0].message);
  216. };
  217. this.setState({
  218. loading: false
  219. });
  220. }.bind(this));
  221. },
  222. render() {
  223. const { pageNo, pageSize, total } = this.state.pagination;
  224. const _me = this;
  225. return (
  226. <div className="portal-body">
  227. <div className="portal-nav clearfix">
  228. <div className="nav-logoBox">
  229. <img src={logoImg} alt="" />
  230. </div>
  231. <ul className="nav-list clearfix">
  232. <li className={this.props.searchType == 'achievement' ? 'active' : ''}><a href={"/portal/search/achievement.html"}>科技成果</a></li>
  233. <li className={this.props.searchType == 'demand' ? 'active' : ''}><a href={"/portal/search/demand.html"}>科技需求</a></li>
  234. <li className={this.props.searchType == 'subscriber' ? 'active' : ''}><a href={"/portal/search/subscriber.html"}>伙伴/行家</a></li>
  235. </ul>
  236. <div className="nav-search">
  237. <Input onChange={(e) => { this.state.searchName = e.target.value; }} />
  238. <Button onClick={() => { this.loadData() }}>
  239. <img src={searchImg} alt="" />
  240. </Button>
  241. </div>
  242. </div>
  243. <Carousel autoplay className="portal-carousel">
  244. <div className="slide-box"><img src={slideImg} alt="" /></div>
  245. <div className="slide-box"><img src={slideImg} alt="" /></div>
  246. <div className="slide-box"><img src={slideImg} alt="" /></div>
  247. <div className="slide-box"><img src={slideImg} alt="" /></div>
  248. </Carousel>
  249. <div className="portal-content clearfix" >
  250. <Row className="search-criteria">
  251. <Col className="search-title" span={2}>
  252. <span>行业分类</span>
  253. </Col>
  254. <Col className="search-select" span={22}>
  255. <Select style={{ width: 160, marginRight: '10px', marginBottom: '10px' }}
  256. value={this.state.firstField}
  257. placeholder="请选择行业一级分类"
  258. notFoundContent="未获取到行业分类"
  259. showSearch
  260. filterOption={companySearch}
  261. onChange={this.fieldFirstChange}>
  262. {this.state.fieldFirstOption}
  263. </Select>
  264. <Select style={{ width: 200, marginRight: '10px', marginBottom: '10px' }}
  265. value={this.state.secondField}
  266. placeholder="请选择行业二级分类"
  267. notFoundContent="未获取到行业分类"
  268. showSearch
  269. filterOption={companySearch}
  270. onChange={this.fieldSecondChange}>
  271. {this.state.fieldSecondOption}
  272. </Select>
  273. <Select style={{ width: 240, marginRight: '10px', marginBottom: '10px' }}
  274. value={this.state.thirdField}
  275. placeholder="请选择行业三级分类"
  276. notFoundContent="未获取到行业分类"
  277. showSearch
  278. filterOption={companySearch}
  279. onChange={(e) => { this.setState({ thirdField: e }) }}>
  280. {this.state.fieldThirdOption}
  281. </Select>
  282. <Button type="ghost" style={{ marginLeft: '20px' }}
  283. onClick={() => {
  284. this.setState({
  285. firstField: undefined,
  286. secondField: undefined,
  287. thirdField: undefined
  288. });
  289. this.state.firstField = undefined;
  290. this.state.secondField = undefined;
  291. this.state.thirdField = undefined;
  292. this.loadData();
  293. }}>不限</Button>
  294. </Col>
  295. </Row>
  296. <Row className="search-criteria">
  297. <Col className="search-title" span={2}>
  298. <span>地区</span>
  299. </Col>
  300. <Col className="search-select" span={22}>
  301. <Select style={{ width: 100, marginRight: '10px', marginBottom: '10px' }}
  302. value={this.state.province}
  303. placeholder="请选择省份"
  304. notFoundContent="未获取到省份列表"
  305. showSearch
  306. filterOption={companySearch}
  307. onChange={this.provinceChange}>
  308. {this.state.provinceOption}
  309. </Select>
  310. <Select style={{ width: 160, marginRight: '10px', marginBottom: '10px' }}
  311. value={this.state.city}
  312. placeholder="请选择行业城市"
  313. notFoundContent="未获取到城市列表"
  314. showSearch
  315. filterOption={companySearch}
  316. onChange={this.cityChange}>
  317. {this.state.cityOption}
  318. </Select>
  319. <Select style={{ width: 160, marginRight: '10px', marginBottom: '10px' }}
  320. value={this.state.area}
  321. placeholder="请选择行政区"
  322. notFoundContent="未获取到行政区列表"
  323. showSearch
  324. filterOption={companySearch}
  325. onChange={(e) => { this.setState({ area: e }) }}>
  326. {this.state.areaOption}
  327. </Select>
  328. <Button type="ghost" style={{ marginLeft: '20px' }}
  329. onClick={() => {
  330. this.setState({
  331. province: undefined,
  332. city: undefined,
  333. area: undefined
  334. });
  335. this.state.province = undefined;
  336. this.state.city = undefined;
  337. this.state.area = undefined;
  338. this.loadData();
  339. }}>不限</Button>
  340. </Col>
  341. </Row>
  342. <Row className="search-criteria">
  343. <Col className="search-title" span={2}>
  344. <span>用户类型</span>
  345. </Col>
  346. <Col className="search-select" span={6}>
  347. <Radio.Group defaultValue={0} onChange={(e) => {
  348. this.setState({
  349. type: e.target.value
  350. });
  351. this.state.type = e.target.value;
  352. this.loadData();
  353. }}>
  354. <Radio.Button value={0}>个人</Radio.Button>
  355. <Radio.Button value={1}>组织</Radio.Button>
  356. </Radio.Group>
  357. </Col>
  358. </Row>
  359. <Spin spinning={this.state.loading}>
  360. <ul className="clearfix">
  361. {this.state.dataSource.map((item, i) => {
  362. return <li key={i} className="user-detail" onClick={() => { _me.tableRowClick(item); }}>
  363. <div className="logo">
  364. <img src={(item.personPortraitUrl || item.logoUrl) ?
  365. (globalConfig.avatarHost + "/upload" + (_me.state.type == 0 ? item.personPortraitUrl : item.logoUrl))
  366. : avatarImg} alt="头像" />
  367. </div>
  368. <div className="name">
  369. {_me.state.type == 0 ? item.username : item.unitName}
  370. </div>
  371. <div className="province">
  372. <span style={{ letterSpacing: '32px' }}>地</span>
  373. <span>区: </span>
  374. <span className="address"> {getProvince(item.province)}</span>
  375. </div>
  376. <div className="text">
  377. <span style={{ letterSpacing: '32px' }}>需</span>
  378. <span>求: </span>
  379. <span className="text-Number"> {item.demandNum} </span>
  380. <span className="text-unit"> 条</span>
  381. </div>
  382. <div className="text">
  383. <span>技术成果: </span>
  384. <span className="text-Number"> {item.achievementNum} </span>
  385. <span className="text-unit"> 条</span>
  386. </div>
  387. </li>
  388. })}
  389. </ul>
  390. <Pagination style={{ float: 'right' }}
  391. onChange={(e) => { this.loadData(e); }}
  392. total={total}
  393. showTotal={() => { return '共' + total + '条数据' }}
  394. current={pageNo}
  395. pageSize={pageSize} />
  396. </Spin>
  397. </div>
  398. </div>
  399. )
  400. }
  401. });
  402. export default SubContent;