Commit 48c8977c by Lin

fix(HomeFrame, ActivityTime): 修复潜在的空引用错误并优化样式

- 在 HomeFrame 组件中使用可选链操作符修复对 messageRef 的调用,避免空引用错误。
- 在 ActivityTime 组件中优化样式,调整商品项的类名和布局,确保更好的视觉效果和用户体验。
1 parent a4ee5825
......@@ -48,20 +48,22 @@
<view
v-for="(item, index) in goodsList"
:key="item.id || index"
:class="['goods-item', { active: goodsIndex === index }]"
class="goods-item-shell"
@click="handleGoodsClick(item, index)"
>
<view v-if="item.isMainPush" class="goods-item-badge">主推</view>
<view v-else class="goods-item-badge badge02">次推</view>
<view class="goods-item-img-wrap">
<image class="goods-item-img" :src="item.thumbImageUrl" mode="aspectFill" />
</view>
<view class="goods-item-content">
<text class="goods-item-name">{{ item.name }}</text>
<view class="goods-item-desc text-two-line">{{ item.description }}</view>
<view class="goods-item-price-wrap">
<text class="goods-item-price">¥ {{ item.price }}</text>
<text v-if="item.originalPrice" class="goods-item-original-price">¥ {{ item.originalPrice }}</text>
<view :class="['goods-item', { active: goodsIndex === index }]">
<view v-if="item.isMainPush" class="goods-item-badge">主推</view>
<view v-else class="goods-item-badge badge02">次推</view>
<view class="goods-item-img-wrap">
<image class="goods-item-img" :src="item.thumbImageUrl" mode="aspectFill" />
</view>
<view class="goods-item-content">
<text class="goods-item-name">{{ item.name }}</text>
<view class="goods-item-desc text-two-line">{{ item.description }}</view>
<view class="goods-item-price-wrap">
<text class="goods-item-price">¥ {{ item.price }}</text>
<text v-if="item.originalPrice" class="goods-item-original-price">¥ {{ item.originalPrice }}</text>
</view>
</view>
</view>
</view>
......@@ -324,8 +326,11 @@ export default {
}
}
.goods-box {
$shadow-space: 10px;
width: 100%;
overflow: visible;
// 允许横向阴影溢出父级,避免负 margin 扩展后被外层裁剪
clip-path: inset(0 -#{$shadow-space});
.goods-img-wrap {
position: relative;
......@@ -375,26 +380,38 @@ export default {
.goods-menu {
$goods-item-height: 120px;
$shadow-space: 8px;
$shadow-space: 10px;
$item-gap: 12px;
// 向外扩展滚动视口,配合首尾 margin 消除左右空隙并保留阴影绘制空间
// scroll-view 自身 padding 为视口边缘预留阴影区,负 margin 保持与父级同宽对齐
width: calc(100% + #{$shadow-space * 2});
margin: toRpx(28) (-$shadow-space);
margin: toRpx(28) (-$shadow-space) 0;
height: calc(#{$goods-item-height} + #{$shadow-space * 2});
padding: $shadow-space;
box-sizing: border-box;
white-space: nowrap;
.goods-menu-inner {
display: flex;
flex-wrap: nowrap;
gap: 12px;
align-items: stretch;
height: $goods-item-height;
padding: $shadow-space 0;
box-sizing: border-box;
}
.goods-item-shell {
flex-shrink: 0;
padding: $shadow-space;
margin: (-$shadow-space) 0;
box-sizing: content-box;
& + & {
margin-left: calc(#{$item-gap} - #{$shadow-space * 2});
}
}
.goods-item {
position: relative;
flex-shrink: 0;
box-sizing: border-box;
width: 252px;
height: $goods-item-height;
......@@ -407,14 +424,6 @@ export default {
box-shadow: 0 2px 8px 0 rgba(44, 102, 247, 0.10);
cursor: pointer;
&:first-child {
margin-left: $shadow-space;
}
&:last-child {
margin-right: $shadow-space;
}
&.active {
border: 1.5px solid rgba(44, 102, 247, 0.10);
background: linear-gradient(0deg, rgba(44, 102, 247, 0.05) 0%, rgba(44, 102, 247, 0.05) 100%), #FFF;
......@@ -518,4 +527,11 @@ export default {
margin-top: toRpx(28);
}
}
::v-deep .goods-menu {
.uni-scroll-view,
.uni-scroll-view-content {
height: 100%;
}
}
</style>
......@@ -508,7 +508,7 @@ export default {
// 监听自定义事件
uni.$on('pageBack', () => {
this.$refs.leftBox.getMessageInfo()
this.$refs.messageRef.getMessageSummary()
this.$refs.messageRef?.getMessageSummary()
})
uni.$on('refreshCustomerProfileGroupInfo', () => {
this.getCustomerProfileGroupInfo()
......@@ -721,7 +721,7 @@ export default {
},
async changeTab({ item, index }) {
if (index == 0) {
this.$refs.messageRef.getMessageSummary()
this.$refs.messageRef?.getMessageSummary()
this.getCustomerProfileGroupInfo()
this.getStrategyStatus()
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!