index.jsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* eslint no-undef: 0 */
  2. /* eslint arrow-parens: 0 */
  3. import React from 'react';
  4. import { enquireScreen } from 'enquire-js';
  5. import Nav0 from './Nav0';
  6. import Banner2 from './Banner2';
  7. import Footer1 from './Footer1';
  8. import Birthday from './Birthday'
  9. import Activities from './Activities'
  10. import {
  11. Nav00DataSource,
  12. Footer10DataSource,
  13. } from './data.source';
  14. import './less/antMotionStyle.less';
  15. let isMobile;
  16. enquireScreen((b) => {
  17. isMobile = b;
  18. });
  19. const { location = {} } = typeof window !== 'undefined' ? window : {};
  20. export default class Home extends React.Component {
  21. constructor(props) {
  22. super(props);
  23. this.state = {
  24. isMobile,
  25. show: !location.port, // 如果不是 dva 2.0 请删除
  26. };
  27. }
  28. componentDidMount() {
  29. // 适配手机屏幕;
  30. enquireScreen((b) => {
  31. this.setState({ isMobile: !!b });
  32. });
  33. // dva 2.0 样式在组件渲染之后动态加载,导致滚动组件不生效;线上不影响;
  34. /* 如果不是 dva 2.0 请删除 start */
  35. if (location.port) {
  36. // 样式 build 时间在 200-300ms 之间;
  37. setTimeout(() => {
  38. this.setState({
  39. show: true,
  40. });
  41. }, 500);
  42. }
  43. /* 如果不是 dva 2.0 请删除 end */
  44. }
  45. render() {
  46. const children = [
  47. <Nav0
  48. id="Nav0_0"
  49. key="Nav0_0"
  50. dataSource={Nav00DataSource}
  51. isMobile={this.state.isMobile}
  52. />,
  53. <Banner2
  54. id="Banner2_0_sty"
  55. key="Banner2_0"
  56. isMobile={this.state.isMobile}
  57. />,
  58. <Birthday
  59. id="birthday"
  60. key="birthday"
  61. isMobile={this.state.isMobile}
  62. />,
  63. <div id="sr" key="sr">
  64. <div>
  65. <h1>员工活动</h1>
  66. <div>
  67. <div>
  68. <img src={require('../../image/1.jpg')} />
  69. <h3>公司团建</h3>
  70. <p>趣程在每年的六七月份,面向员工组织公司团建,可以强身健体、增进员工与员工之间的感情。</p>
  71. </div>
  72. <div>
  73. <img src={require('../../image/IMG_0729.jpg')} />
  74. <h3>公司年会</h3>
  75. <p>自趣程创立以来,每年年底,全体员工欢聚一堂,凝聚才华与激情创作出一个个精彩的节目,增加同事之间的感情,同时激励员工在新的一年里再接再厉。</p>
  76. </div>
  77. </div>
  78. </div>
  79. </div>,
  80. <Activities
  81. id="activities"
  82. key="activities"
  83. isMobile={this.state.isMobile}
  84. />,
  85. <Footer1
  86. id="Footer1_0"
  87. key="Footer1_0"
  88. dataSource={Footer10DataSource}
  89. isMobile={this.state.isMobile}
  90. />,
  91. ];
  92. return (
  93. <div
  94. className="templates-wrapper"
  95. ref={(d) => {
  96. this.dom = d;
  97. }}
  98. >
  99. {/* 如果不是 dva 2.0 替换成 {children} start */}
  100. {this.state.show && children}
  101. {/* 如果不是 dva 2.0 替换成 {children} end */}
  102. </div>
  103. );
  104. }
  105. }