|
|
<template>
|
|
|
<div class="article-item-slide">
|
|
|
<Slide :data="data.blockList" :threshold="0.2" :auto-play="false" :loop="false" :options="scrollOption" @change="onChange">
|
|
|
<SlideItem v-for="(item, inx) in data.blockList" :key="inx">
|
|
|
<ImageFormat :lazy="lazy" class="image-slide-item" :src="item.contentData" :width="item.width" :height="item.height"></ImageFormat>
|
|
|
<SlideItem :style="slideItemStyle" v-for="(item, inx) in data.blockList" :key="inx">
|
|
|
<ImageFormat :mode="1" :lazy="lazy" :style="getImageStyle(item)" class="image-slide-item" :src="item.contentData" :width="item.width" :height="item.height"></ImageFormat>
|
|
|
</SlideItem>
|
|
|
<template slot="dots" slot-scope="props">
|
|
|
<span class="slide-dot"
|
...
|
...
|
@@ -19,7 +19,9 @@ |
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import {first} from 'lodash';
|
|
|
import {Slide} from 'cube-ui';
|
|
|
import {mapState} from 'vuex';
|
|
|
|
|
|
export default {
|
|
|
name: 'ArticleItemSlide',
|
...
|
...
|
@@ -43,7 +45,52 @@ export default { |
|
|
currentIndex: 1,
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState(['yoho']),
|
|
|
slideItemStyle() {
|
|
|
const {width, height} = this.firstBlockSize;
|
|
|
|
|
|
if (width && height) {
|
|
|
return {
|
|
|
width: `${width}px`,
|
|
|
height: `${height}px`,
|
|
|
display: 'flex',
|
|
|
'justify-content': 'center',
|
|
|
'align-items': 'center'
|
|
|
};
|
|
|
}
|
|
|
},
|
|
|
firstBlockSize() {
|
|
|
const {width, height} = first(this.data.blockList) || {};
|
|
|
|
|
|
if (width && height) {
|
|
|
const scale = width / height;
|
|
|
|
|
|
return {
|
|
|
width: this.yoho.window.clientWidth,
|
|
|
height: this.yoho.window.clientWidth / scale,
|
|
|
};
|
|
|
}
|
|
|
return {};
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
getImageStyle({width, height}) {
|
|
|
const {height: fHeight} = this.firstBlockSize;
|
|
|
const scale = width / height;
|
|
|
|
|
|
if (scale > 1) {
|
|
|
return {
|
|
|
width: `${this.yoho.window.clientWidth}px`,
|
|
|
height: `${this.yoho.window.clientWidth / scale}px`
|
|
|
};
|
|
|
} else if (scale < 1) {
|
|
|
return {
|
|
|
width: `${fHeight * scale}px`,
|
|
|
height: `${fHeight}px`
|
|
|
};
|
|
|
}
|
|
|
},
|
|
|
onChange(inx) {
|
|
|
this.currentIndex = inx + 1;
|
|
|
},
|
...
|
...
|
@@ -88,7 +135,6 @@ export default { |
|
|
.article-item-slide {
|
|
|
position: relative;
|
|
|
width: 750px;
|
|
|
height: 750px;
|
|
|
overflow: hidden;
|
|
|
|
|
|
& /deep/ .cube-slide-dots {
|
...
|
...
|
@@ -120,8 +166,6 @@ export default { |
|
|
}
|
|
|
|
|
|
.image-slide-item {
|
|
|
width: 750px;
|
|
|
height: 750px;
|
|
|
overflow: hidden;
|
|
|
}
|
|
|
|
...
|
...
|
|