mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp.git
synced 2026-11-06 17:09:01 +08:00
- 将所有模板组件的 pageGap/marginBottom 默认值从 10rpx 调整为 0 - 重构店铺卡片样式一为全景大片橱窗布局,添加自营标签与图片加载容错 - 重构店铺卡片样式二为大牌名店街 + 精品橱窗风格,优化商品封面与价格展示 - 促销详情模板添加 isRealGoods 过滤,无有效数据时整块不渲染 - 修复 u-notice-bar 横向滚动模式下 text 需为字符串的类型兼容问题 - 统一将模板中 HTML 实体 > 改为插值表达式避免转义异常
105 lines
2.9 KiB
Vue
105 lines
2.9 KiB
Vue
<template>
|
|
<view class="tpl-article" :class="{ styled: styled }" :style="wrapperStyle" v-if="articleList.length">
|
|
<view class="article-title" v-if="title">{{ title }}</view>
|
|
<view
|
|
class="article-item"
|
|
v-for="item in articleList"
|
|
:key="item.id"
|
|
@click="goDetail(item)"
|
|
>
|
|
<view class="article-text">
|
|
<view class="article-name" :style="nameStyle">{{ item.title }}</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref, computed, onMounted } from "vue";
|
|
import { getArticleList } from "@/api/article.js";
|
|
|
|
const props = defineProps<{ res: any }>();
|
|
|
|
const articleList = ref<any[]>([]);
|
|
|
|
const title = computed(() => props.res?.list?.[0]?.title || "");
|
|
const count = computed(() => props.res?.list?.[0]?.count || 3);
|
|
const categoryId = computed(() => props.res?.list?.[0]?.categoryId || "");
|
|
|
|
// 面板保存过样式字段才启用自定义样式,老数据保持原样
|
|
const styled = computed(() => props.res && props.res.paddingTop !== undefined);
|
|
const wrapperStyle = computed(() => {
|
|
const res = props.res || {};
|
|
if (styled.value) {
|
|
const bg =
|
|
!res.bgColor2 || res.bgColor1 === res.bgColor2
|
|
? res.bgColor1
|
|
: `linear-gradient(180deg, ${res.bgColor1}, ${res.bgColor2})`;
|
|
const radius = Number(res.borderRadius) || 0;
|
|
return {
|
|
background: bg,
|
|
padding: `${Number(res.paddingTop) || 0}rpx ${Number(res.paddingX) || 0}rpx ${Number(res.paddingBottom) || 0}rpx`,
|
|
marginBottom: `${Number(res.pageGap) || 0}rpx`,
|
|
borderRadius: `${radius}rpx`,
|
|
overflow: radius > 0 ? "hidden" : "visible",
|
|
display: "flex",
|
|
flexDirection: "column",
|
|
rowGap: `${Number(res.contentGap) || 0}rpx`,
|
|
};
|
|
}
|
|
return {
|
|
background: res.bgColor || "#FFFFFF",
|
|
padding: `20rpx ${res.paddingX ?? 0}rpx`,
|
|
marginBottom: `${res.pageGap ?? 0}rpx`,
|
|
borderRadius: `${res.borderRadius ?? 0}rpx`,
|
|
overflow: "hidden",
|
|
};
|
|
});
|
|
const nameStyle = computed(() =>
|
|
styled.value && props.res.titleColor ? { color: props.res.titleColor } : {}
|
|
);
|
|
|
|
onMounted(() => {
|
|
const params: any = { pageNumber: 1, pageSize: count.value };
|
|
if (categoryId.value) params.categoryId = categoryId.value;
|
|
getArticleList(params).then((res) => {
|
|
if (res.data.success && res.data.result) {
|
|
articleList.value = (res.data.result.records || []).slice(0, count.value);
|
|
}
|
|
});
|
|
});
|
|
|
|
function goDetail(item: any) {
|
|
uni.navigateTo({ url: `/pages/passport/article?id=${item.id}` });
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.article-title {
|
|
font-size: 30rpx;
|
|
font-weight: 600;
|
|
padding: 8rpx 24rpx 20rpx;
|
|
}
|
|
.article-item {
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 16rpx 24rpx;
|
|
border-top: 2rpx solid #f5f5f5;
|
|
}
|
|
.tpl-article.styled .article-item {
|
|
border-top: none;
|
|
padding: 0;
|
|
}
|
|
.article-text {
|
|
flex: 1;
|
|
min-width: 0;
|
|
}
|
|
.article-name {
|
|
font-size: 26rpx;
|
|
color: #333;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
</style>
|