|
@@ -1,107 +1,51 @@
|
|
|
import React from 'react';
|
|
|
-import { Button } from 'antd';
|
|
|
-import { DownOutlined } from '@ant-design/icons';
|
|
|
-import QueueAnim from 'rc-queue-anim';
|
|
|
-import TweenOne, { TweenOneGroup } from 'rc-tween-one';
|
|
|
-import BannerAnim, { Element } from 'rc-banner-anim';
|
|
|
-import { isImg } from './utils';
|
|
|
import 'rc-banner-anim/assets/index.css';
|
|
|
|
|
|
-const BgElement = Element.BgElement;
|
|
|
-class Banner extends React.PureComponent {
|
|
|
- render() {
|
|
|
- const { ...props } = this.props;
|
|
|
- const { dataSource, isMobile } = props;
|
|
|
- delete props.dataSource;
|
|
|
- delete props.isMobile;
|
|
|
- const childrenToRender = dataSource.BannerAnim.children.map((item, i) => {
|
|
|
- const elem = item.BannerElement;
|
|
|
- const elemClassName = elem.className;
|
|
|
- delete elem.className;
|
|
|
- const bg = item.bg;
|
|
|
- const textWrapper = item.textWrapper;
|
|
|
- const title = item.title;
|
|
|
- const content = item.content;
|
|
|
- const button = item.button;
|
|
|
- const page = item.page;
|
|
|
- const follow = !isMobile
|
|
|
- ? {
|
|
|
- delay: 1000,
|
|
|
- minMove: 0.1,
|
|
|
- data: [
|
|
|
- {
|
|
|
- id: `bg${i}`,
|
|
|
- value: 15,
|
|
|
- type: 'x',
|
|
|
- },
|
|
|
- { id: `wrapperBlock${i}`, value: -15, type: 'x' },
|
|
|
- ],
|
|
|
- }
|
|
|
- : null;
|
|
|
- return (
|
|
|
- <Element
|
|
|
- key={i.toString()}
|
|
|
- followParallax={follow}
|
|
|
- {...elem}
|
|
|
- prefixCls={elemClassName}
|
|
|
- >
|
|
|
- <BgElement key="bg" {...bg} id={`bg${i}`} />
|
|
|
- <div {...page}>
|
|
|
- <QueueAnim
|
|
|
- type={['bottom', 'top']}
|
|
|
- delay={200}
|
|
|
- key="text"
|
|
|
- {...textWrapper}
|
|
|
- id={`wrapperBlock${i}`}
|
|
|
- >
|
|
|
- <div key="logo" {...title}>
|
|
|
- {typeof title.children === 'string' &&
|
|
|
- title.children.match(isImg) ? (
|
|
|
- <img src={title.children} width="100%" alt="img" />
|
|
|
- // <img src='@/image/img5.jpg' width="100%" alt="img" />
|
|
|
- ) : (
|
|
|
- title.children
|
|
|
- )}
|
|
|
- </div>
|
|
|
- <div key="content" {...content}>
|
|
|
- {content.children}
|
|
|
- </div>
|
|
|
- <Button type="ghost" key="button" {...button}>
|
|
|
- {button.children}
|
|
|
- </Button>
|
|
|
- </QueueAnim>
|
|
|
- </div>
|
|
|
- </Element>
|
|
|
- );
|
|
|
- });
|
|
|
- return (
|
|
|
- <div {...props} {...dataSource.wrapper}>
|
|
|
- <TweenOneGroup
|
|
|
- key="bannerGroup"
|
|
|
- enter={{ opacity: 0, type: 'from' }}
|
|
|
- leave={{ opacity: 0 }}
|
|
|
- component=""
|
|
|
- >
|
|
|
- <BannerAnim key="BannerAnim" {...dataSource.BannerAnim}>
|
|
|
- {childrenToRender}
|
|
|
- </BannerAnim>
|
|
|
- </TweenOneGroup>
|
|
|
- <TweenOne
|
|
|
- animation={{
|
|
|
- y: '-=20',
|
|
|
- yoyo: true,
|
|
|
- repeat: -1,
|
|
|
- duration: 1000,
|
|
|
- }}
|
|
|
- className="banner2-icon"
|
|
|
- style={{ bottom: 40 }}
|
|
|
- key="icon"
|
|
|
- >
|
|
|
- <DownOutlined />
|
|
|
- </TweenOne>
|
|
|
+
|
|
|
+const videos = ['https://zx-oss-dev.oss-cn-hangzhou.aliyuncs.com/mp4D2BD31130FF64BDE8FE16411943EE96E.mp4', 'https://zx-oss-dev.oss-cn-hangzhou.aliyuncs.com/mp4401C85BB09084B2EB823B337946E099C.mp4']
|
|
|
+function Banner(props) {
|
|
|
+ const { isMobile, ...prop } = props;
|
|
|
+ const [curr, setCurr] = React.useState(0) // 播放的哪条视频
|
|
|
+
|
|
|
+ const refVideo = React.useRef(null)
|
|
|
+
|
|
|
+ const endenHandle = React.useCallback(()=>{
|
|
|
+ if(curr + 1 >= videos.length) {
|
|
|
+ setCurr(0)
|
|
|
+ }else{
|
|
|
+ setCurr(curr + 1)
|
|
|
+ }
|
|
|
+ console.log(refVideo);
|
|
|
+ },[curr, refVideo])
|
|
|
+
|
|
|
+ return (
|
|
|
+ <div {...prop} className="Banner2_0_sty">
|
|
|
+ <div className='home-header__video-bg'>
|
|
|
+ {/* <video id="pc-video" muted="muted" autoPlay playsInline="playsinline" loop="loop" controls={true} webkit-playsinline="webkit-playsinline" x5-playsinline="x5-playsinline">
|
|
|
+ <source src={videos[curr]} type="video/mp4" />
|
|
|
+ </video> */}
|
|
|
+ {
|
|
|
+ curr === 0 && <video id="pc-video1" muted="muted" ref={refVideo} autoPlay="autoplay" controls={true} onEnded={endenHandle} webkit-playsinline="webkit-playsinline" x5-playsinline="x5-playsinline">
|
|
|
+ <source src={videos[curr]} type="video/mp4" />
|
|
|
+ </video>
|
|
|
+ }
|
|
|
+ {
|
|
|
+ curr === 1 && <video id="pc-video2" muted="muted" ref={refVideo} autoPlay="autoplay" controls={true} onEnded={endenHandle} webkit-playsinline="webkit-playsinline" x5-playsinline="x5-playsinline">
|
|
|
+ <source src={videos[curr]} type="video/mp4" />
|
|
|
+ </video>
|
|
|
+ }
|
|
|
+ {/* {
|
|
|
+ curr === 2 && <video id="pc-video" muted="muted" ref={refVideo} autoPlay="autoplay" controls={true} onEnded={endenHandle} webkit-playsinline="webkit-playsinline" x5-playsinline="x5-playsinline">
|
|
|
+ <source src={'http://questnet.cn/image/2.mp4'} type="video/mp4" />
|
|
|
+ </video>
|
|
|
+ } */}
|
|
|
+ </div>
|
|
|
+ <div className="home-header-content">
|
|
|
+ <h1>为世界创造快乐</h1>
|
|
|
+ <p>激情青春敢为梦想,用科技创新赋予生活更多精彩</p>
|
|
|
</div>
|
|
|
- );
|
|
|
- }
|
|
|
+ </div>
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
-export default Banner;
|
|
|
+export default Banner;
|