632 行
7.1 KiB
Vue
632 行
7.1 KiB
Vue
<template>
|
|
|
|
<view class="home-hero">
|
|
|
|
<view class="home-hero__nav" :style="[navTopStyle]">
|
|
|
|
<view class="home-hero__top" :style="[capsuleRowStyle, topRowStyle]">
|
|
|
|
<view class="brand-block">
|
|
|
|
<text class="brand-title u-ellipsis-1">{{ navTitle || '雄戈小酒' }}</text>
|
|
|
|
<text class="brand-tagline u-ellipsis-1">臻选酱香 · 品质生活</text>
|
|
|
|
</view>
|
|
|
|
|
|
|
|
<view
|
|
|
|
class="home-hero__search"
|
|
|
|
hover-class="home-hero__search--hover"
|
|
|
|
@tap="$Router.push('/pages/public/search')"
|
|
|
|
>
|
|
|
|
<u-icon name="search" :size="28" color="#9CA3AF"></u-icon>
|
|
|
|
<text class="search-placeholder">搜索酒品 / 关键词</text>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
|
|
|
|
<view class="home-hero__tabs">
|
|
<scroll-view
|
|
class="tabs-scroll"
|
|
scroll-x
|
|
:show-scrollbar="false"
|
|
:enable-flex="true"
|
|
:scroll-with-animation="true"
|
|
>
|
|
<view class="tabs-row">
|
|
<view
|
|
v-for="(tab, index) in displayTabs"
|
|
:key="tab.key || index"
|
|
class="tab-item"
|
|
:class="{ 'tab-item--active': tabCur === index }"
|
|
@tap="onTabTap(tab, index)"
|
|
>
|
|
<text class="tab-item__text">{{ tab.name }}</text>
|
|
</view>
|
|
</view>
|
|
</scroll-view>
|
|
</view>
|
|
|
|
</view>
|
|
|
|
|
|
|
|
<view class="home-hero__banner" v-if="list && list.length">
|
|
|
|
<swiper
|
|
|
|
class="hero-swiper"
|
|
|
|
@change="onChange"
|
|
|
|
:circular="true"
|
|
|
|
:autoplay="true"
|
|
|
|
interval="5000"
|
|
|
|
duration="500"
|
|
|
|
:indicator-dots="false"
|
|
|
|
>
|
|
|
|
<swiper-item v-for="(item, index) in list" :key="index" @tap="onSwiper(index)">
|
|
|
|
<image class="hero-swiper__img" :src="item.image" mode="aspectFill"></image>
|
|
|
|
</swiper-item>
|
|
|
|
</swiper>
|
|
|
|
<view class="hero-dots" v-if="list.length > 1">
|
|
|
|
<view
|
|
|
|
v-for="(item, index) in list"
|
|
|
|
:key="index"
|
|
|
|
class="hero-dot"
|
|
|
|
:class="{ 'hero-dot--active': swiperCur === index }"
|
|
|
|
></view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
<home-notice-bar></home-notice-bar>
|
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
import homeNoticeBar from './home-notice-bar.vue';
|
|
|
|
let systemInfo = uni.getSystemInfoSync();
|
|
|
|
let menuButtonInfo = {};
|
|
|
|
// #ifdef MP-WEIXIN || MP-BAIDU || MP-TOUTIAO || MP-QQ
|
|
|
|
menuButtonInfo = uni.getMenuButtonBoundingClientRect();
|
|
|
|
// #endif
|
|
|
|
|
|
|
|
const HOME_TAB = { key: 'home', name: '首页', isHome: true };
|
|
|
|
export default {
|
|
components: {
|
|
homeNoticeBar
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
swiperCur: 0,
|
|
|
|
tabCur: 0,
|
|
|
|
categoryTabs: [],
|
|
|
|
statusBarHeight: systemInfo.statusBarHeight
|
|
|
|
};
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
list: {
|
|
|
|
type: Array,
|
|
|
|
default() {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
navTitle: {
|
|
|
|
type: String,
|
|
|
|
default: '雄戈小酒'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
capsuleHeight() {
|
|
|
|
// #ifdef MP
|
|
|
|
if (menuButtonInfo && menuButtonInfo.height) {
|
|
|
|
return menuButtonInfo.height;
|
|
|
|
}
|
|
|
|
// #endif
|
|
|
|
return 32;
|
|
|
|
},
|
|
|
|
capsuleTopGap() {
|
|
|
|
// #ifdef MP
|
|
|
|
if (menuButtonInfo && menuButtonInfo.top) {
|
|
|
|
return menuButtonInfo.top - this.statusBarHeight;
|
|
|
|
}
|
|
|
|
// #endif
|
|
|
|
return 4;
|
|
|
|
},
|
|
|
|
navCapsuleGap() {
|
|
|
|
// #ifdef MP
|
|
|
|
if (menuButtonInfo && menuButtonInfo.left) {
|
|
|
|
return systemInfo.windowWidth - menuButtonInfo.left + 8;
|
|
|
|
}
|
|
|
|
// #endif
|
|
|
|
return 16;
|
|
|
|
},
|
|
|
|
navTopStyle() {
|
|
return {
|
|
paddingTop: this.statusBarHeight + 'px',
|
|
boxSizing: 'border-box'
|
|
};
|
|
},
|
|
|
|
topRowStyle() {
|
|
return {
|
|
paddingRight: this.navCapsuleGap + 'px',
|
|
boxSizing: 'border-box'
|
|
};
|
|
},
|
|
|
|
capsuleRowStyle() {
|
|
|
|
return {
|
|
|
|
minHeight: this.capsuleHeight + 'px',
|
|
|
|
marginTop: this.capsuleTopGap + 'px'
|
|
|
|
};
|
|
|
|
},
|
|
|
|
displayTabs() {
|
|
|
|
return [HOME_TAB, ...this.categoryTabs];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.loadCategoryTabs();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
loadCategoryTabs() {
|
|
|
|
this.$http('category.info').then(res => {
|
|
|
|
if (res.code !== 1 || !res.data || !res.data.id) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
return this.$http('category.detail', { id: res.data.id });
|
|
|
|
}).then(res => {
|
|
|
|
if (res && res.code === 1 && res.data && res.data.children && res.data.children.length) {
|
|
this.categoryTabs = res.data.children.map(item => ({
|
|
key: 'cat-' + item.id,
|
|
name: item.name,
|
|
path: `/pages/goods/list?id=${item.id}`
|
|
}));
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onTabTap(tab, index) {
|
|
|
|
this.tabCur = index;
|
|
|
|
if (tab.isHome || !tab.path) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.$tools.routerTo(tab.path);
|
|
|
|
},
|
|
|
|
onSwiper(e) {
|
|
|
|
this.$tools.routerTo(this.list[e].path);
|
|
|
|
},
|
|
|
|
onChange(e) {
|
|
|
|
this.swiperCur = e.detail.current;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.home-hero {
|
|
|
|
position: relative;
|
|
|
|
z-index: 100;
|
|
|
|
padding-bottom: 8rpx;
|
|
|
|
background: $home-header-bg;
|
|
|
|
}
|
|
|
|
|
|
|
|
.home-hero__nav {
|
|
padding-bottom: 12rpx;
|
|
}
|
|
|
|
|
|
|
|
.home-hero__top {
|
|
display: flex;
|
|
flex-direction: row;
|
|
align-items: center;
|
|
width: 100%;
|
|
gap: 20rpx;
|
|
padding-left: $brand-page-gutter;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
|
|
|
|
.brand-block {
|
|
|
|
flex-shrink: 0;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: center;
|
|
|
|
max-width: 38%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.brand-title {
|
|
|
|
font-size: 34rpx;
|
|
|
|
font-weight: 700;
|
|
|
|
color: #064E3B;
|
|
|
|
line-height: 1.25;
|
|
|
|
letter-spacing: 1rpx;
|
|
|
|
}
|
|
|
|
|
|
|
|
.brand-tagline {
|
|
|
|
margin-top: 4rpx;
|
|
|
|
font-size: 20rpx;
|
|
|
|
color: #6B7280;
|
|
|
|
line-height: 1.2;
|
|
|
|
}
|
|
|
|
|
|
|
|
.home-hero__search {
|
|
|
|
flex: 1;
|
|
|
|
min-width: 0;
|
|
|
|
height: 72rpx;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
align-items: center;
|
|
|
|
padding: 0 28rpx;
|
|
|
|
background: #F9FAFB;
|
|
|
|
border: 1rpx solid $brand-border;
|
|
|
|
border-radius: 999rpx;
|
|
|
|
box-sizing: border-box;
|
|
|
|
}
|
|
|
|
|
|
|
|
.home-hero__search--hover {
|
|
|
|
background: #F3F4F6;
|
|
|
|
}
|
|
|
|
|
|
|
|
.search-placeholder {
|
|
|
|
flex: 1;
|
|
|
|
min-width: 0;
|
|
|
|
margin-left: 12rpx;
|
|
|
|
font-size: 26rpx;
|
|
|
|
color: #9CA3AF;
|
|
|
|
overflow: hidden;
|
|
|
|
white-space: nowrap;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
}
|
|
|
|
|
|
|
|
.home-hero__tabs {
|
|
margin-top: 16rpx;
|
|
width: 100%;
|
|
}
|
|
|
|
.tabs-scroll {
|
|
width: 100%;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.tabs-row {
|
|
display: inline-flex;
|
|
flex-direction: row;
|
|
flex-wrap: nowrap;
|
|
align-items: center;
|
|
padding: 0 $brand-page-gutter;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.tab-item {
|
|
flex-shrink: 0;
|
|
display: inline-flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
padding: 8rpx 24rpx 12rpx;
|
|
margin-right: 4rpx;
|
|
}
|
|
|
|
|
|
|
|
.tab-item__text {
|
|
|
|
font-size: 28rpx;
|
|
|
|
color: $brand-text-muted;
|
|
|
|
line-height: 1.2;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tab-item--active .tab-item__text {
|
|
|
|
color: $home-accent;
|
|
|
|
font-weight: 600;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tab-item--active {
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tab-item--active::after {
|
|
content: '';
|
|
position: absolute;
|
|
left: 24rpx;
|
|
right: 24rpx;
|
|
bottom: 0;
|
|
height: 4rpx;
|
|
border-radius: 4rpx;
|
|
background: $home-accent;
|
|
}
|
|
|
|
|
|
|
|
.home-hero__banner {
|
|
|
|
position: relative;
|
|
|
|
margin: 8rpx $brand-page-gutter 0;
|
|
|
|
border-radius: 20rpx;
|
|
|
|
overflow: hidden;
|
|
|
|
box-shadow: $brand-shadow;
|
|
|
|
}
|
|
|
|
|
|
|
|
.hero-swiper {
|
|
|
|
height: 320rpx;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.hero-swiper__img {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
|
|
|
|
.hero-dots {
|
|
|
|
position: absolute;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
bottom: 16rpx;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.hero-dot {
|
|
|
|
width: 10rpx;
|
|
|
|
height: 10rpx;
|
|
|
|
border-radius: 50%;
|
|
|
|
background: rgba(255, 255, 255, 0.55);
|
|
|
|
margin: 0 6rpx;
|
|
|
|
}
|
|
|
|
|
|
|
|
.hero-dot--active {
|
|
|
|
width: 24rpx;
|
|
|
|
border-radius: 6rpx;
|
|
|
|
background: #ffffff;
|
|
|
|
}
|
|
|
|
</style>
|
|
|