|
@@ -1,11 +1,9 @@
|
|
|
<template>
|
|
<template>
|
|
|
- <view class="diy-banner" :style="{ height: `${imgHeights[imgCurrent]}rpx` }">
|
|
|
|
|
|
|
+ <view class="diy-banner" :style="{ height: `${imgHeights[imgCurrent]}px` }">
|
|
|
<!-- 图片轮播 -->
|
|
<!-- 图片轮播 -->
|
|
|
- <swiper :autoplay="autoplay" class="swiper-box" :duration="duration" :circular="true" :interval="itemStyle.interval * 1000"
|
|
|
|
|
- @change="_bindChange">
|
|
|
|
|
|
|
+ <swiper class="swiper-box" :autoplay="autoplay" :duration="duration" :circular="true" :interval="itemStyle.interval * 1000" @change="_bindChange">
|
|
|
<swiper-item v-for="(dataItem, index) in dataList" :key="index">
|
|
<swiper-item v-for="(dataItem, index) in dataList" :key="index">
|
|
|
- <image mode="widthFix" class="slide-image" :src="dataItem.imgUrl" @click="onLink(dataItem.link)"
|
|
|
|
|
- @load="_imagesHeight" />
|
|
|
|
|
|
|
+ <image mode="widthFix" class="slide-image" :src="dataItem.imgUrl" @click="onLink(dataItem.link)" @load="_imagesHeight" />
|
|
|
</swiper-item>
|
|
</swiper-item>
|
|
|
</swiper>
|
|
</swiper>
|
|
|
<!-- 指示点 -->
|
|
<!-- 指示点 -->
|
|
@@ -17,10 +15,10 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
- import mixin from '../mixin'
|
|
|
|
|
|
|
+ import mixin from '../mixin';
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
- name: "Banner",
|
|
|
|
|
|
|
+ name: 'Banner',
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 组件的属性列表
|
|
* 组件的属性列表
|
|
@@ -41,12 +39,22 @@
|
|
|
*/
|
|
*/
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
|
|
+ windowWidth: 750,
|
|
|
indicatorDots: false, // 是否显示面板指示点
|
|
indicatorDots: false, // 是否显示面板指示点
|
|
|
autoplay: true, // 是否自动切换
|
|
autoplay: true, // 是否自动切换
|
|
|
duration: 800, // 滑动动画时长
|
|
duration: 800, // 滑动动画时长
|
|
|
imgHeights: [], // 图片的高度
|
|
imgHeights: [], // 图片的高度
|
|
|
- imgCurrent: 0, // 当前banne所在滑块指针
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ imgCurrent: 0 // 当前banne所在滑块指针
|
|
|
|
|
+ };
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ created() {
|
|
|
|
|
+ const app = this;
|
|
|
|
|
+ uni.getSystemInfo({
|
|
|
|
|
+ success({ windowWidth }) {
|
|
|
|
|
+ app.windowWidth = windowWidth > 750 ? 750 : windowWidth;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -54,34 +62,29 @@
|
|
|
* 更新属性和数据的方法与更新页面数据的方法类似
|
|
* 更新属性和数据的方法与更新页面数据的方法类似
|
|
|
*/
|
|
*/
|
|
|
methods: {
|
|
methods: {
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 计算图片高度
|
|
* 计算图片高度
|
|
|
*/
|
|
*/
|
|
|
- _imagesHeight(e) {
|
|
|
|
|
|
|
+ _imagesHeight({ detail }) {
|
|
|
|
|
+ const app = this;
|
|
|
// 获取图片真实宽度
|
|
// 获取图片真实宽度
|
|
|
- const imgwidth = e.detail.width,
|
|
|
|
|
- imgheight = e.detail.height,
|
|
|
|
|
- // 宽高比
|
|
|
|
|
- ratio = imgwidth / imgheight
|
|
|
|
|
|
|
+ const { width, height } = detail;
|
|
|
|
|
+ // 宽高比
|
|
|
|
|
+ const ratio = width / height;
|
|
|
// 计算的高度值
|
|
// 计算的高度值
|
|
|
- const viewHeight = 750 / ratio,
|
|
|
|
|
- imgHeights = this.imgHeights;
|
|
|
|
|
|
|
+ const viewHeight = app.windowWidth / ratio;
|
|
|
// 把每一张图片的高度记录到数组里
|
|
// 把每一张图片的高度记录到数组里
|
|
|
- imgHeights.push(viewHeight);
|
|
|
|
|
- this.imgHeights = imgHeights
|
|
|
|
|
|
|
+ app.imgHeights.push(viewHeight);
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 记录当前指针
|
|
* 记录当前指针
|
|
|
*/
|
|
*/
|
|
|
_bindChange(e) {
|
|
_bindChange(e) {
|
|
|
- this.imgCurrent = e.detail.current
|
|
|
|
|
|
|
+ this.imgCurrent = e.detail.current;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ };
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
@@ -100,7 +103,6 @@
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
/* 指示点 */
|
|
/* 指示点 */
|
|
|
.indicator-dots {
|
|
.indicator-dots {
|
|
|
width: 100%;
|
|
width: 100%;
|
|
@@ -147,8 +149,6 @@
|
|
|
width: 22rpx;
|
|
width: 22rpx;
|
|
|
height: 14rpx;
|
|
height: 14rpx;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
</style>
|
|
</style>
|