|
@@ -857,7 +857,7 @@
|
|
|
}"
|
|
}"
|
|
|
>
|
|
>
|
|
|
<!-- “猜你喜欢”特殊栏目,固定图标尺寸为 18*18 -->
|
|
<!-- “猜你喜欢”特殊栏目,固定图标尺寸为 18*18 -->
|
|
|
- <img v-if="item.id === 1 || item.name === '猜你喜欢'" src="" class="recommend-img-heart" alt="猜你喜欢" />
|
|
|
|
|
|
|
+ <img v-if="item.name === '猜你喜欢'" src="/猜你喜欢.png" class="recommend-img-heart" alt="猜你喜欢" />
|
|
|
<!-- 其他常规分类,默认图标尺寸为 36*36 -->
|
|
<!-- 其他常规分类,默认图标尺寸为 36*36 -->
|
|
|
<img v-else :src="item.icon || ''" class="recommend-img-standard" alt="分类图标" />
|
|
<img v-else :src="item.icon || ''" class="recommend-img-standard" alt="分类图标" />
|
|
|
</div>
|
|
</div>
|
|
@@ -914,10 +914,17 @@
|
|
|
|
|
|
|
|
<el-table :data="recommendList" border style="width: 100%" header-cell-class-name="table-header-custom" class="standard-table">
|
|
<el-table :data="recommendList" border style="width: 100%" header-cell-class-name="table-header-custom" class="standard-table">
|
|
|
<el-table-column label="位置" width="80" align="center">
|
|
<el-table-column label="位置" width="80" align="center">
|
|
|
- <template #default="{ $index }">
|
|
|
|
|
|
|
+ <template #default="{ row, $index }">
|
|
|
<div class="rank-action-btns">
|
|
<div class="rank-action-btns">
|
|
|
- <el-icon v-if="$index > 0" class="rank-btn-mini" @click="moveRecommend($index, -1)"><ArrowUp /></el-icon>
|
|
|
|
|
- <el-icon v-if="$index < recommendList.length - 1" class="rank-btn-mini" @click="moveRecommend($index, 1)"><ArrowDown /></el-icon>
|
|
|
|
|
|
|
+ <!-- 猜你喜欢固定在第一位,不显示移动箭头 -->
|
|
|
|
|
+ <el-icon v-if="$index > 0 && row.name !== '猜你喜欢'" class="rank-btn-mini" @click="moveRecommend($index, -1)"><ArrowUp /></el-icon>
|
|
|
|
|
+ <el-icon
|
|
|
|
|
+ v-if="$index < recommendList.length - 1 && row.name !== '猜你喜欢'"
|
|
|
|
|
+ class="rank-btn-mini"
|
|
|
|
|
+ @click="moveRecommend($index, 1)"
|
|
|
|
|
+ >
|
|
|
|
|
+ <ArrowDown />
|
|
|
|
|
+ </el-icon>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
@@ -2879,17 +2886,24 @@ const loadRecommendList = async () => {
|
|
|
try {
|
|
try {
|
|
|
const res = await listRecommendCategoryConfig({ customerId: customerId.value, pageNum: 1, pageSize: 100 } as any);
|
|
const res = await listRecommendCategoryConfig({ customerId: customerId.value, pageNum: 1, pageSize: 100 } as any);
|
|
|
const rows = res.rows || [];
|
|
const rows = res.rows || [];
|
|
|
- recommendList.value = rows.map((item: any) => ({
|
|
|
|
|
- id: item.id,
|
|
|
|
|
- name: item.name || '',
|
|
|
|
|
- icon: item.iconUrl || '',
|
|
|
|
|
- type: item.dataType || 'select',
|
|
|
|
|
- categoryPath: item.categoryPath || '',
|
|
|
|
|
- categoryLabel: item.categoryLabel || '',
|
|
|
|
|
- selectedProducts: item.selectedProductIds ? mapProductsFromBackend(JSON.parse(item.selectedProductIds)) : [],
|
|
|
|
|
- sortOrder: item.sortOrder ?? 0,
|
|
|
|
|
- status: item.status ?? 1
|
|
|
|
|
- }));
|
|
|
|
|
|
|
+ recommendList.value = rows
|
|
|
|
|
+ .map((item: any) => ({
|
|
|
|
|
+ id: item.id,
|
|
|
|
|
+ name: item.name || '',
|
|
|
|
|
+ icon: item.iconUrl || '',
|
|
|
|
|
+ type: item.dataType || 'select',
|
|
|
|
|
+ categoryPath: item.categoryPath || '',
|
|
|
|
|
+ categoryLabel: item.categoryLabel || '',
|
|
|
|
|
+ selectedProducts: item.selectedProductIds ? mapProductsFromBackend(JSON.parse(item.selectedProductIds)) : [],
|
|
|
|
|
+ sortOrder: item.sortOrder ?? 0,
|
|
|
|
|
+ status: item.status ?? 1
|
|
|
|
|
+ }))
|
|
|
|
|
+ .sort((a: any, b: any) => {
|
|
|
|
|
+ // "猜你喜欢"始终固定在第一位
|
|
|
|
|
+ if (a.name === '猜你喜欢') return -1;
|
|
|
|
|
+ if (b.name === '猜你喜欢') return 1;
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ });
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error('加载推荐分类列表失败', error);
|
|
console.error('加载推荐分类列表失败', error);
|
|
|
}
|
|
}
|
|
@@ -3059,6 +3073,11 @@ const moveRecommend = async (index: number, direction: number) => {
|
|
|
const targetIndex = index + direction;
|
|
const targetIndex = index + direction;
|
|
|
if (targetIndex < 0 || targetIndex >= recommendList.value.length) return;
|
|
if (targetIndex < 0 || targetIndex >= recommendList.value.length) return;
|
|
|
|
|
|
|
|
|
|
+ // "猜你喜欢"固定在第一位,不允许移动
|
|
|
|
|
+ const currentItem = recommendList.value[index];
|
|
|
|
|
+ const targetItem = recommendList.value[targetIndex];
|
|
|
|
|
+ if (currentItem.name === '猜你喜欢' || targetItem.name === '猜你喜欢') return;
|
|
|
|
|
+
|
|
|
const temp = recommendList.value[index];
|
|
const temp = recommendList.value[index];
|
|
|
recommendList.value[index] = recommendList.value[targetIndex];
|
|
recommendList.value[index] = recommendList.value[targetIndex];
|
|
|
recommendList.value[targetIndex] = temp;
|
|
recommendList.value[targetIndex] = temp;
|