|
|
@@ -1,23 +1,29 @@
|
|
|
<template>
|
|
|
<div class="pcPages" :style="warpCss">
|
|
|
- <div class="goods-bos" :style="boxCss">
|
|
|
- <div v-for="(item, index) in dataList" :key="index" class="goods-list flex-column-between" :style="goodsCss">
|
|
|
+ <div class="goods-bos" :style="boxCss" v-if="componentData.styleType == 1">
|
|
|
+ <div
|
|
|
+ v-for="(item, index) in dataList"
|
|
|
+ :key="index"
|
|
|
+ class="goods-list flex-column-between hover-color"
|
|
|
+ :style="goodsCss"
|
|
|
+ @click="onPath('/item?id=' + item.id)"
|
|
|
+ >
|
|
|
<img
|
|
|
class="goods-img"
|
|
|
:src="item.productImage ? item.productImage : figure"
|
|
|
alt=""
|
|
|
:style="componentData.imageRadius ? { borderRadius: componentData.imageRadius + 'px' } : {}"
|
|
|
/>
|
|
|
- <div v-if="componentData.goodsShow.includes(1)" :style="titleCss" class="itemName">{{ item.itemName || '' }}</div>
|
|
|
+ <div v-if="componentData.goodsShow.includes(1)" :style="titleCss" class="itemName zi-hover">{{ item.itemName || '商品名称' }}</div>
|
|
|
<div class="flex-row-between">
|
|
|
<div>
|
|
|
<span v-if="componentData.goodsShow.includes(2)" class="memberPrice" :style="{ color: componentData.priceColor }"
|
|
|
- >¥{{ item.memberPrice }}</span
|
|
|
+ >¥{{ item.memberPrice || '0.00' }}</span
|
|
|
>
|
|
|
- <span v-if="componentData.goodsShow.includes(3)" class="marketPrice">¥{{ item.marketPrice }}</span>
|
|
|
+ <span v-if="componentData.goodsShow.includes(3)" class="marketPrice">¥{{ item.marketPrice || '0.00' }}</span>
|
|
|
</div>
|
|
|
<template v-if="componentData.btnShow">
|
|
|
- <div v-if="componentData.btnStyle == 1" :style="btnCss1" class="btn1">{{ componentData.btnText }}</div>
|
|
|
+ <div v-if="componentData.btnStyle == 1" :style="btnCss1" class="btn1">{{ componentData.btnText || '购买' }}</div>
|
|
|
<div v-if="componentData.btnStyle == 2" :style="btnCss2" class="btn2 flex-row-center">
|
|
|
<el-icon size="14"><Plus /></el-icon>
|
|
|
</div>
|
|
|
@@ -28,103 +34,123 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <div v-else :style="boxCss">
|
|
|
+ <el-carousel height="300px" arrow="always" autoplay>
|
|
|
+ <el-carousel-item v-for="(item1, index1) in dataList" :key="index1" class="w100% h100%">
|
|
|
+ <div class="goods-bos">
|
|
|
+ <div
|
|
|
+ v-for="(item, index) in item1"
|
|
|
+ :key="index"
|
|
|
+ class="goods-list flex-column-between hover-color"
|
|
|
+ :style="goodsCss"
|
|
|
+ @click="onPath('/item?id=' + item.id)"
|
|
|
+ >
|
|
|
+ <img
|
|
|
+ class="goods-img"
|
|
|
+ :src="item.productImage ? item.productImage : figure"
|
|
|
+ alt=""
|
|
|
+ :style="componentData.imageRadius ? { borderRadius: componentData.imageRadius + 'px' } : {}"
|
|
|
+ />
|
|
|
+ <div v-if="componentData.goodsShow.includes(1)" :style="titleCss" class="itemName zi-hover">{{ item.itemName || '商品名称' }}</div>
|
|
|
+ <div class="flex-row-between">
|
|
|
+ <div>
|
|
|
+ <span v-if="componentData.goodsShow.includes(2)" class="memberPrice" :style="{ color: componentData.priceColor }"
|
|
|
+ >¥{{ item.memberPrice || '0.00' }}</span
|
|
|
+ >
|
|
|
+ <span v-if="componentData.goodsShow.includes(3)" class="marketPrice">¥{{ item.marketPrice || '0.00' }}</span>
|
|
|
+ </div>
|
|
|
+ <template v-if="componentData.btnShow">
|
|
|
+ <div v-if="componentData.btnStyle == 1" :style="btnCss1" class="btn1">{{ componentData.btnText || '购买' }}</div>
|
|
|
+ <div v-if="componentData.btnStyle == 2" :style="btnCss2" class="btn2 flex-row-center">
|
|
|
+ <el-icon size="14"><Plus /></el-icon>
|
|
|
+ </div>
|
|
|
+ <div v-if="componentData.btnStyle == 3" :style="btnCss2" class="btn2 flex-row-center">
|
|
|
+ <icon name="iconfont icongouwuche" size="14px" />
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-carousel-item>
|
|
|
+ </el-carousel>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
+import { onPath } from '@/utils/siteConfig';
|
|
|
import figure from '@/assets/images/figure.png';
|
|
|
-import usePcdiyStore from '@/store/modules/pcdiy';
|
|
|
-import { listBase } from '@/api/pmsProduct/base';
|
|
|
-const diyStore = usePcdiyStore();
|
|
|
+import { getDiyProductPage } from '@/api/home/diy';
|
|
|
|
|
|
-const props = defineProps<{
|
|
|
- index: number; // 确保声明 index 为可选属性
|
|
|
+interface Props {
|
|
|
row?: any;
|
|
|
-}>();
|
|
|
-const componentData = props.row ? props.row : diyStore.componentList[props.index];
|
|
|
-const dataList = ref<any>([{}, {}, {}, {}, {}]);
|
|
|
+}
|
|
|
+
|
|
|
+const props = defineProps<Props>();
|
|
|
+const componentData = props.row || {};
|
|
|
+const original = ref<any>([{}, {}, {}, {}, {}]);
|
|
|
|
|
|
onMounted(() => {
|
|
|
getDataList();
|
|
|
});
|
|
|
|
|
|
const getDataList = () => {
|
|
|
- dataList.value = [{}, {}, {}, {}, {}];
|
|
|
+ original.value = [{}, {}, {}, {}, {}];
|
|
|
//手动选择
|
|
|
if (componentData.goodsType == 1) {
|
|
|
if (componentData.goodsIds.length > 0) {
|
|
|
- listBase({ pageNum: 1, pageSize: 20, ids: componentData.goodsIds.join(',') }).then((res) => {
|
|
|
+ getDiyProductPage({ pageNum: 1, pageSize: 20, ids: componentData.goodsIds.join(',') }).then((res) => {
|
|
|
if (res.code == 200) {
|
|
|
- dataList.value = res.rows;
|
|
|
+ original.value = res.rows;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
} else if (componentData.goodsType == 2) {
|
|
|
//分类查询
|
|
|
- if (componentData.goodsClassify) {
|
|
|
- listBase({
|
|
|
+ if (componentData.categoryIds && componentData.categoryIds.length > 0) {
|
|
|
+ const categoryIds = componentData.categoryIds.map((item: any) => item[2]);
|
|
|
+ getDiyProductPage({
|
|
|
pageNum: 1,
|
|
|
- pageSize: componentData.goodsNumber == 0 ? 50 : componentData.goodsNumber,
|
|
|
- topCategoryId: componentData.topCategoryId,
|
|
|
- mediumCategoryId: componentData.mediumCategoryId,
|
|
|
- bottomCategoryId: componentData.bottomCategoryId
|
|
|
+ pageSize: componentData.goodsNumber == 0 ? 9999 : componentData.goodsNumber,
|
|
|
+ categoryIds: categoryIds.join(',')
|
|
|
}).then((res) => {
|
|
|
if (res.code == 200) {
|
|
|
- dataList.value = res.rows;
|
|
|
+ if (res.rows && res.rows.length > 0) {
|
|
|
+ original.value = res.rows;
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
} else if (componentData.goodsType == 3) {
|
|
|
//品牌查询
|
|
|
- if (componentData.goodsBrand) {
|
|
|
- listBase({
|
|
|
+ if (componentData.brandIds && componentData.brandIds.length > 0) {
|
|
|
+ getDiyProductPage({
|
|
|
pageNum: 1,
|
|
|
- pageSize: componentData.goodsNumber == 0 ? 50 : componentData.goodsNumber,
|
|
|
- brandId: componentData.goodsBrand
|
|
|
+ pageSize: componentData.goodsNumber == 0 ? 9999 : componentData.goodsNumber,
|
|
|
+ brandIds: componentData.brandIds.join(',')
|
|
|
}).then((res) => {
|
|
|
if (res.code == 200) {
|
|
|
- dataList.value = res.rows;
|
|
|
+ if (res.rows && res.rows.length > 0) {
|
|
|
+ original.value = res.rows;
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-watch(
|
|
|
- () => componentData.goodsType,
|
|
|
- () => {
|
|
|
- getDataList();
|
|
|
- }
|
|
|
-);
|
|
|
-
|
|
|
-watch(
|
|
|
- () => componentData.goodsClassify,
|
|
|
- () => {
|
|
|
- getDataList();
|
|
|
- }
|
|
|
-);
|
|
|
-
|
|
|
-watch(
|
|
|
- () => componentData.goodsNumber,
|
|
|
- () => {
|
|
|
- getDataList();
|
|
|
- }
|
|
|
-);
|
|
|
-
|
|
|
-watch(
|
|
|
- () => componentData.goodsBrand,
|
|
|
- () => {
|
|
|
- getDataList();
|
|
|
+const dataList = computed(() => {
|
|
|
+ if (componentData.styleType == 1) {
|
|
|
+ return original.value;
|
|
|
+ } else {
|
|
|
+ const pageSize = 5;
|
|
|
+ const groupedUsers = [];
|
|
|
+ for (let i = 0; i < original.value.length; i += pageSize) {
|
|
|
+ groupedUsers.push(original.value.slice(i, i + pageSize));
|
|
|
+ }
|
|
|
+ return groupedUsers;
|
|
|
}
|
|
|
-);
|
|
|
-
|
|
|
-watch(
|
|
|
- () => componentData.goodsIds,
|
|
|
- () => {
|
|
|
- getDataList();
|
|
|
- },
|
|
|
- { deep: true } // 5. 数组变化需要 deep 监听
|
|
|
-);
|
|
|
+});
|
|
|
|
|
|
const warpCss = computed(() => {
|
|
|
let style = '';
|
|
|
@@ -157,7 +183,15 @@ const warpCss = computed(() => {
|
|
|
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;';
|
|
|
-
|
|
|
+ //间距
|
|
|
+ if (componentData.margin) {
|
|
|
+ if (componentData.margin.top > 0) {
|
|
|
+ style += 'margin-top:' + componentData.margin.top + 'px' + ';';
|
|
|
+ }
|
|
|
+ if (componentData.margin.bottom > 0) {
|
|
|
+ style += 'margin-bottom:' + componentData.margin.bottom + 'px' + ';';
|
|
|
+ }
|
|
|
+ }
|
|
|
return style;
|
|
|
});
|
|
|
|
|
|
@@ -221,13 +255,13 @@ const btnCss2 = computed(() => {
|
|
|
.goods-bos {
|
|
|
display: flex;
|
|
|
gap: 10px;
|
|
|
- overflow: auto;
|
|
|
.goods-list {
|
|
|
padding: 20px 15px;
|
|
|
height: 300px;
|
|
|
width: 0;
|
|
|
flex: 0 0 calc((100% - 40px) / 5);
|
|
|
overflow: hidden;
|
|
|
+ cursor: pointer;
|
|
|
.goods-img {
|
|
|
width: 100%;
|
|
|
height: 180px;
|