Fix:4735 【商城小程序】管理后台未配置养生榜单数据的情况下点击【确认】后,前端无需显示养生榜单模块

This commit is contained in:
LinCyJang
2026-01-14 23:21:15 +08:00
parent 84ddb0790e
commit 4897edce74
+27 -2
View File
@@ -57,14 +57,14 @@
</view>
</swiper-item>
</swiper>
<view class="v12-justify-center v12-mt-3" v-if="rank.length > 0">
<view class="v12-justify-center v12-mt-3" v-if="hasRankData">
<image
class="title-img"
:src="webUrl + '/orderIcon/rankTitle.png'"
mode="widthFix"
></image>
</view>
<view class="rank-wrap v12-mt-3" v-if="rank.length > 0">
<view class="rank-wrap v12-mt-3" v-if="hasRankData">
<view class="rank-items-wrap">
<view class="bee-rank" v-for="(k, i) in rank" :key="i">
<image :src="k.backgroundImage" class="bg-img" style="width:inherit" mode="scaleToFill"></image>
@@ -196,6 +196,31 @@ export default {
ProductWindow
},
mixins: [goCartMixin],
computed: {
hasRankData() {
if (!Array.isArray(this.rank)) return false;
const hasText = (v) => typeof v === "string" && v.trim() !== "";
const hasValue = (v) => v !== null && v !== undefined && v !== "";
return this.rank.some((item) => {
if (!item) return false;
if (hasText(item.title) || hasText(item.backgroundImage)) {
return true;
}
if (Array.isArray(item.products)) {
return item.products.some((p) => {
if (!p) return false;
return (
hasText(p.productTitle) ||
hasText(p.productDesc) ||
hasValue(p.productImage) ||
hasValue(p.productId)
);
});
}
return false;
});
}
},
data() {
return {
webUrl: this.$VUE_APP_RESOURCES_URL,