功能:统一账号输入校验并调整首页轮播图

This commit is contained in:
xiaowang
2026-03-26 10:53:19 +08:00
parent 764bfadb51
commit b1177c4f75
18 changed files with 294 additions and 124 deletions
+27 -79
View File
@@ -35,49 +35,31 @@
description="先逛作品和门店,收藏、加购、下单时再登录即可。"
/>
<div class="banner-container">
<div class="banner-carousel">
<a-carousel v-if="bannerImages.length" autoplay :autoplay-speed="3200" effect="fade">
<div
v-for="banner in bannerImages"
:key="banner.shopId"
class="banner-slide"
@click="openShopById(banner.shopId)"
>
<img :src="banner.url" :alt="banner.shopName" class="banner-img" />
<div class="banner-copy">
<a-tag color="blue">门店推荐</a-tag>
<h3>{{ banner.shopName }}</h3>
<p>{{ banner.businessHours || '欢迎到店体验' }}</p>
<section class="section">
<div class="banner-container">
<div class="banner-carousel">
<a-carousel v-if="bannerImages.length" autoplay :autoplay-speed="3200" effect="fade">
<div
v-for="banner in bannerImages"
:key="banner.id"
class="banner-slide"
@click="openShopById(banner.shopId)"
>
<img :src="banner.url" :alt="banner.shopName" class="banner-img" />
<div class="banner-copy">
<a-tag color="blue">门店推荐</a-tag>
<h3>{{ banner.shopName }}</h3>
<p>{{ banner.businessHours || '欢迎到店体验' }}</p>
</div>
</div>
</a-carousel>
<div v-else class="banner-empty">
<h3>发现适合你的美甲风格</h3>
<p>先看看门店 Banner 和精选作品,再决定今天预约谁。</p>
<a-button type="primary" @click="router.push('/products')">浏览作品</a-button>
</div>
</a-carousel>
<div v-else class="banner-empty">
<h3>发现适合你的美甲风格</h3>
<p>先看看热门门店和精选作品,再决定今天预约谁。</p>
<a-button type="primary" @click="router.push('/products')">浏览作品</a-button>
</div>
</div>
</div>
<section v-if="featuredShops.length" class="section">
<div class="section-header">
<h3>热门门店</h3>
<a class="see-all" @click="router.push('/products')">去看作品</a>
</div>
<div class="shop-strip">
<a-card
v-for="shop in featuredShops"
:key="shop.id"
class="shop-card"
hoverable
@click="openShop(shop)"
>
<div class="shop-card-name">{{ shop.shopName }}</div>
<div class="shop-card-address">{{ shop.address || '门店地址待完善' }}</div>
<div class="shop-card-hours">{{ shop.businessHours || '营业时间待完善' }}</div>
</a-card>
</div>
</section>
<section class="section">
@@ -158,6 +140,7 @@ import { fileApi } from '../api/file'
import { DEFAULT_AVATAR, DEFAULT_PRODUCT_IMAGE } from '@/constants'
interface BannerImage {
id: string
shopId: number
shopName: string
businessHours?: string
@@ -191,7 +174,6 @@ const pageSize = 8
const isLoggedIn = computed(() => Boolean(localStorage.getItem('accessToken') || sessionStorage.getItem('accessToken')))
const greeting = computed(() => (isLoggedIn.value ? '欢迎回来' : '游客模式'))
const displayName = computed(() => userInfo.value?.nickname || (isLoggedIn.value ? '用户' : '先看看门店和作品'))
const featuredShops = computed(() => publicShops.value.slice(0, 4))
const getRandomColor = (): string => {
const colors = ['#ffe4d6', '#d6eaff', '#e2ffd6', '#fff2d6', '#d6ffe4', '#e4d6ff']
@@ -262,12 +244,16 @@ const loadPublicShops = async () => {
const loadBannerImages = async () => {
const banners: BannerImage[] = []
for (const shop of publicShops.value) {
const coverIds = (shop as any).coverImageFileId?.split(',').map((id: string) => id.trim()).filter(Boolean) || []
const coverIds = (shop.coverImageFileId || shop.imageFileIds || '')
.split(',')
.map(id => id.trim())
.filter(Boolean)
for (const id of coverIds) {
try {
const url = await fileApi.getSignedUrl(Number(id)) as unknown as string
if (url) {
banners.push({
id: `${shop.id}-${id}`,
shopId: Number(shop.id),
shopName: shop.shopName,
businessHours: shop.businessHours,
@@ -353,10 +339,6 @@ const handleProductClick = (item: ProductCardItem) => {
router.push(`/product/${item.id}`)
}
const openShop = (shop: ShopVO) => {
router.push(`/shop/${shop.id}`)
}
const openShopById = (shopId: number) => {
router.push(`/shop/${shopId}`)
}
@@ -418,9 +400,6 @@ onUnmounted(() => {
}
.banner-container {
display: flex;
justify-content: center;
margin: 18px 0 0;
padding: 0 20px;
}
@@ -513,7 +492,6 @@ onUnmounted(() => {
font-size: 13px;
}
.shop-strip,
.horizontal-scroll {
display: flex;
gap: 14px;
@@ -522,31 +500,10 @@ onUnmounted(() => {
scrollbar-width: none;
}
.shop-strip::-webkit-scrollbar,
.horizontal-scroll::-webkit-scrollbar {
display: none;
}
.shop-card {
min-width: 220px;
border-radius: 18px;
background: linear-gradient(135deg, #fff 0%, #f7faff 100%);
}
.shop-card-name {
font-size: 16px;
font-weight: 700;
color: #1f1f1f;
}
.shop-card-address,
.shop-card-hours {
margin-top: 8px;
font-size: 13px;
color: #666;
line-height: 1.6;
}
.product-card {
width: 152px;
flex-shrink: 0;
@@ -643,15 +600,6 @@ onUnmounted(() => {
max-width: var(--frontend-content-max-width);
}
.shop-strip {
overflow: visible;
}
.shop-card {
flex: 1 1 0;
min-width: 0;
}
.horizontal-scroll {
overflow: visible;
flex-wrap: wrap;