| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- <template>
- <div class="pcPages">
- <div class="carousel-bos" :style="warpCss" v-if="componentData.styleType == 3">
- <el-carousel :height="170 * componentData.count + (componentData.count == 2 ? 10 : 0) + 'px'" :autoplay="false" arrow="always">
- <el-carousel-item v-for="(item1, index1) in dataList" :key="index1" class="w100% h100%">
- <div class="carousel-list">
- <div v-for="(item, index) in item1" :key="index" class="data-list flex-column-center" :style="boxCss">
- <div :style="titleCss">{{ item.title || '' }}</div>
- <div :style="subtitleCss" class="mt-[2px] mb-[12px]">{{ item.subtitle || '' }}</div>
- <el-image
- class="img"
- :src="item.imageUrl ? item.imageUrl : figure"
- :fit="item.imgType == 1 ? 'fill' : item.imgType == 2 ? 'contain' : 'cover'"
- :style="componentData.imageRadius ? { borderRadius: componentData.imageRadius + 'px' } : {}"
- />
- </div>
- </div>
- </el-carousel-item>
- </el-carousel>
- </div>
- <div v-else :style="warpCss" class="data-bos">
- <div v-for="(item, index) in componentData.navlList" :key="index" class="data-list flex-column-center" :style="boxCss">
- <div :style="titleCss">{{ item.title || '' }}</div>
- <div :style="subtitleCss" class="mt-[2px] mb-[12px]">{{ item.subtitle || '' }}</div>
- <el-image
- class="img"
- :src="item.imageUrl ? item.imageUrl : figure"
- :fit="item.imgType == 1 ? 'fill' : item.imgType == 2 ? 'contain' : 'cover'"
- :style="componentData.imageRadius ? { borderRadius: componentData.imageRadius + 'px' } : {}"
- />
- </div>
- </div>
- </div>
- </template>
- <script lang="ts" setup>
- import usePcdiyStore from '@/store/modules/pcdiy';
- import figure from '@/assets/images/figure.png';
- const diyStore = usePcdiyStore();
- const props = defineProps<{
- index: number; // 确保声明 index 为可选属性
- }>();
- const componentData = diyStore.componentList[props.index];
- const dataList = computed(() => {
- const chunkSize = componentData.number * componentData.count;
- const result = [];
- for (let i = 0; i < componentData.navlList.length; i += chunkSize) {
- const chunk = componentData.navlList.slice(i, i + chunkSize);
- result.push(chunk);
- }
- return result;
- });
- const warpCss = computed(() => {
- let style = '';
- style += 'position:relative;';
- //背景颜色
- if (componentData.pageStartBgColor) {
- if (componentData.pageStartBgColor && componentData.pageEndBgColor)
- style += `background:linear-gradient(${componentData.pageGradientAngle},${componentData.pageStartBgColor},${componentData.pageEndBgColor});`;
- else if (componentData.pageStartBgColor) style += `background: ${componentData.pageStartBgColor};`;
- else if (componentData.pageEndBgColor) style += `background: ${componentData.pageEndBgColor};`;
- }
- //边距
- if (componentData.padding) {
- if (componentData.padding.top > 0) {
- style += 'padding-top:' + componentData.padding.top + 'px' + ';';
- }
- if (componentData.padding.bottom > 0) {
- style += 'padding-bottom:' + componentData.padding.bottom + 'px' + ';';
- }
- style += 'padding-right:' + componentData.padding.both + 'px' + ';';
- style += 'padding-left:' + componentData.padding.both + 'px' + ';';
- if (componentData.styleType == 1) style += 'flex-wrap:wrap' + ';';
- }
- return style;
- });
- //组件样式
- const boxCss = computed(() => {
- let style = '';
- if (componentData.componentStartBgColor && componentData.componentEndBgColor)
- style += `background:linear-gradient(${componentData.componentGradientAngle},${componentData.componentStartBgColor},${componentData.componentEndBgColor});`;
- else if (componentData.componentStartBgColor) style += 'background-color:' + componentData.componentStartBgColor + ';';
- else if (componentData.componentEndBgColor) style += 'background-color:' + componentData.componentEndBgColor + ';';
- if (componentData.number) style += 'flex:' + `0 0 calc((100% - ${(componentData.number - 1) * 10}px) / ${componentData.number})` + ';';
- //圆角
- if (componentData.topRounded) style += 'border-top-left-radius:' + componentData.topRounded + 'px;';
- if (componentData.topRounded) style += 'border-top-right-radius:' + componentData.topRounded + 'px;';
- if (componentData.bottomRounded) style += 'border-bottom-left-radius:' + componentData.bottomRounded + 'px;';
- if (componentData.bottomRounded) style += 'border-bottom-right-radius:' + componentData.bottomRounded + 'px;';
- return style;
- });
- // 标题样式
- const titleCss = computed(() => {
- let style = '';
- if (componentData.titleColor) style += 'color:' + componentData.titleColor + ';';
- if (componentData.titleSize) style += 'font-size:' + componentData.titleSize + 'px;';
- if (componentData.titleWeight) style += 'font-weight:' + componentData.titleWeight + ';';
- return style;
- });
- // 副标题样式
- const subtitleCss = computed(() => {
- let style = '';
- if (componentData.subtitleColor) style += 'color:' + componentData.subtitleColor + ';';
- if (componentData.subtitleSize) style += 'font-size:' + componentData.subtitleSize + 'px;';
- return style;
- });
- </script>
- <style lang="scss" scoped>
- .pcPages {
- width: 1200px;
- margin: 0 auto;
- .data-bos {
- display: flex;
- gap: 10px;
- width: 100%;
- overflow-x: auto;
- .data-list {
- min-height: 170px;
- .img {
- height: 80px;
- width: 80px;
- }
- }
- }
- .carousel-bos {
- .carousel-list {
- width: 100%;
- height: 100%;
- display: flex;
- gap: 10px;
- flex-wrap: wrap;
- .data-list {
- height: 170px;
- .img {
- height: 80px;
- width: 80px;
- }
- }
- }
- }
- }
- </style>
|