normal.jsx 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. import React from 'react';
  2. import { Spin, Button, Tabs, message, Modal } from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js'
  4. import $ from 'jquery/src/ajax';
  5. import '../content.less';
  6. import './content.less';
  7. import LeftTab from './leftTab.jsx';
  8. import Collection from './collection';
  9. import weixin from '../../../../image/weixin-w.png';
  10. import qq from '../../../../image/qq-w.png';
  11. import weibo from '../../../../image/weibo-w.png';
  12. import defaultAvatar from '../../../../image/avatarImg.png'
  13. import level1 from '../../../../image/level_1.png';
  14. import level2 from '../../../../image/level_2.png';
  15. import level3 from '../../../../image/level_3.png';
  16. import level4 from '../../../../image/level_4.png';
  17. import level5 from '../../../../image/level_5.png';
  18. const Content = React.createClass({
  19. getInitialState () {
  20. return {
  21. loading: false,
  22. visible: false
  23. };
  24. },
  25. getData () {
  26. this.setState({
  27. loading: false
  28. });
  29. $.ajax({
  30. method: "get",
  31. dataType: "json",
  32. url: globalConfig.context + "/api/user/homePage"
  33. }).done(function (data) {
  34. if (data.error && data.error.length) {
  35. message.warning(data.error[0].message);
  36. } else {
  37. this.setState({
  38. achievementNum: data.data.achievementNum,
  39. copyrightNum: data.data.copyrightNum,
  40. demandNum: data.data.demandNum,
  41. gradeName: data.data.gradeName,
  42. email: data.data.email,
  43. intellectualPropertyNum: data.data.intellectualPropertyNum,
  44. logoUrl: data.data.logoUrl,
  45. level: data.data.lvl,
  46. nickname: data.data.nickname,
  47. number: data.data.number,
  48. patentNum: data.data.patentNum,
  49. personPortraitUrl: data.data.personPortraitUrl,
  50. techProjectNum: data.data.techProjectNum,
  51. type: data.data.type,
  52. uid: data.data.uid,
  53. visible: !data.data.lvl || data.data.lvl == 0 ? true : false
  54. })
  55. }
  56. }.bind(this)).always(function () {
  57. this.setState({
  58. loading: false
  59. });
  60. }.bind(this));
  61. },
  62. componentWillMount () {
  63. this.getData();
  64. },
  65. tabChange (key) {
  66. },
  67. render () {
  68. const TabPane = Tabs.TabPane;
  69. return (
  70. <Spin spinning={this.state.loading} className='spin-box'>
  71. <div className="index-content">
  72. <div className="index-userdata clearfix">
  73. <p className="acc-title">
  74. 欢迎,
  75. <span>{this.state.nickname || ('No.' + this.state.number)}</span>
  76. {(() => {
  77. if ( this.state.level ) {
  78. return <img src={globalConfig.avatarUploadHost + '/rank/level_' + this.state.level + '.png'} alt="" />
  79. } else {
  80. return ''
  81. }
  82. })()}
  83. {(() => {
  84. if (this.state.level > 1 && this.state.level < 2) {
  85. return <span style={{ fontSize: '14px', color: '#333' }}>
  86. <a href={globalConfig.context + '/portal/membership.html'}>升级高级会员</a> ,获取更多会员权益
  87. </span>;
  88. }
  89. })()}
  90. </p>
  91. <div className="userdata-img">
  92. {this.state.personPortraitUrl || this.state.logoUrl ?
  93. <img src={globalConfig.avatarHost + "/upload" + (this.state.type == 0 ? this.state.personPortraitUrl : this.state.logoUrl)} alt="" />
  94. : <img src={defaultAvatar} alt="" />}
  95. </div>
  96. <div className="userdata-content">
  97. {(() => {
  98. if (this.state.level > 0) {
  99. return <p className="userdata-lvl"><span>{this.state.gradeName}</span></p>;
  100. } else {
  101. return <p className="userdata-lvl"><span>用户未认证</span><a style={{ marginLeft: '20px' }} href={userData.type == 1 ? globalConfig.context + "/user/groupCertify.html" : globalConfig.context + "/user/certify.html"}>进行实名认证</a></p>;
  102. };
  103. })()}
  104. <p><a href={globalConfig.context + "/user/account/set.html"}>填写完整资料</a>,有助于提高您的资信</p>
  105. <p className="userdata-relate" style={{ 'display': 'none' }}>
  106. <Button className="relateqq"><img src={qq} alt="" /> QQ账号登录</Button>
  107. <Button className="relateweibo"><img src={weibo} alt="" />微博账号登录</Button>
  108. <Button className="relateweixin"><img src={weixin} alt="" />微信账号登录</Button>
  109. </p>
  110. </div>
  111. </div>
  112. <div className="index-record">
  113. <p className="acc-title">我的轨迹</p>
  114. {this.state.type ? <ul className="record-list clearfix">
  115. <li>专利:<a href={globalConfig.context + "/user/account/services.html#patent"}>{this.state.patentNum || 0}</a> 项</li>
  116. <li>软著:<a href={globalConfig.context + "/user/account/services.html#copyright"}>{this.state.copyrightNum || 0}</a> 项</li>
  117. <li>知识产权:<a href={globalConfig.context + "/user/account/services.html#intellectual"}>{this.state.intellectualPropertyNum || 0}</a> 项</li>
  118. <li>科技项目:<a href={globalConfig.context + "/user/account/services.html#technology"}>{this.state.techProjectNum || 0}</a> 项</li>
  119. <li>技术成果:<a href={globalConfig.context + "/user/account/achievement.html#techAchievement"}>{this.state.achievementNum || 0}</a> 项</li>
  120. <li>发布需求:<a href={globalConfig.context + "/user/account/demand.html#techDemand"}>{this.state.demandNum || 0}</a> 项</li>
  121. </ul> : <ul className="record-list clearfix">
  122. <li>技术成果:<a href={globalConfig.context + "/user/account/achievement.html#techAchievement"}>{this.state.achievementNum || 0}</a> 项</li>
  123. <li>发布需求:<a href={globalConfig.context + "/user/account/demand.html#techDemand"}>{this.state.demandNum || 0}</a> 项</li>
  124. </ul>}
  125. </div>
  126. <div className="index-activity">
  127. <Collection />
  128. </div>
  129. </div>
  130. <Modal maskClosable={false}
  131. title="实名认证提示"
  132. visible={this.state.visible}
  133. onCancel={() => {
  134. this.setState({
  135. visible: false,
  136. });
  137. }}
  138. width='400px'
  139. footer={[]} >
  140. <p style={{ textAlign: 'center' }}>
  141. <span>您还未进行实名认证,请完成实名认证,为您提供更多服务</span>
  142. </p>
  143. <div style={{ marginTop: '20px', textAlign: 'center' }}>
  144. <Button type="primary"
  145. onClick={() => {
  146. window.open(this.state.type == 1 ? globalConfig.context + "/user/groupCertify.html" : globalConfig.context + "/user/certify.html")
  147. }}>马上去</Button>
  148. </div>
  149. </Modal>
  150. </Spin>
  151. )
  152. }
  153. });
  154. export default Content;