mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp.git
synced 2026-11-13 20:38:51 +08:00
feat(uniapp): 首页楼层模板支持装修样式字段,修复 tpl_notice 样式缺少闭合括号
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<view class="tpl-article" :style="wrapperStyle" v-if="articleList.length">
|
||||
<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"
|
||||
@@ -8,7 +8,7 @@
|
||||
@click="goDetail(item)"
|
||||
>
|
||||
<view class="article-text">
|
||||
<view class="article-name">{{ item.title }}</view>
|
||||
<view class="article-name" :style="nameStyle">{{ item.title }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -26,13 +26,38 @@ 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 wrapperStyle = computed(() => ({
|
||||
background: props.res?.bgColor || "#FFFFFF",
|
||||
padding: `20rpx ${props.res?.paddingX ?? 0}rpx`,
|
||||
marginBottom: `${props.res?.pageGap ?? 10}rpx`,
|
||||
borderRadius: `${props.res?.borderRadius ?? 0}rpx`,
|
||||
overflow: "hidden",
|
||||
}));
|
||||
// 面板保存过样式字段才启用自定义样式,老数据保持原样
|
||||
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 ?? 10}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 };
|
||||
@@ -61,6 +86,10 @@ function goDetail(item: any) {
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user