294 lines
8.2 KiB
Vue
294 lines
8.2 KiB
Vue
<template>
|
|
<main class="page">
|
|
<van-nav-bar fixed placeholder title="首页" :border="false" />
|
|
<van-search v-model="keyword" class="fixed-search" shape="round" placeholder="搜索供应商名称或商品" />
|
|
|
|
<section class="content">
|
|
<van-swipe class="banner" :autoplay="3200" :show-indicators="false">
|
|
<van-swipe-item v-for="banner in banners" :key="banner.id">
|
|
<van-image class="banner-image" :src="banner.image" :alt="banner.alt" fit="contain" />
|
|
</van-swipe-item>
|
|
</van-swipe>
|
|
|
|
<section v-if="filteredSuppliers.length" class="list">
|
|
<article v-for="supplier in filteredSuppliers" :key="supplier.id" class="card">
|
|
<div class="icon" :style="{ backgroundColor: supplier.backgroundColor }">
|
|
<van-image :src="supplier.image" :alt="`${supplier.name}图标`" fit="cover" />
|
|
</div>
|
|
<div class="card-info">
|
|
<div class="heading">
|
|
<h2>{{ supplier.name }}</h2>
|
|
<van-tag class="head-tag" plain type="warning">官方</van-tag>
|
|
</div>
|
|
<p class="description">{{ supplier.description }}</p>
|
|
<div class="tags">
|
|
<span v-for="tag in supplier.tags" :key="tag"
|
|
:style="{ color: supplier.tagColor, backgroundColor: supplier.tagBackground }">
|
|
{{ tag }}
|
|
</span>
|
|
</div>
|
|
<div class="stats">
|
|
<span>商品数量 {{ formatCount(supplier.productCount) }}</span><i></i><span>月销 {{ formatCount(supplier.sales)
|
|
}}</span>
|
|
</div>
|
|
</div>
|
|
<van-button class="enter-supplier" round :color="supplier.buttonColor"
|
|
@click="$router.push(supplier.path)">进入店铺</van-button>
|
|
</article>
|
|
</section>
|
|
<van-empty v-else description="未找到相关供应商" />
|
|
</section>
|
|
|
|
<footer class="services">
|
|
<div v-for="service in services" :key="service.title" class="service">
|
|
<van-icon :name="service.icon" :color="service.color" :size="22" />
|
|
<span><b>{{ service.title }}</b><small>{{ service.description }}</small></span>
|
|
</div>
|
|
</footer>
|
|
</main>
|
|
</template>
|
|
|
|
<script>
|
|
import bannerWelfare from '@/assets/supplier-banner/supplier-banner-welfare.png'
|
|
import bannerQuality from '@/assets/supplier-banner/supplier-banner-quality.png'
|
|
import bannerDaily from '@/assets/supplier-banner/supplier-banner-daily.png'
|
|
import supplierJoy from '@/assets/supplier-icons/joyful-selection.png'
|
|
import supplierHome from '@/assets/supplier-icons/home-living.png'
|
|
import supplierHappy from '@/assets/supplier-icons/happy-shopping.png'
|
|
import supplierFruit from '@/assets/supplier-icons/fresh-fruit.png'
|
|
import supplierCute from '@/assets/supplier-icons/cute-selection.png'
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
keyword: '',
|
|
banners: [
|
|
{ id: 'welfare', image: bannerWelfare, alt: '优质供应商精选' },
|
|
{ id: 'quality', image: bannerQuality, alt: '品质好物精选直供' },
|
|
{ id: 'daily', image: bannerDaily, alt: '精选商品每日推荐' }
|
|
],
|
|
suppliers: [
|
|
{ id: 'joy', name: '悦享优选', image: supplierJoy, description: '精选好物,悦享品质生活', tags: ['正品保障', '极速发货', '售后无忧'], productCount: 6800, sales: '18万+', backgroundColor: '#f4f7ff', tagColor: '#4e83ef', tagBackground: '#edf3ff', buttonColor: '#ff651d', path: '/joyful-selection/home' },
|
|
{ id: 'home', name: '美家生活馆', image: supplierHome, description: '家居好物,点亮品质生活', tags: ['家居日用', '品质精选', '售后保障'], productCount: 5200, sales: '12万+', backgroundColor: '#f1fbf9', tagColor: '#18bfae', tagBackground: '#e9faf7', buttonColor: '#ff651d', path: '/home-living' },
|
|
{ id: 'happy', name: '乐购甄选', image: supplierHappy, description: '天天低价,乐享购物', tags: ['低价好物', '限时优惠', '极速配送'], productCount: 7600, sales: '22万+', backgroundColor: '#f7f4ff', tagColor: '#7b61ee', tagBackground: '#f0edff', buttonColor: '#ff651d', path: '/happy-shopping' },
|
|
{ id: 'fruit', name: '鲜果优品', image: supplierFruit, description: '新鲜直达,优选好果', tags: ['产地直采', '新鲜直达', '坏果包赔'], productCount: 3500, sales: '9万+', backgroundColor: '#fff9ed', tagColor: '#f39d16', tagBackground: '#fff5df', buttonColor: '#ff651d', path: '/fresh-fruit' },
|
|
{ id: 'cute', name: '萌趣优选', image: supplierCute, description: '萌趣好物,快乐购物', tags: ['潮流好物', '品质保障', '贴心服务'], productCount: 4500, sales: '11万+', backgroundColor: '#fff4f7', tagColor: '#f45a7d', tagBackground: '#fff0f3', buttonColor: '#ff651d', path: '/cute-selection' }
|
|
],
|
|
services: [
|
|
{ title: '正品保障', description: '品牌直供,假一赔十', icon: 'shield-o', color: '#3d78ed' },
|
|
{ title: '极速配送', description: '多仓直发,快速送达', icon: 'logistics', color: '#15b8a3' },
|
|
{ title: '售后无忧', description: '7天无理由退换货', icon: 'service-o', color: '#725cf2' }
|
|
]
|
|
}
|
|
},
|
|
computed: {
|
|
filteredSuppliers() {
|
|
const keyword = this.keyword.trim()
|
|
return keyword ? this.suppliers.filter(item => `${item.name}${item.description}${item.tags.join('')}`.includes(keyword)) : this.suppliers
|
|
}
|
|
},
|
|
methods: {
|
|
formatCount(value) {
|
|
const source = String(value).trim()
|
|
const explicitPlus = source.endsWith('+')
|
|
const numeric = Number(source.replace(/\+$/, ''))
|
|
|
|
if (!Number.isFinite(numeric) || numeric <= 1000) return source
|
|
|
|
const rounded = Math.floor(numeric / 100) / 10
|
|
const hasRemainder = numeric % 100 !== 0
|
|
return `${rounded}k${explicitPlus || hasRemainder ? '+' : ''}`
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
.page {
|
|
min-height: 100vh;
|
|
padding-bottom: 76px;
|
|
background: #fafafa;
|
|
}
|
|
|
|
.content {
|
|
padding: 64px 17px 0;
|
|
}
|
|
|
|
.fixed-search {
|
|
position: fixed;
|
|
z-index: 10;
|
|
top: 46px;
|
|
right: 0;
|
|
left: 0;
|
|
}
|
|
|
|
.banner {
|
|
overflow: hidden;
|
|
border-radius: 14px;
|
|
aspect-ratio: 1492 / 315;
|
|
}
|
|
|
|
.banner-image {
|
|
display: block;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
.list {
|
|
margin-top: 14px;
|
|
}
|
|
|
|
.card {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 14px;
|
|
margin-bottom: 13px;
|
|
padding: 14px;
|
|
border-radius: 17px;
|
|
background: #fff;
|
|
}
|
|
|
|
.icon {
|
|
width: 74px;
|
|
height: 74px;
|
|
flex: none;
|
|
overflow: hidden;
|
|
border-radius: 16px;
|
|
}
|
|
|
|
.icon ::v-deep .van-image {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
.card-info {
|
|
min-width: 0;
|
|
flex: 1;
|
|
}
|
|
|
|
.heading,
|
|
.tags,
|
|
.stats,
|
|
.service {
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
.heading {
|
|
gap: 7px;
|
|
}
|
|
|
|
.heading h2 {
|
|
min-width: 0;
|
|
overflow: hidden;
|
|
margin: 0;
|
|
color: #1c1c1c;
|
|
font-size: 16px;
|
|
line-height: 20px;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.head-tag {
|
|
flex: none;
|
|
padding: 0 4px;
|
|
font-size: 10px;
|
|
line-height: 16px;
|
|
}
|
|
|
|
.description {
|
|
overflow: hidden;
|
|
margin: 4px 0;
|
|
color: #777;
|
|
font-size: 10px;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.tags {
|
|
gap: 5px;
|
|
flex-wrap: nowrap;
|
|
overflow-x: auto;
|
|
overflow-y: hidden;
|
|
padding-bottom: 1px;
|
|
font-size: 9px;
|
|
-webkit-overflow-scrolling: touch;
|
|
scrollbar-width: none;
|
|
}
|
|
|
|
.tags::-webkit-scrollbar {
|
|
display: none;
|
|
}
|
|
|
|
.tags span {
|
|
flex: 0 0 auto;
|
|
padding: 2px 6px;
|
|
border-radius: 5px;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.stats {
|
|
gap: 5px;
|
|
min-width: 0;
|
|
margin-top: 3px;
|
|
overflow: hidden;
|
|
color: #868686;
|
|
font-size: 10px;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.stats span {
|
|
min-width: 0;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.stats i {
|
|
width: 1px;
|
|
height: 13px;
|
|
flex: none;
|
|
background: #ddd;
|
|
}
|
|
|
|
.enter-supplier {
|
|
width: 72px;
|
|
height: 24px;
|
|
flex: none;
|
|
font-size: 10px;
|
|
}
|
|
|
|
.services {
|
|
position: fixed;
|
|
right: 0;
|
|
bottom: 0;
|
|
left: 0;
|
|
display: flex;
|
|
height: 58px;
|
|
background: #fff;
|
|
border-top: 1px solid #f2f2f2;
|
|
}
|
|
|
|
.service {
|
|
flex: 1;
|
|
justify-content: center;
|
|
gap: 5px;
|
|
min-width: 0;
|
|
font-size: 10px;
|
|
}
|
|
|
|
.service span {
|
|
display: grid;
|
|
min-width: 0;
|
|
font-size: 9px;
|
|
}
|
|
|
|
.service small {
|
|
overflow: hidden;
|
|
margin: 0;
|
|
color: rgb(226, 226, 226);
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
</style>
|