Server.js 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import React, {Component} from 'react';
  2. import {Card, WhiteSpace, Button, Carousel, WingBlank, Flex} from 'antd-mobile';
  3. class Server extends Component {
  4. constructor(props) {
  5. super(props);
  6. this.state = {
  7. data: ['AiyWuByWklrrUDlFignR', 'TekJlZRVCjLFexlOCuWn', 'IJOtIlfsYdTyaDTRVrLI'],
  8. imgHeight: 176,
  9. }
  10. }
  11. render() {
  12. let {tip, servers} = this.props;
  13. return (
  14. <div>
  15. <WingBlank>
  16. <Carousel
  17. autoplay={true}
  18. infinite
  19. >
  20. {this.state.data.map(val => (
  21. <a
  22. key={val}
  23. href="http://www.alipay.com"
  24. style={{display: 'inline-block', width: '100%', height: this.state.imgHeight}}
  25. >
  26. <img
  27. src={`https://zos.alipayobjects.com/rmsportal/${val}.png`}
  28. alt=""
  29. style={{width: '100%', verticalAlign: 'top'}}
  30. onLoad={() => {
  31. window.dispatchEvent(new Event('resize'));
  32. this.setState({imgHeight: 'auto'});
  33. }}
  34. />
  35. </a>
  36. ))}
  37. </Carousel>
  38. </WingBlank>
  39. {
  40. tip ?
  41. <div className={'center'}>{tip}</div>
  42. :
  43. ''
  44. }
  45. {
  46. servers.map((server) => {
  47. return (
  48. <div key={server.id}>
  49. <WingBlank size="lg">
  50. <WhiteSpace size="lg"/>
  51. <Card className={'card'}>
  52. <Card.Body>
  53. <div>
  54. <Flex>
  55. <Flex.Item>
  56. <div className={'avatar'}
  57. style={{backgroundImage: `url(${server.img})`}}>1
  58. </div>
  59. </Flex.Item>
  60. <Flex.Item>
  61. <div className={'server-name'}>{server.name}</div>
  62. <div className={'server-description'}>{server.description}</div>
  63. </Flex.Item>
  64. <Flex.Item>
  65. <Button type='ghost' size='small'
  66. onClick={this.props.pageSwitchToService(server.id, server.name, server.description)}>选我</Button>
  67. </Flex.Item>
  68. </Flex>
  69. </div>
  70. </Card.Body>
  71. </Card>
  72. </WingBlank>
  73. </div>
  74. )
  75. })
  76. }
  77. </div>
  78. );
  79. }
  80. }
  81. export default Server;