Banner.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import React, {PureComponent} from "react";
  2. import {BannerWrapper, Center, Focusinfo} from '../style';
  3. import {scrollAnimation} from '../../../lib/auth';
  4. import axios from "axios";
  5. class Banner extends PureComponent {
  6. constructor(props) {
  7. super(props);
  8. this.state = {
  9. info: []
  10. };
  11. }
  12. render() {
  13. const {banner, innerHeight} = this.props;
  14. const {introduction,avatar} = this.props.userInfo.toJS();
  15. const {info} = this.state;
  16. return (
  17. <BannerWrapper>
  18. <div className="waveWrapper waveAnimation">
  19. <div className="waveWrapperInner bgTop">
  20. <div className="wave waveTop"/>
  21. </div>
  22. <div className="waveWrapperInner bgMiddle">
  23. <div className="wave waveMiddle"/>
  24. </div>
  25. <div className="waveWrapperInner bgBottom">
  26. <div className="wave waveBottom"/>
  27. </div>
  28. </div>
  29. <div className='headertop-down animated'>
  30. <span onClick={headertop_down}><i className='iconfont icon-chevrondown'/></span>
  31. </div>
  32. <Center style={{backgroundImage: banner, height: innerHeight + 'px'}}>
  33. <Focusinfo>
  34. <div className='header-tou'>
  35. <img src={avatar} alt=''/>
  36. </div>
  37. <h1 className='glitch' data-text="NOSUMBLOG!">NOSUMBLOG!</h1>
  38. <div className='header-info'>
  39. <p className='ellipsis'>
  40. <i className='iconfont icon-quote-left'/>
  41. <span>{introduction || 'You got to put the past behind you before you can move on.'}</span>
  42. <i className='iconfont icon-quoteright'/>
  43. </p>
  44. <div className='top-social_v2'>
  45. <li onClick={this.props.getBanner}>
  46. <img className='flipx' src={require('../../../statics/images/next-b.svg')} alt=""/>
  47. </li>
  48. {
  49. info.map((item, index) => {
  50. if (item.showType === 1) {
  51. return (
  52. <li className='img' key={index}>
  53. <img src={item.icon} alt=""/>
  54. <div className='img-box'>
  55. <img src={item.content} alt=""/>
  56. </div>
  57. </li>
  58. )
  59. } else if (item.showType === 2) {
  60. return (
  61. <li className='text' key={index}>
  62. <img src={item.icon} alt=""/>
  63. <div className='text-box'>
  64. <p>{item.content}</p>
  65. </div>
  66. </li>
  67. )
  68. } else if (item.showType === 3) {
  69. return (
  70. <li className='link' key={index}>
  71. <a href={item.content} target={'_blank'} rel="noopener noreferrer">
  72. <img src={item.icon} alt=""/>
  73. </a>
  74. </li>
  75. )
  76. }else {
  77. return null
  78. }
  79. })
  80. }
  81. <li onClick={this.props.getBanner}>
  82. <img src={require('../../../statics/images/next-b.svg')} alt=""/>
  83. </li>
  84. </div>
  85. </div>
  86. </Focusinfo>
  87. </Center>
  88. </BannerWrapper>
  89. )
  90. }
  91. componentDidMount() {
  92. axios.get('/social/social/v1/info').then((res) => {
  93. if (res.success === 1) {
  94. const {models} = res;
  95. let array = [];
  96. for (let i = 0; i < models.length; i++) {
  97. array.push({
  98. show: false,
  99. icon: models[i].icon,
  100. content: models[i].content,
  101. showType: models[i].showType,
  102. })
  103. }
  104. this.setState({
  105. info: array
  106. })
  107. }
  108. });
  109. }
  110. }
  111. function headertop_down() {
  112. const content = document.getElementById('content').offsetTop;
  113. scrollAnimation(0, content);
  114. }
  115. export default Banner