Commit 756a25d2 by zhanghaozhe

Merge branch 'swiper' into pre

parents c4180fe2 10a9fc8c
...@@ -4777,6 +4777,14 @@ ...@@ -4777,6 +4777,14 @@
"resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.1.tgz", "resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.1.tgz",
"integrity": "sha1-ZyIm3HTI95mtNTB9+TaroRrNYBg=" "integrity": "sha1-ZyIm3HTI95mtNTB9+TaroRrNYBg="
}, },
"dom7": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/dom7/-/dom7-2.1.3.tgz",
"integrity": "sha512-QTxHHDox+M6ZFz1zHPAHZKI3JOHY5iY4i9BK2uctlggxKQwRhO3q3HHFq1BKsT25Bm/ySSj70K6Wk/G4bs9rMQ==",
"requires": {
"ssr-window": "^1.0.1"
}
},
"domain-browser": { "domain-browser": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz", "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz",
...@@ -13875,6 +13883,11 @@ ...@@ -13875,6 +13883,11 @@
"tweetnacl": "~0.14.0" "tweetnacl": "~0.14.0"
} }
}, },
"ssr-window": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/ssr-window/-/ssr-window-1.0.1.tgz",
"integrity": "sha512-dgFqB+f00LJTEgb6UXhx0h+SrG50LJvti2yMKMqAgzfUmUXZrLSv2fjULF7AWGwK25EXu8+smLR3jYsJQChPsg=="
},
"ssri": { "ssri": {
"version": "6.0.1", "version": "6.0.1",
"resolved": "https://registry.npmjs.org/ssri/-/ssri-6.0.1.tgz", "resolved": "https://registry.npmjs.org/ssri/-/ssri-6.0.1.tgz",
...@@ -14157,6 +14170,15 @@ ...@@ -14157,6 +14170,15 @@
} }
} }
}, },
"swiper": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/swiper/-/swiper-4.5.0.tgz",
"integrity": "sha512-jRCd/CGet9kaHwthHdd/sL/YU8CI157PWLyItnIcn/o/jP4haVky3zTF6f9F3JDpmQIw7jdWihISiYx0/oTHsg==",
"requires": {
"dom7": "^2.1.3",
"ssr-window": "^1.0.1"
}
},
"symbol-observable": { "symbol-observable": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz", "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz",
......
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
"sass-resources-loader": "^2.0.0", "sass-resources-loader": "^2.0.0",
"socket.io": "^2.2.0", "socket.io": "^2.2.0",
"style-loader": "0.23.1", "style-loader": "0.23.1",
"swiper": "^4.5.0",
"terser-webpack-plugin": "1.2.2", "terser-webpack-plugin": "1.2.2",
"url-loader": "1.1.2", "url-loader": "1.1.2",
"video.js": "^7.6.0", "video.js": "^7.6.0",
......
import React, { Component } from 'react';
import Swiper from 'swiper'
import './index.scss'
import 'swiper/dist/css/swiper.min.css'
import { Link } from "react-router-dom";
class Index extends Component {
container = null
swiper = null
componentDidMount() {
this.swiper = new Swiper('.swiper-container', {
direction: 'horizontal',
loop: true,
spaceBetween: 12,
centeredSlides: true,
slidesPerView: 'auto',
loopedSlides: 2,
autoplay: true
})
}
componentWillUnmount() {
this.swiper.destroy()
}
render() {
const {bannerList} = this.props
return (
<div className={'index-banner-swiper'}>
<div className={'swiper-container'} ref={el => this.container = el}>
<ul className="swiper-wrapper">
{bannerList && bannerList.length > 0 && bannerList.map((item, index) => {
return (
<li className={'swiper-slide'} key={index}>
{
Number.isNaN(parseInt(item.jump_url)) ?
<a href={item.jump_url} key={index}>
<img className="item" src={item.name} alt=""/>
</a> :
<Link
to={{
pathname: '/detail',
search: `?id=${item.jump_url}`
}}
key={index}
>
<img
className="item"
src={item.name}
alt=""
/>
</Link>
}
</li>
)
})
}
</ul>
</div>
</div>
);
}
}
export default Index;
\ No newline at end of file
.index-banner-swiper{
.swiper {
&-container {
padding: 0 20px !important;
}
&-slide {
width: 335px !important;
height: 168px !important;
transform: scale3d(1, 0.9, 1);
transition: transform .4s;
img {
width: 100% !important;
height: 100% !important;
}
&-active {
transform: scale3d(1, 1, 1);
}
}
}
}
\ No newline at end of file
...@@ -2,17 +2,18 @@ import React, { Component } from 'react' ...@@ -2,17 +2,18 @@ import React, { Component } from 'react'
import { Course, CallApp } from '../../common' import { Course, CallApp } from '../../common'
import './index.scss' import './index.scss'
import { WithTab } from '@/HOCs' import { WithTab } from '@/HOCs'
import Swiper from 'react-mobile-swiper' // import Swiper from 'react-mobile-swiper'
import createStyle from './createStyle' // import createStyle from './createStyle'
import LazyLoad from 'react-lazy-load' import LazyLoad from 'react-lazy-load'
import { http } from '@/utils' import { http } from '@/utils'
import LiveRoom from './liveRoom' import LiveRoom from './liveRoom'
import { Link } from "react-router-dom" import { Link } from "react-router-dom"
import { Toast } from 'antd-mobile' import { Toast } from 'antd-mobile'
import { connect } from "react-redux"; import { connect } from "react-redux";
import TopSwiper from './TopSwiper'
const animateTypes = Swiper.animateTypes // const animateTypes = Swiper.animateTypes
@connect(state => ({ @connect(state => ({
user: state.user user: state.user
...@@ -210,43 +211,43 @@ class Index extends Component { ...@@ -210,43 +211,43 @@ class Index extends Component {
} }
function TopSwiper({bannerList}) { // function TopSwiper({bannerList}) {
return ( // return (
<Swiper // <Swiper
type={animateTypes.CARD} // type={animateTypes.CARD}
loop={true} // loop={true}
height={168} // height={168}
autoPlay={true} // autoPlay={true}
typePro // typePro
createStyle={createStyle} // createStyle={createStyle}
> // >
{bannerList && bannerList.length > 0 && bannerList.map((item, index) => { // {bannerList && bannerList.length > 0 && bannerList.map((item, index) => {
return ( // return (
Number.isNaN(parseInt(item.jump_url)) ? // Number.isNaN(parseInt(item.jump_url)) ?
<a href={item.jump_url} key={index}> // <a href={item.jump_url} key={index}>
{/* <Link to={item.jump_url} key={index}> */} // {/* <Link to={item.jump_url} key={index}> */}
<img className="item" src={item.name} alt="" /> // <img className="item" src={item.name} alt="" />
{/* </Link> */} // {/* </Link> */}
</a> : // </a> :
<Link // <Link
to={{ // to={{
pathname: '/detail', // pathname: '/detail',
search: `?id=${item.jump_url}` // search: `?id=${item.jump_url}`
}} // }}
key={index} // key={index}
> // >
<img // <img
className="item" // className="item"
src={item.name} // src={item.name}
alt="" // alt=""
/> // />
</Link> // </Link>
) // )
}) // })
} // }
</Swiper> // </Swiper>
) // )
} // }
// 课程模块儿公共组件 // 课程模块儿公共组件
// 课程数量是奇数第一个课程需要横着展示沾满一行,课程数量是偶数一行显示两个 // 课程数量是奇数第一个课程需要横着展示沾满一行,课程数量是偶数一行显示两个
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment