content.jsx 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. import React from 'react';
  2. import { Icon, message, Row, Col, Spin, Tag, Pagination, Modal, Button } from 'antd';
  3. import './detail.less';
  4. import { getSearchUrl, getAchievementCategory, getDemandType, getTransferMode, getMaturity } from '../tools';
  5. import { getProvince } from '../NewDicProvinceList';
  6. import { getIndustryCategory } from '../DicIndustryList';
  7. import { getTechField } from '../DicTechFieldList';
  8. import ajax from 'jquery/src/ajax/xhr.js'
  9. import $ from 'jquery/src/ajax';
  10. import avatarImg from '../../../image/avatarImg.png';
  11. import list_title_ico_1 from '../../../image/list_title_ico_1.png';
  12. import list_title_ico_2 from '../../../image/list_title_ico_2.png';
  13. import list_title_ico_3 from '../../../image/list_title_ico_3.png';
  14. import demand_ico_5 from '../../../image/demand_ico_5.png';
  15. import demand_ico_3 from '../../../image/demand_ico_3.png';
  16. import demand_ico_2 from '../../../image/demand_ico_2.png';
  17. import demand_ico_1 from '../../../image/demand_ico_1.png';
  18. import achievement_ico_1 from '../../../image/achievement_ico_1.png';
  19. import achievement_ico_2 from '../../../image/achievement_ico_2.png';
  20. import score_ioc from '../../../image/score_ioc.png';
  21. import demand_sup from '../../../image/demand_sup.png';
  22. const Content = React.createClass({
  23. loadData () {
  24. this.setState({
  25. loading: true
  26. });
  27. $.ajax({
  28. method: "get",
  29. dataType: "json",
  30. url: globalConfig.context + "/api/user/partner/detail",
  31. data: {
  32. uid: this.state.uid,
  33. type: this.state.type
  34. }
  35. }).done(function (data) {
  36. if (data.error && data.error.length) {
  37. message.warning(data.error[0].message);
  38. } else {
  39. this.state.data = data.data || {};
  40. this.state.theField = this.state.type == 0 ? (data.data.engagedField ? data.data.engagedField.split(',') : []) : (data.data.field ? data.data.field.split(',') : []);
  41. this.state.theImgsrc = this.state.type == 0 ? (data.data.lifePhotoUrl ? data.data.lifePhotoUrl.split(',') : []) : (data.data.publicityPictureUrl ? data.data.publicityPictureUrl.split(',') : []);
  42. }
  43. this.setState({
  44. data: this.state.data,
  45. theField: this.state.theField,
  46. theImgsrc: this.state.theImgsrc,
  47. loading: false
  48. });
  49. }.bind(this));
  50. },
  51. achievementLoadData (pageNo) {
  52. this.setState({
  53. loading: true
  54. });
  55. $.ajax({
  56. method: "get",
  57. dataType: "json",
  58. crossDomain: false,
  59. url: globalConfig.context + "/api/user/partner/achievementList",
  60. data: {
  61. ownerId: this.state.uid,
  62. pageNo: pageNo || 1,
  63. pageSize: this.state.achievementPagination.pageSize
  64. },
  65. success: function (data) {
  66. let theArr = [];
  67. if (!data.data || !data.data.list) {
  68. if (data.error && data.error.length) {
  69. message.warning(data.error[0].message);
  70. };
  71. } else {
  72. for (let i = 0; i < data.data.list.length; i++) {
  73. let thisdata = data.data.list[i];
  74. theArr.push({
  75. key: i,
  76. id: thisdata.id,
  77. serialNumber: thisdata.serialNumber,
  78. dataCategory: thisdata.dataCategory,
  79. name: thisdata.name,
  80. transferPrice: thisdata.transferPrice,
  81. fieldA: thisdata.fieldA,
  82. fieldB: thisdata.fieldB,
  83. bargainingMode: thisdata.bargainingMode,
  84. maturity: thisdata.maturity,
  85. keyword: thisdata.keyword,
  86. category: thisdata.category,
  87. ownerType: thisdata.ownerType,
  88. releaseDate: thisdata.releaseDate,
  89. releaseDateFormattedDate: thisdata.releaseDateFormattedDate,
  90. });
  91. };
  92. }
  93. this.state.achievementPagination.current = data.data.pageNo;
  94. this.state.achievementPagination.total = data.data.totalCount;
  95. this.setState({
  96. achievementDataSource: theArr,
  97. achievementPagination: this.state.achievementPagination
  98. });
  99. }.bind(this),
  100. }).always(function () {
  101. this.setState({
  102. loading: false
  103. });
  104. }.bind(this));
  105. },
  106. demandLoadData (pageNo) {
  107. this.setState({
  108. loading: true
  109. });
  110. $.ajax({
  111. method: "get",
  112. dataType: "json",
  113. crossDomain: false,
  114. url: globalConfig.context + "/api/user/partner/demandList",
  115. data: {
  116. employerId: this.state.uid,
  117. pageNo: pageNo || 1,
  118. pageSize: this.state.demandPagination.pageSize
  119. },
  120. success: function (data) {
  121. let theArr = [];
  122. if (!data.data || !data.data.list) {
  123. if (data.error && data.error.length) {
  124. message.warning(data.error[0].message);
  125. };
  126. } else {
  127. for (let i = 0; i < data.data.list.length; i++) {
  128. let thisdata = data.data.list[i];
  129. theArr.push({
  130. key: i,
  131. id: thisdata.id,
  132. serialNumber: thisdata.serialNumber,
  133. dataCategory: thisdata.dataCategory,
  134. problemDes: thisdata.problemDes,
  135. budgetCost: thisdata.budgetCost,
  136. name: thisdata.name,
  137. keyword: thisdata.keyword,
  138. releaseDate: thisdata.releaseDate,
  139. demandType: thisdata.demandType,
  140. industryCategoryA: thisdata.industryCategoryA,
  141. industryCategoryB: thisdata.industryCategoryB,
  142. validityPeriod: thisdata.validityPeriod,
  143. validityPeriodFormattedDate: thisdata.validityPeriodFormattedDate,
  144. releaseDateFormattedDate: thisdata.releaseDateFormattedDate
  145. });
  146. };
  147. }
  148. this.state.demandPagination.current = data.data.pageNo;
  149. this.state.demandPagination.total = data.data.totalCount;
  150. this.setState({
  151. demandDataSource: theArr,
  152. demandPagination: this.state.demandPagination
  153. });
  154. }.bind(this),
  155. }).always(function () {
  156. this.setState({
  157. loading: false
  158. });
  159. }.bind(this));
  160. },
  161. interestClick () {
  162. this.setState({
  163. loading: true
  164. });
  165. $.ajax({
  166. method: "post",
  167. dataType: "json",
  168. crossDomain: false,
  169. url: globalConfig.context + '/api/user/interest/interestUser',
  170. data: {
  171. toUid: this.state.uid
  172. },
  173. success: function (data) {
  174. if (data.error && data.error.length) {
  175. message.warning(data.error[0].message);
  176. } else {
  177. this.loadData();
  178. };
  179. }.bind(this),
  180. }).always(function () {
  181. this.setState({
  182. loading: false
  183. });
  184. }.bind(this));;
  185. },
  186. addConsultorder () {
  187. this.setState({
  188. loading: true
  189. });
  190. $.ajax({
  191. method: "post",
  192. dataType: "json",
  193. crossDomain: false,
  194. url: globalConfig.context + '/api/user/consultorder/add',
  195. data: {
  196. toUserId: this.state.uid
  197. },
  198. success: function (data) {
  199. if (data.error && data.error.length) {
  200. message.warning(data.error[0].message);
  201. } else {
  202. this.loadData();
  203. };
  204. }.bind(this),
  205. }).always(function () {
  206. this.setState({
  207. visible: false,
  208. loading: false
  209. });
  210. }.bind(this));;
  211. },
  212. consultClick () {
  213. $.ajax({
  214. method: "get",
  215. dataType: "json",
  216. url: globalConfig.context + "/api/user/consultorder/price"
  217. }).done(function (data) {
  218. if (data.error && data.error.length) {
  219. message.warning(data.error[0].message);
  220. } else {
  221. this.state.consultPrice = data.data || 0;
  222. }
  223. this.setState({
  224. visible: true
  225. });
  226. }.bind(this));
  227. },
  228. cancelInterestClick () {
  229. this.setState({
  230. loading: true
  231. });
  232. $.ajax({
  233. method: "post",
  234. dataType: "json",
  235. crossDomain: false,
  236. url: globalConfig.context + '/api/user/interest/cancelInterest',
  237. data: {
  238. interestId: this.state.data.interestId
  239. },
  240. success: function (data) {
  241. if (data.error && data.error.length) {
  242. message.warning(data.error[0].message);
  243. } else {
  244. this.loadData();
  245. };
  246. }.bind(this),
  247. }).always(function () {
  248. this.setState({
  249. loading: false
  250. });
  251. }.bind(this));;
  252. },
  253. getInitialState () {
  254. return {
  255. loading: false,
  256. visible: false,
  257. consultPrice: 0,
  258. theField: [],
  259. data: {},
  260. theImgsrc: [],
  261. achievementPagination: {
  262. pageNo: 1,
  263. pageSize: 10,
  264. total: 0
  265. },
  266. achievementDataSource: [],
  267. demandDataSource: [],
  268. demandPagination: {
  269. pageNo: 1,
  270. pageSize: 10,
  271. total: 0
  272. },
  273. };
  274. },
  275. componentWillMount () {
  276. if (window.location.search) {
  277. let theObj = getSearchUrl(window.location.search);
  278. if (theObj.rid && theObj.rid != 'null') {
  279. this.state.uid = theObj.rid;
  280. this.state.type = theObj.type;
  281. this.loadData();
  282. this.achievementLoadData();
  283. this.demandLoadData();
  284. };
  285. };
  286. },
  287. achievementListClick (record, index) {
  288. window.open(globalConfig.context + '/portal/detail/achievementDetail.html?id=' + record.id + '&type=' + record.ownerType);
  289. },
  290. demandListClick (record, index) {
  291. window.open(globalConfig.context + '/portal/detail/demandDetail.html?id=' + record.id + '&type=' + record.dataCategory);
  292. },
  293. render () {
  294. const theData = this.state.data;
  295. return (
  296. <Spin spinning={this.state.loading} style={{ marginBottom: '80px' }} >
  297. <div className="detail-content">
  298. <Row>
  299. <Col span={8}>
  300. <div className="avatar-box">
  301. <img src={(theData.personPortraitUrl || theData.logoUrl) ?
  302. (globalConfig.avatarHost + "/upload" + (this.state.type == 0 ? theData.personPortraitUrl : theData.logoUrl))
  303. : avatarImg} alt="头像" />
  304. </div>
  305. <div className="interest">
  306. {theData.interestId ? <a onClick={this.cancelInterestClick}><Icon type="heart" /> 不感兴趣</a>
  307. : <a onClick={this.interestClick}><Icon type="heart-o" /> 感兴趣</a>}
  308. </div>
  309. <div className="interest">
  310. <a onClick={() => { this.consultClick() }}><Icon type="message" /> 线下咨询</a>
  311. </div>
  312. </Col>
  313. <Col span={16} className="avatar-right">
  314. <div className="user-name">{this.state.type == 0 ? theData.username : theData.unitName}</div>
  315. <div>
  316. Lv.
  317. <span className="user-level">{theData.level}</span>
  318. <span className="user-type">{this.state.type == 0 ? '个人' : '组织'}</span>
  319. </div>
  320. <div className="user-desc">
  321. <span>简介:</span>
  322. {this.state.type == 0 ? theData.personalProfile : theData.companyIntroduction}</div>
  323. </Col>
  324. </Row>
  325. <Row className="all-row">
  326. <Col span={4}>
  327. <div className="column-title">所在地:</div>
  328. </Col>
  329. <Col span={20}>
  330. <div className="column-text">{getProvince(theData.province, theData.city, theData.area)}</div>
  331. </Col>
  332. </Row>
  333. <Row className="all-row">
  334. <Col span={4}>
  335. <div className="column-title">专业领域:</div>
  336. </Col>
  337. <Col span={20}>
  338. <div className="column-text">{getTechField(this.state.theField[0], this.state.theField[1], this.state.theField[2])}</div>
  339. </Col>
  340. </Row>
  341. <Row className="all-row">
  342. <Col span={4}>
  343. <div className="column-title">能力标签:</div>
  344. </Col>
  345. <Col span={20}>
  346. <div className="column-text">
  347. {theData.abilityLabel ? theData.abilityLabel.split(',').map((item) => {
  348. return <Tag key={item}>{item}</Tag>
  349. }) : ''}
  350. </div>
  351. </Col>
  352. </Row>
  353. </div>
  354. <div className="detail-list">
  355. <div className="list-title">
  356. <img src={list_title_ico_1} alt="" />
  357. <span>用户展示</span>
  358. </div>
  359. <div className="column-img clearfix">
  360. {this.state.theImgsrc.map((item, i) => {
  361. return <div className="img-box" key={i}>
  362. <img src={globalConfig.avatarHost + "/upload" + item} alt=""
  363. onClick={() => { window.open(globalConfig.avatarHost + "/upload" + item) }} />
  364. </div>
  365. })}
  366. </div>
  367. </div>
  368. <div className="detail-list">
  369. <div className="list-title">
  370. <img src={list_title_ico_2} alt="" />
  371. <span>技术成果</span>
  372. </div>
  373. <ul className="detail_interest_sub clearfix">
  374. {this.state.achievementDataSource.map((item, i) => {
  375. return <li key={item.id} onClick={() => { this.achievementListClick(item) }}
  376. style={{ float: 'left', marginLeft: '18px', width: '48%' }}>
  377. <div className="interest_list_title" style={{ paddingLeft: '20px' }}>
  378. <span>{item.name}</span>
  379. </div>
  380. <div className="detial_sub">
  381. <span className="detial_sub_icon">
  382. <img src={demand_ico_5} alt="成果" />
  383. </span>
  384. <span className="detial_sub_title">关键词: </span>
  385. <span className="detial_sub_text">{item.keyword}</span>
  386. </div>
  387. <div className="detial_sub">
  388. <span className="detial_sub_icon">
  389. <img src={demand_ico_2} alt="类型" />
  390. </span>
  391. <span className="detial_sub_title">技术类型: </span>
  392. <span className="detial_sub_text">{getAchievementCategory(item.category)}</span>
  393. </div>
  394. <div className="detial_sub">
  395. <span className="detial_sub_icon">
  396. <img src={demand_ico_1} alt="行业" />
  397. </span>
  398. <span className="detial_sub_title">行业分类: </span>
  399. <span className="detial_sub_text">{getIndustryCategory(item.fieldA, item.fieldB)}</span>
  400. </div>
  401. <div className="detial_sub">
  402. <span className="detial_sub_icon">
  403. <img src={demand_ico_3} alt="标价" />
  404. </span>
  405. <span className="detial_sub_title">标价: </span>
  406. <span className="money_text">{item.transferPrice ? (item.transferPrice + '万元') : '价格面议'}</span>
  407. </div>
  408. <div className="detial_sub">
  409. <span className="detial_sub_icon">
  410. <img src={achievement_ico_1} alt="交易方式" />
  411. </span>
  412. <span className="detial_sub_title">交易方式: </span>
  413. <span className="money_text">{item.bargainingMode == 1 ? '定价' : '面议'}</span>
  414. </div>
  415. <div className="detial_sub">
  416. <span className="detial_sub_icon">
  417. <img src={achievement_ico_2} alt="成熟度" />
  418. </span>
  419. <span className="detial_sub_title">技术成熟度: </span>
  420. <span className="detial_sub_score" >
  421. <span style={{ width: (item.maturity ? Number(item.maturity) * 20 : 0) + '%' }}>
  422. <img src={score_ioc} alt={getMaturity(item.maturity)} />
  423. </span>
  424. </span>
  425. </div>
  426. </li>
  427. })}
  428. </ul>
  429. <Pagination style={{ float: 'right' }}
  430. onChange={(e) => { this.achievementLoadData(e); }}
  431. total={this.state.achievementPagination.total}
  432. showTotal={() => { return '共' + this.state.achievementPagination.total + '条数据' }}
  433. current={this.state.achievementPagination.pageNo}
  434. pageSize={this.state.achievementPagination.pageSize} />
  435. </div>
  436. <div className="detail-list">
  437. <div className="list-title">
  438. <img src={list_title_ico_3} alt="" />
  439. <span>技术需求</span>
  440. </div>
  441. <ul className="detail_interest_sub clearfix">
  442. {this.state.demandDataSource.map((item, i) => {
  443. return <li key={item.id} onClick={() => { this.demandListClick(item) }}>
  444. <div className="interest_list_title">
  445. <img src={demand_sup} alt="" />
  446. <span>{item.name}</span>
  447. </div>
  448. <div className="detial_sub">
  449. <span className="detial_sub_icon">
  450. <img src={demand_ico_5} alt="需求" />
  451. </span>
  452. <span className="detial_sub_title">关键词: </span>
  453. <span className="detial_sub_text">{item.keyword}</span>
  454. </div>
  455. <div className="detial_sub">
  456. <span className="detial_sub_icon">
  457. <img src={demand_ico_5} alt="需求" />
  458. </span>
  459. <span className="detial_sub_title">需求描述: </span>
  460. <span className="detial_sub_text">{item.problemDes}</span>
  461. </div>
  462. <div className="detial_sub">
  463. <span className="detial_sub_icon">
  464. <img src={demand_ico_3} alt="预算" />
  465. </span>
  466. <span className="detial_sub_title">预算: </span>
  467. <span className="money_text">{item.budgetCost ? item.budgetCost + ' 元' : '价格面议'}</span>
  468. </div>
  469. <div className="detial_sub">
  470. <span className="detial_sub_icon">
  471. <img src={demand_ico_2} alt="类型" />
  472. </span>
  473. <span className="detial_sub_title">类型: </span>
  474. <span className="detial_sub_text">{getDemandType(item.demandType)}</span>
  475. </div>
  476. <div className="detial_sub">
  477. <span className="detial_sub_icon">
  478. <img src={demand_ico_1} alt="行业" />
  479. </span>
  480. <span className="detial_sub_title">行业: </span>
  481. <span className="detial_sub_text">{getIndustryCategory(item.industryCategoryA, item.industryCategoryB)}</span>
  482. </div>
  483. </li>
  484. })}
  485. </ul>
  486. <Pagination style={{ float: 'right' }}
  487. onChange={(e) => { this.demandLoadData(e); }}
  488. total={this.state.demandPagination.total}
  489. showTotal={() => { return '共' + this.state.demandPagination.total + '条数据' }}
  490. current={this.state.demandPagination.pageNo}
  491. pageSize={this.state.demandPagination.pageSize} />
  492. </div>
  493. <Modal title="订单确认" width={600} className="activity-modal"
  494. visible={this.state.visible}
  495. maskClosable={false}
  496. footer={null}
  497. onCancel={() => { this.setState({ visible: false }) }} >
  498. <Spin spinning={this.state.loading}>
  499. <div className="clearfix">
  500. <div className="modal-box">
  501. <span>{"预约 " + (this.state.type == 0 ? theData.username : theData.unitName) + " 的线下咨询需要支付 " + this.state.consultPrice + " 元,是否确认预约?"}</span>
  502. </div>
  503. <div className="modal-box" style={{ marginTop: '20px' }}>
  504. <Button style={{ marginRight: '20px' }} type="primary" onClick={this.addConsultorder}>提交</Button>
  505. <Button type="ghost" onClick={() => { this.setState({ visible: false }) }}>取消</Button>
  506. </div>
  507. </div>
  508. </Spin>
  509. </Modal>
  510. </Spin>
  511. )
  512. }
  513. });
  514. export default Content;