chore(diy-article): 支持diy-article 组件关于滚动控制的参数化设置

This commit is contained in:
2025-12-23 11:45:03 +08:00
parent 96049bbcae
commit 92db148237

View File

@@ -3,8 +3,14 @@
<view class="article-wrap" :style="warpCss"> <view class="article-wrap" :style="warpCss">
<view :class="['list-wrap', value.style]" :style="warpCss"> <view :class="['list-wrap', value.style]" :style="warpCss">
<!-- 自动垂直滚动 --> <!-- 自动垂直滚动 -->
<swiper class="auto-scroll-swiper" vertical="true" autoplay="true" circular="true" <swiper class="auto-scroll-swiper"
interval="3000" duration="500" display-multiple-items="3"> :style="swiperStyle"
:vertical="swiperConfig.vertical !== false"
:autoplay="swiperConfig.autoplay !== false"
:circular="swiperConfig.circular !== false"
:interval="swiperConfig.interval || 3000"
:duration="swiperConfig.duration || 500"
:display-multiple-items="swiperConfig.displayMultipleItems || 3">
<swiper-item v-for="(item, index) in list" :key="index" @click="toDetail(item)"> <swiper-item v-for="(item, index) in list" :key="index" @click="toDetail(item)">
<view class="swiper-item-content"> <view class="swiper-item-content">
<view :class="['item', value.ornament.type]" :style="itemCss"> <view :class="['item', value.ornament.type]" :style="itemCss">
@@ -41,18 +47,18 @@
} }
}, },
data() { data() {
return { return {
list: [], list: [],
loading: true, loading: true,
skeletonConfig: { skeletonConfig: {
gridRows: 1, gridRows: 1,
gridRowsGap: '40rpx', gridRowsGap: '40rpx',
headWidth: '160rpx', headWidth: '160rpx',
headHeight: '160rpx', headHeight: '160rpx',
textRows: 2 textRows: 2
} }
}; };
}, },
created() { created() {
this.getList(); this.getList();
}, },
@@ -63,6 +69,10 @@
} }
}, },
computed: { computed: {
// 获取swiper配置默认空对象
swiperConfig() {
return this.value?.swiperConfig || {};
},
warpCss() { warpCss() {
var obj = ''; var obj = '';
obj += 'background-color:' + this.value.componentBgColor + ';'; obj += 'background-color:' + this.value.componentBgColor + ';';
@@ -74,6 +84,15 @@
} }
return obj; return obj;
}, },
// swiper容器样式
swiperStyle() {
// 从swiperConfig获取高度默认600rpx
const height = this.swiperConfig.swiperHeight || 600;
return {
height: height + 'rpx',
width: '100%'
};
},
// 子项样式 // 子项样式
itemCss() { itemCss() {
var obj = ''; var obj = '';
@@ -130,21 +149,29 @@
<style lang="scss"> <style lang="scss">
.article-wrap { .article-wrap {
.list-wrap { .list-wrap {
&.style-1 { .auto-scroll-swiper {
.auto-scroll-swiper { height: 600rpx; /* 可以根据需要调整高度 */
height: 480rpx; width: 100%;
width: 100%;
}
.swiper-item-content { .swiper-item-content {
width: 100%; padding: 10rpx 20rpx;
box-sizing: border-box; box-sizing: border-box;
} }
}
.item {
margin: 0;
margin-bottom: 24rpx;
}
.style-1 .item {
padding: 20rpx;
}
&.style-1 {
.item { .item {
display: flex; display: flex;
padding: 20rpx; margin-top: 0;
margin-top: 24rpx;
height: 120rpx;
box-sizing: border-box;
&:first-of-type { &:first-of-type {
margin-top: 0; margin-top: 0;