文件
xionggeshop/xgsc.gynhc.com_wx/pages/index/index/home-zone-grid.vue
2026-09-14 17:24:53 +08:00

446 行
9.1 KiB
Vue

<template>
<view class="zone-wrap" v-if="mainZone">
<view class="zone-grid">
<view
class="zone-card zone-card--hero"
:class="'zone-card--' + mainZone.theme"
hover-class="zone-card--pressed"
@tap="onTap(mainZone)"
>
<image
v-if="!mainZone.image"
class="zone-card__hero-bg"
:src="bottleImage"
mode="aspectFit"
></image>
<image
v-else
class="zone-card__hero-bg"
:src="mainZone.image"
mode="aspectFit"
></image>
<view class="zone-card__hero-mask"></view>
<view class="zone-card__sheen"></view>
<view class="zone-card__hero-float">
<view class="zone-card__copy">
<text class="zone-card__title">{{ mainZone.title }}</text>
<view class="zone-card__subtitle" v-if="heroSubtitleLines.length">
<text
class="zone-card__subtitle-line"
v-for="(line, index) in heroSubtitleLines"
:key="index"
>{{ line }}</text>
</view>
</view>
<view class="zone-card__cta">
<text class="zone-card__cta-text" :class="'zone-card__cta-text--' + mainZone.theme">立即查看</text>
<view class="zone-card__cta-arrow" :class="'zone-card__cta-arrow--' + mainZone.theme">
<u-icon name="arrow-right" :size="18" color="#FFFFFF"></u-icon>
</view>
</view>
</view>
</view>
<view class="zone-stack">
<view
v-for="item in sideZones"
:key="item.key"
class="zone-card zone-card--mini"
:class="'zone-card--' + item.theme"
hover-class="zone-card--pressed"
@tap="onTap(item)"
>
<image
v-if="getMiniDeco(item)"
class="zone-card__mini-bg"
:src="getMiniDeco(item)"
mode="aspectFit"
></image>
<view class="zone-card__mini-mask" :class="'zone-card__mini-mask--' + item.theme"></view>
<view class="zone-card__sheen zone-card__sheen--mini"></view>
<view class="zone-card__mini-float">
<view class="zone-card__mini-main">
<text class="zone-card__mini-title">{{ item.title }}</text>
<text class="zone-card__mini-hint">进入专区</text>
</view>
<view class="zone-card__mini-arrow">
<u-icon name="arrow-right" :size="20" color="#FFFFFF"></u-icon>
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
const DEFAULT_ZONES = [
{
key: 'main',
theme: 'green',
title: '雄戈系列',
subtitle: '经典之选 · 品质之作',
path: '/pages/index/category'
},
{
key: 'repurchase',
theme: 'orange',
title: '复购专区',
path: '/pages/index/category'
},
{
key: 'exchange',
theme: 'blue',
title: '兑换专区',
path: '/pages/index/category'
},
{
key: 'mall',
theme: 'purple',
title: '平台商城',
path: '/pages/index/category'
}
];
export default {
data() {
return {
bottleImage: '/static/images/home/zone-xiongge-bottle.png',
miniDecoMap: {
repurchase: '/static/images/home/zone-mini-repurchase.png',
exchange: '/static/images/home/zone-mini-exchange.png',
mall: '/static/images/home/zone-mini-mall.png'
}
};
},
props: {
list: {
type: Array,
default: () => []
}
},
computed: {
zones() {
if (this.list && this.list.length >= 4) {
return this.list.slice(0, 4).map((item, index) => ({
key: item.key || DEFAULT_ZONES[index].key,
theme: DEFAULT_ZONES[index].theme,
title: item.title || item.name || DEFAULT_ZONES[index].title,
subtitle: index === 0 ? (item.subtitle || DEFAULT_ZONES[0].subtitle) : '',
path: item.path || DEFAULT_ZONES[index].path,
image: item.image || ''
}));
}
return DEFAULT_ZONES;
},
mainZone() {
return this.zones[0] || null;
},
heroSubtitleLines() {
const subtitle = this.mainZone && this.mainZone.subtitle;
if (!subtitle) return [];
return subtitle.split(/\s*[·•]\s*/).filter(Boolean);
},
sideZones() {
return this.zones.slice(1, 4);
}
},
methods: {
getMiniDeco(item) {
if (item.image) {
return item.image;
}
return this.miniDecoMap[item.key] || '';
},
onTap(item) {
if (item.path) {
this.$tools.routerTo(item.path);
}
}
}
};
</script>
<style lang="scss" scoped>
.zone-wrap {
margin: 8rpx $brand-page-gutter 20rpx;
padding: 10rpx;
border-radius: 28rpx;
background: $zone-bg;
box-shadow: $zone-elevation-sm;
}
.zone-grid {
display: flex;
flex-direction: row;
align-items: stretch;
gap: 12rpx;
}
.zone-stack {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
justify-content: space-between;
gap: 12rpx;
}
.zone-card {
position: relative;
overflow: hidden;
border-radius: 22rpx;
box-shadow: $zone-elevation-sm;
transition: transform 0.2s ease, opacity 0.2s ease;
}
.zone-card--pressed {
transform: scale(0.985);
opacity: 0.92;
}
.zone-card--green {
background: $zone-green-grad;
}
.zone-card--orange { background: $zone-orange-grad; }
.zone-card--blue { background: $zone-blue-grad; }
.zone-card--purple { background: $zone-purple-grad; }
.zone-card__sheen {
position: absolute;
inset: 0 0 auto 0;
height: 42%;
background: linear-gradient(180deg, rgba(255, 255, 255, 0.18) 0%, transparent 100%);
pointer-events: none;
z-index: 1;
}
.zone-card__sheen--mini {
height: 100%;
width: 38%;
left: auto;
right: 0;
background: linear-gradient(270deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
}
.zone-card--hero {
width: 48%;
flex-shrink: 0;
min-height: 400rpx;
padding: 0;
box-sizing: border-box;
}
.zone-card__hero-bg {
position: absolute;
right: -24rpx;
bottom: -32rpx;
width: 88%;
height: 92%;
z-index: 0;
pointer-events: none;
opacity: 0.88;
}
.zone-card__hero-mask {
position: absolute;
inset: 0;
z-index: 1;
pointer-events: none;
background: linear-gradient(
102deg,
rgba(4, 120, 87, 0.96) 0%,
rgba(5, 150, 105, 0.88) 34%,
rgba(16, 185, 129, 0.52) 58%,
rgba(16, 185, 129, 0.08) 82%,
transparent 100%
);
}
.zone-card__hero-float {
position: relative;
z-index: 3;
min-height: 400rpx;
padding: 32rpx 28rpx 30rpx;
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.zone-card--mini {
flex: 1;
min-height: 118rpx;
padding: 0;
box-sizing: border-box;
}
.zone-card__mini-bg {
position: absolute;
right: -18rpx;
bottom: -22rpx;
width: 74%;
height: 118%;
z-index: 0;
pointer-events: none;
opacity: 0.9;
}
.zone-card__mini-mask {
position: absolute;
inset: 0;
z-index: 1;
pointer-events: none;
}
.zone-card__mini-mask--orange {
background: linear-gradient(
96deg,
rgba(194, 65, 12, 0.95) 0%,
rgba(234, 88, 12, 0.84) 40%,
rgba(245, 158, 11, 0.28) 72%,
transparent 100%
);
}
.zone-card__mini-mask--blue {
background: linear-gradient(
96deg,
rgba(29, 78, 216, 0.95) 0%,
rgba(37, 99, 235, 0.84) 40%,
rgba(59, 130, 246, 0.28) 72%,
transparent 100%
);
}
.zone-card__mini-mask--purple {
background: linear-gradient(
96deg,
rgba(109, 40, 217, 0.95) 0%,
rgba(124, 58, 237, 0.84) 40%,
rgba(139, 92, 246, 0.28) 72%,
transparent 100%
);
}
.zone-card__mini-float {
position: relative;
z-index: 3;
min-height: 118rpx;
padding: 18rpx 20rpx;
box-sizing: border-box;
display: flex;
flex-direction: row;
align-items: center;
}
.zone-card__copy {
min-height: 0;
}
.zone-card__title {
display: block;
font-size: 36rpx;
font-weight: 700;
color: #ffffff;
line-height: 1.28;
letter-spacing: 0.5rpx;
}
.zone-card__subtitle {
display: flex;
flex-direction: column;
margin-top: 10rpx;
}
.zone-card__subtitle-line {
display: block;
font-size: 21rpx;
font-weight: 400;
color: rgba(255, 255, 255, 0.9);
line-height: 1.55;
}
.zone-card__cta {
display: inline-flex;
flex-direction: row;
align-items: center;
align-self: flex-start;
flex-shrink: 0;
margin-top: 28rpx;
padding: 12rpx 12rpx 12rpx 24rpx;
background: rgba(255, 255, 255, 0.98);
border-radius: 999rpx;
box-shadow: 0 4rpx 12rpx rgba(4, 78, 56, 0.12);
}
.zone-card__cta-text {
font-size: 24rpx;
font-weight: 600;
line-height: 1;
white-space: nowrap;
flex-shrink: 0;
}
.zone-card__cta-text--green { color: $zone-green-end; }
.zone-card__cta-text--orange { color: $zone-orange-end; }
.zone-card__cta-text--blue { color: $zone-blue-end; }
.zone-card__cta-text--purple { color: $zone-purple-end; }
.zone-card__cta-arrow {
width: 40rpx;
height: 40rpx;
margin-left: 10rpx;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.zone-card__cta-arrow--green { background: $zone-green-grad; }
.zone-card__cta-arrow--orange { background: $zone-orange-grad; }
.zone-card__cta-arrow--blue { background: $zone-blue-grad; }
.zone-card__cta-arrow--purple { background: $zone-purple-grad; }
.zone-card__mini-main {
flex: 1;
min-width: 0;
padding-right: 12rpx;
}
.zone-card__mini-title {
display: block;
font-size: 28rpx;
font-weight: 700;
color: #ffffff;
line-height: 1.25;
white-space: nowrap;
}
.zone-card__mini-hint {
display: block;
margin-top: 4rpx;
font-size: 20rpx;
color: rgba(255, 255, 255, 0.78);
line-height: 1.3;
white-space: nowrap;
}
.zone-card__mini-arrow {
width: 48rpx;
height: 48rpx;
border-radius: 50%;
background: rgba(255, 255, 255, 0.18);
border: 1rpx solid rgba(255, 255, 255, 0.26);
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
</style>