<template>
	<view class="container">
		<!-- 头部搜索与导航 -->
		<view class="header">
			<view class="status-bar" :style="{ height: statusBarHeight + 'px' }"></view>
			<view class="search-section">
				<view class="search-bar-wrap" @click="goSearch">
					<text class="search-icon"></text>
					<text class="search-input" style="color: #999;">输入关键词或粘贴商品标题</text>
					<view class="search-btn-red">搜索</view>
				</view>
				<image class="search-right-ad" src="https://img.bc.haodanku.com/cms_web/1651735687" mode="aspectFit" @click="goToSaveMoney"></image>
			</view>
			<scroll-view scroll-x class="nav-scroll" :show-scrollbar="false">
				<view class="nav-item" :class="{ 'active': currentTab === index }" v-for="(item, index) in navList" :key="index" @click="switchTab(index)">
					<text class="nav-text">{{ item.name }}</text>
					<view class="nav-line" v-if="currentTab === index"></view>
				</view>
		</scroll-view>
	</view>
		<view class="main-content" :style="{ paddingTop: homeHeaderHeight + 'px' }">
			<!-- 轮播图区域 -->
			<view class="banner-box" id="top-section">
				<swiper class="swiper" circular autoplay indicator-dots indicator-color="rgba(255,255,255,0.5)" indicator-active-color="#ffffff">
					<swiper-item v-for="(img, idx) in banners" :key="idx">
						<image class="banner-img" :src="img" mode="aspectFill"></image>
					</swiper-item>
				</swiper>
			</view>

			<!-- 垂直滚动通知栏 (1:1 还原) -->
			<view class="notice-bar">
				<view class="notice-icon-box">
					<text class="notice-speaker"></text>
				</view>
				<swiper class="notice-swiper" vertical circular autoplay interval="3000">
					<swiper-item v-for="(item, idx) in noticeList" :key="idx">
						<view class="notice-item">
							<image class="notice-avatar" :src="item.img"></image>
							<text class="notice-text">{{ item.msg }}</text>
						</view>
					</swiper-item>
				</swiper>
			</view>

			<!-- 金刚区 / 导航图标 (滑动 1:1 还原) -->
			<!-- <view class="grid-menu-wrap">
				<swiper class="grid-swiper" @change="e => gridCurrent = e.detail.current">
					<swiper-item v-for="(page, pIdx) in (gridMenuPages || [])" :key="pIdx">
						<view class="grid-menu">
							<view class="grid-item" v-for="(menu, idx) in page" :key="idx">
								<image class="menu-icon" :src="menu.img"></image>
								<text class="menu-text">{{ menu.title }}</text>
								<view class="menu-tag" v-if="menu.tag">{{ menu.tag }}</view>
							</view>
						</view>
					</swiper-item>
				</swiper> -->
				<!-- 自定义指示器 -->
				<!-- <view class="grid-indicator" v-if="gridMenuPages && gridMenuPages.length > 1">
					<view class="indicator-bg">
						<view class="indicator-slider" :style="{ width: (gridMenuPages && gridMenuPages.length ? 100 / gridMenuPages.length : 100) + '%', transform: 'translateX(' + (gridCurrent * 100) + '%)' }"></view>
					</view>
				</view>
			</view> -->

			<!-- 活动专区 (胶囊形轮播图) -->
			<!-- <view class="ad-swiper-box">
				<swiper class="ad-swiper" circular autoplay indicator-dots indicator-active-color="#ff416c" indicator-color="rgba(255,255,255,0.6)">
					<swiper-item v-for="(ad, idx) in adList" :key="idx">
						<image class="ad-swiper-img" :src="ad" mode="aspectFill"></image>
					</swiper-item>
				</swiper>
			</view> -->

			<!-- 今日值得买 (1:1 还原) -->
			<view class="worth-buy-card">
				<view class="worth-header">
					<view class="worth-header-left">
						<image class="worth-icon" src="https://cdn-icons-png.flaticon.com/512/3594/3594162.png"></image>
						<text class="worth-title">今日值得买</text>
					</view>
					<view class="worth-header-right">
						<view class="avatar-list">
							<image class="avatar" v-for="(item, index) in noticeList.slice(0, 3)" :key="index" :src="item.img"></image>
							<view class="avatar-more">...</view>
						</view>
							<text class="flash-sale-count">{{ qiangNum }}人正在抢</text>
					</view>
				</view>
				<view class="worth-subtitle-tag">高性价比好物，买TA!</view>

				<view class="worth-tabs">
					<view class="worth-tab-item" :class="{ 'active': worthTabActive === 0 }" @click="worthTabActive = 0">
						<text>推荐</text>
						<view class="active-arrow" v-if="worthTabActive === 0"></view>
					</view>
					<view class="worth-tab-item" :class="{ 'active': worthTabActive === 1 }" @click="worthTabActive = 1">
						<text>9.9包邮</text>
						<view class="active-arrow" v-if="worthTabActive === 1"></view>
					</view>
					<view class="worth-tab-item" :class="{ 'active': worthTabActive === 2 }" @click="worthTabActive = 2">
						<text>19.9超值</text>
						<view class="active-arrow" v-if="worthTabActive === 2"></view>
					</view>
				</view>

				<swiper class="worth-swiper" :indicator-dots="true" indicator-active-color="#ff416c">
					<swiper-item v-for="(chunk, cIdx) in worthBuyChunks" :key="cIdx">
						<view class="worth-goods-item" v-for="(item, idx) in chunk" :key="idx" @click="goToDetail(item.id)">
							<image class="worth-goods-img" :src="item.img" mode="aspectFill"></image>
							<view class="worth-goods-info">
								<view class="worth-goods-title">
									<text :class="item.shopType === '天猫' ? 'tag-tmall' : 'tag-taobao'">{{ item.shopType }}</text>
									{{ item.title }}
								</view>
								<view class="worth-goods-labels">
									<text class="worth-label red">{{ item.label1 }}</text>
									<text class="worth-label orange" v-if="item.label2">{{ item.label2 }}</text>
								</view>
								<view class="worth-price-row">
									<view class="worth-price-left">
										<text class="worth-price-tip">券后</text>
										<text class="worth-price-symbol">￥</text>
										<text class="worth-price-val">{{ item.price }}</text>
										<text class="worth-old-price">￥{{ item.oldPrice }}</text>
									</view>
									<view class="worth-coupon-tag">券 {{ item.coupon }}元</view>
								</view>
								<view class="worth-buy-btn-group">
									<view class="worth-btn-left">今日已抢 {{ item.todaySale }} 件</view>
									<view class="worth-btn-right">马上抢 ></view>
								</view>
							</view>
						</view>
					</swiper-item>
				</swiper>
			</view>

			<!-- 品牌特卖区 (1:1 还原) -->
			<view class="brand-sale-module">
				<view class="brand-header">
					<view class="brand-header-left">
						<image class="brand-tag-icon" src="https://cdn-icons-png.flaticon.com/512/879/879796.png"></image>
						<text class="brand-title">品牌特卖</text>
						<text class="brand-subtitle-tag">跟着潮流买 限时抢好货</text>
					</view>
					<text class="brand-more" @click="goToChoiceness">更多 ></text>
				</view>

				<!-- 品牌特卖分页轮播 (以店铺为单位整体翻页) -->
				<swiper class="brand-goods-swiper" :indicator-dots="true" indicator-active-color="#ff416c">
					<swiper-item v-for="(shop, sIdx) in brandSaleShops" :key="sIdx">
						<!-- 品牌主推位 -->
						<view class="brand-highlight">
							<image class="highlight-bg" :src="shop.bg" mode="aspectFill"></image>
							<view class="highlight-content">
								<view class="brand-logo-white-box">
									<image class="brand-logo-img" :src="shop.logo" mode="aspectFit"></image>
								</view>
								<view class="brand-feature-info">
									<view class="brand-name-row">
										<text>{{ shop.name }}</text>
										<text class="arrow">></text>
									</view>
									<view class="brand-discount-text">{{ shop.desc }}</view>
									<view class="brand-promo-tags">
										<text class="p-tag" v-for="(tag, tIdx) in shop.tags" :key="tIdx">{{ tag }}</text>
									</view>
								</view>
							</view>
						</view>

						<!-- 品牌商品格子 -->
						<view class="brand-goods-grid">
							<view class="brand-grid-item" v-for="(goods, gIdx) in shop.items" :key="gIdx" @click="goToDetail(goods.id)">
								<view class="b-img-wrap">
									<view class="anniversary-tag">
										<text class="a-icon"></text>
										<text>周年庆</text>
									</view>
									<image class="b-goods-img" :src="goods.img" mode="aspectFill"></image>
									<view class="b-sold-overlay">已售{{ goods.sold }}件</view>
								</view>
								<view class="b-goods-title">{{ goods.title }}</view>
								<view class="b-promo-label">{{ goods.promo }}</view>
								<view class="b-price-row">
									<view class="b-price-blue">￥{{ goods.price }}</view>
									<view class="b-coupon-tag">券 {{ goods.coupon }}元</view>
								</view>
							</view>
						</view>
					</swiper-item>
				</swiper>
			</view>

			<!-- 平台切换选项卡 -->
			<!-- <view class="platform-tabs">
				<view class="p-tab-item" :class="{ 'active': platformActive === 0 }" @click="platformActive = 0">
					<text>淘宝</text>
					<view class="p-active-line" v-if="platformActive === 0"></view>
				</view>
				<view class="p-tab-item" :class="{ 'active': platformActive === 1 }" @click="platformActive = 1">
					<text>京东</text>
					<view class="p-active-line" v-if="platformActive === 1"></view>
				</view>
				<view class="p-tab-item" :class="{ 'active': platformActive === 2 }" @click="platformActive = 2">
					<text>拼多多</text>
					<view class="p-active-line" v-if="platformActive === 2"></view>
				</view>
				<view class="p-tab-item" :class="{ 'active': platformActive === 3 }" @click="platformActive = 3">
					<text>抖音电商</text>
					<view class="p-active-line" v-if="platformActive === 3"></view>
				</view>
			</view> -->

			<!-- 商品列表 (1:1 还原) -->
			<view class="goods-list" id="goods-list-section">
				<view class="goods-item" v-for="(goods, idx) in goodsList" :key="idx" @click="goToDetail(goods.id)">
					<view class="g-img-wrap">
						<view class="g-anniversary-tag">
							<text class="a-icon"></text>
							<text>周年庆</text>
						</view>
						<view class="g-brand-tag" v-if="goods.brandTag">{{ goods.brandTag }}</view>
						<image class="goods-img" :src="goods.image" mode="aspectFill"></image>
						<view class="g-bottom-banner" v-if="goods.bottomTag">{{ goods.bottomTag }}</view>
					</view>
					<view class="goods-info">
						<view class="goods-title">
							<text :class="goods.shopType === '天猫' ? 'tag-tmall' : 'tag-taobao'">{{ goods.shopType }}</text>
							<text class="title-text">{{ goods.title }}</text>
						</view>
						<view class="goods-lowest-price" v-if="goods.lowestTag">{{ goods.lowestTag }}</view>
						<view class="goods-price-row">
							<view class="g-price-left">
								<text class="g-price-tip">券后￥</text>
								<text class="g-price-val">{{ goods.finalPrice }}</text>
							</view>
							<view class="g-coupon-tag">券 {{ goods.couponValue }}元</view>
						</view>
						
						<view class="goods-sales">已售 {{ goods.sales }} 件</view>
					</view>
				</view>
			</view>
			
			<view class="loading-more">-- 到底啦 --</view>
		</view>

		<!-- 通用底部 Tab 栏 -->
		<bottom-nav :activeTab="0"></bottom-nav>
	</view>
</template>

<script>
	import BottomNav from '@/components/bottom-nav/bottom-nav.vue';
	import http from '@/request/request.js';

	export default {
		components: {
			BottomNav
		},
		data() {
			return {
				statusBarHeight: 44,
				activeBottomTab: 0,
				currentTab: 0,
				navList: [{ name: '首页', cat_id: 0 }, { name: '推荐', cat_id: -1 }],
				banners: [
					'https://images.unsplash.com/photo-1483985988355-763728e1935b?w=800&q=80',
					'https://images.unsplash.com/photo-1542291026-7eec264c27ff?w=800&q=80',
					'https://images.unsplash.com/photo-1607082348824-0a96f2a4b9da?w=800&q=80'
				],
				gridCurrent: 0,
				menus: [],
				noticeList: [
					// 初始兜底数据
					{ img: 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=100&q=80', msg: '正在获取最新订单信息...' }
				],
				qiangNum: 2263,
				adList: [
					'https://images.unsplash.com/photo-1607083206968-13611e3d76db?w=800&q=80',
					'https://images.unsplash.com/photo-1607082348824-0a96f2a4b9da?w=800&q=80'
				],
				worthTabActive: 0,
				deserveList: [],
				nineList: [],
				nineteenList: [],
				recommendData: {
					left: { title: '今日必抢', sub: '爆款直降', img: 'https://images.unsplash.com/photo-1542291026-7eec264c27ff?w=400&q=80' },
					topRight: { title: '百亿补贴', sub: '大牌正品', img: 'https://images.unsplash.com/photo-1523275335684-37898b6baf30?w=400&q=80' },
					bottomRight: { title: '热销榜单', sub: '闭眼入', img: 'https://images.unsplash.com/photo-1546868871-7041f2a55e12?w=400&q=80' }
				},
				brandSaleList: [
					{ logo: 'https://cdn-icons-png.flaticon.com/512/732/732229.png', image: 'https://images.unsplash.com/photo-1521572163474-6864f9cf17ab?w=400&q=80', price: '39.9', oldPrice: '99' },
					{ logo: 'https://cdn-icons-png.flaticon.com/512/882/882730.png', image: 'https://images.unsplash.com/photo-1618354691373-d851c5c3a990?w=400&q=80', price: '59.0', oldPrice: '159' },
					{ logo: 'https://cdn-icons-png.flaticon.com/512/732/732244.png', image: 'https://images.unsplash.com/photo-1583743814966-8936f5b7be1a?w=400&q=80', price: '89.0', oldPrice: '299' },
					{ logo: 'https://cdn-icons-png.flaticon.com/512/732/732221.png', image: 'https://images.unsplash.com/photo-1511556532299-8f662fc26c06?w=400&q=80', price: '129', oldPrice: '499' }
				],
				brandSaleShops: [],
				platformActive: 0,
				goodsList: []
			}
		},
		onLoad() {
			this.initializePage();
		},
		mounted() {
			if (this.__taokeInitialized) return;
			this.__taokeInitialized = true;
			this.initializePage();
		},
		onPullDownRefresh() {
			this.getIndexData();
			this.getCategoryList();
			this.getNoticeList();
			this.getGoodsList();
			this.getWorthBuyLists();
			this.getBrandSaleList();
			setTimeout(() => {
				uni.stopPullDownRefresh();
			}, 600);
		},
		computed: {
			homeHeaderHeight() {
				return this.statusBarHeight + 100;
			},
			gridMenuPages() {
				const pages = [];
				if (!this.menus || this.menus.length === 0) return pages;
				for (let i = 0; i < this.menus.length; i += 10) {
					pages.push(this.menus.slice(i, i + 10));
				}
				return pages;
			},
			worthBuyGoods() {
				if (this.worthTabActive === 0) return this.deserveList;
				if (this.worthTabActive === 1) return this.nineList;
				if (this.worthTabActive === 2) return this.nineteenList;
				return [];
			},
			// 将商品按 2 个一组进行切分
			worthBuyChunks() {
				let chunks = [];
				for (let i = 0; i < this.worthBuyGoods.length; i += 2) {
					chunks.push(this.worthBuyGoods.slice(i, i + 2));
				}
				return chunks;
			}
		},
		methods: {
			initializePage() {
				if (this.__pageInitialized) return;
				this.__pageInitialized = true;
				const sysInfo = uni.getSystemInfoSync();
				this.statusBarHeight = sysInfo.statusBarHeight || 44;
				this.getIndexData();
				this.getCategoryList();
				this.getNoticeList();
				this.getGoodsList();
				this.getWorthBuyLists();
				this.getBrandSaleList();
			},
			goSearch() {
				uni.navigateTo({
					url: '/pages/search/search'
				});
			},
			getIndexData() {
				http.get('https://api.cmspro.haodanku.com/index/index?cid=YsWZ21tx').then(res => {
					const d = res.data;
							if (Array.isArray(d.navs)) {
								this.menus = d.navs;
							}
							// 顶部轮播图
							if (Array.isArray(d.banners) && d.banners.length > 0) {
								this.banners = d.banners.map(b => b.img).filter(Boolean);
							}
							// 活动专区（胶囊形轮播图）
							if (Array.isArray(d.tile_long) && d.tile_long.length > 0) {
								this.adList = d.tile_long.map(t => t.img).filter(Boolean);
							}
				}).catch(err => {
					console.error('获取首页数据失败:', err.message);
				});
			},
			goToDetail(id) {
				console.log('正在跳转到详情页，商品ID:', id);
				uni.navigateTo({
					url: `/pages/detail/detail?id=${id}`
					// url: `/pages/activity/activity`
				});
			},

			getCategoryList() {
				http.get('https://api.cmspro.haodanku.com/index/category?cid=YsWZ21tx').then(res => {
					if (res.data.category) {
						this.navList = [{ name: '首页', cat_id: 0 }, { name: '推荐', cat_id: -1 }, ...res.data.category];
					}
				}).catch(err => {
					console.error('获取分类失败:', err.message);
				});
			},
			getNoticeList() {
				http.get('https://api.cmspro.haodanku.com/msg/getMsgs?cid=YsWZ21tx').then(res => {
					this.noticeList = res.data.msgs;
					if (res.data.num) {
						this.qiangNum = res.data.num;
					}
				}).catch(err => {
					console.error('获取通知失败:', err.message);
				});
			},
			getGoodsList() {
				http.get('https://api.cmspro.haodanku.com/recommend/getRecommend?page_size=200&page=1&type=2&cid=YsWZ21tx').then(res => {
					const list = res.data.recommends.map(item => {
								// 格式化销量
								let salesStr = item.itemsale;
								if (item.itemsale >= 10000) {
									salesStr = (item.itemsale / 10000).toFixed(1) + '万';
								}
								
								return {
									id: item.id,
									image: item.itempic,
									title: item.itemshorttitle,
									finalPrice: item.itemendprice,
									couponValue: item.couponmoney,
									sales: salesStr,
									brandTag: item.brand_name,
									lowestTag: item.label && item.label.length > 0 ? item.label[0] : '',
									shopType: item.shoptype === 'B' ? '天猫' : '淘宝',
									tkmoney: item.tkmoney
								};
							});
						this.goodsList = list;
					}).catch(err => {
						console.error('获取商品列表失败:', err.message);
					});
			},
			getWorthBuyLists() {
				http.get('https://api.cmspro.haodanku.com/index/deserveLists?cid=YsWZ21tx').then(res => {
					const formatData = (list) => {
								return list.map(item => ({
									id: item.id,
									img: item.itempic,
									title: item.itemshorttitle,
									label1: item.label && item.label[0] ? item.label[0] : '',
									label2: item.label && item.label[1] ? item.label[1] : '',
									price: item.itemendprice,
									oldPrice: item.itemprice,
									coupon: item.couponmoney,
									todaySale: item.todaysale >= 10000 ? (item.todaysale / 10000).toFixed(1) + '万' : item.todaysale,
									sold: item.itemsale >= 10000 ? (item.itemsale / 10000).toFixed(1) + '万' : item.itemsale,
									shopType: item.shoptype === 'B' ? '天猫' : '淘宝'
								}));
							};
						this.deserveList = formatData(res.data.deserve_lists);
						this.nineList = formatData(res.data.nine_lists);
						this.nineteenList = formatData(res.data.nineteen_lists);
					}).catch(err => {
						console.error('获取值得买列表失败:', err.message);
					});
			},
			getBrandSaleList() {
				http.get('https://api.cmspro.haodanku.com/brandItem/choiceness?cid=YsWZ21tx').then(res => {
					if (res.data.brand_prefecture) {
						this.brandSaleShops = res.data.brand_prefecture.map(shop => ({
								bg: shop.backimage || 'https://images.unsplash.com/photo-1556228720-195a672e8a03?w=800&q=80',
								logo: shop.brand_logo || 'https://images.unsplash.com/photo-1560155016-bd4879ae8f21?w=200&q=80',
								name: shop.fq_brand_name || '大牌特卖',
								desc: shop.title || '官方直降 爆款秒杀',
								tags: shop.label ? shop.label.slice(0, 2) : ['抢限量大额券', '霸榜天猫3大榜单'],
								items: (shop.items || []).slice(0, 3).map(goods => ({
									id: goods.id,
									img: goods.itempic,
									title: goods.itemshorttitle,
									sold: goods.itemsale >= 10000 ? (goods.itemsale / 10000).toFixed(1) + '万' : goods.itemsale,
									promo: goods.couponmoney ? '领' + goods.couponmoney + '元券' : '官方直降',
									price: goods.itemendprice,
									coupon: goods.couponmoney
								}))
						}));
					}
				}).catch(err => {
					console.error('获取品牌特卖失败:', err.message);
				});
			},
			switchTab(index) {
				const tab = this.navList[index];
				const catId = tab.cat_id;
				const tabName = tab.name;

				if (catId > 0) {
					// 跳转到独立的分类商品列表页
					uni.navigateTo({
						url: `/pages/category/category?cat_id=${catId}`
					});
					return;
				}

				this.currentTab = index;
				uni.pageScrollTo({
					selector: tabName === '推荐' ? '#goods-list-section' : '#top-section',
					duration: 300
				});
			},
			goToChoiceness() {
				console.log('触发品牌特卖更多跳转');
				uni.navigateTo({
					url: '/pages/special-sale/choicen'
				});
			},
			goToSaveMoney() {
				uni.navigateTo({
					url: '/pages/save-money/save-money'
				});
			}
		}
	}
</script>

<style scoped>
	.container {
		background-color: #f5f6f8;
	}

	/* 头部区域 */
	.header {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		background: #ffffff;
		padding-bottom: 10rpx;
		z-index: 100;
	}

	.status-bar {
		width: 100%;
	}

	.placeholder-style {
		color: #999;
	}

	/* 搜索区域 (1:1 还原) */
	.search-section {
		display: flex;
		align-items: center;
		padding: 20rpx 30rpx;
		justify-content: space-between;
	}

	.search-bar-wrap {
		flex: 1;
		height: 72rpx;
		background: #ffffff;
		border: 2rpx solid #ff416c;
		border-radius: 36rpx;
		display: flex;
		align-items: center;
		padding-left: 30rpx;
		padding-right: 4rpx; /* 为内部按钮留出微小边距 */
		position: relative;
	}

	.search-icon {
		font-size: 30rpx;
		color: #ff416c;
		margin-right: 16rpx;
	}

	.search-input {
		flex: 1;
		font-size: 26rpx;
		color: #333;
	}

	.search-btn-red {
		width: 130rpx;
		height: 64rpx;
		background: linear-gradient(to right, #ff715a, #ff416c);
		color: #ffffff;
		font-size: 28rpx;
		font-weight: bold;
		border-radius: 32rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.search-right-ad {
		width: 100rpx;
		height: 80rpx;
		margin-left: 20rpx;
	}

	.nav-scroll {
		white-space: nowrap;
		padding: 0 20rpx;
	}

	.nav-item {
		display: inline-block;
		padding: 10rpx 30rpx;
		position: relative;
	}

	.nav-text {
		font-size: 30rpx;
		color: #333;
		transition: all 0.3s;
	}

	.nav-item.active .nav-text {
		color: #ff416c;
		font-size: 34rpx;
		font-weight: bold;
	}

	.nav-line {
		position: absolute;
		bottom: 0;
		left: 50%;
		transform: translateX(-50%);
		width: 40rpx;
		height: 6rpx;
		background-color: #ff416c;
		border-radius: 6rpx;
	}

	/* 主体滚动区域 */
	.main-content {
		min-height: 100vh;
	}

	/* 轮播图 */
	.banner-box {
		padding: 0 30rpx 10rpx;
	}

	.swiper {
		height: 320rpx;
		border-radius: 24rpx;
		overflow: hidden;
		box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.05);
	}

	.banner-img {
		width: 100%;
		height: 100%;
	}

	/* 修改主轮播指示器 */
	.swiper :deep(.uni-swiper-dot) {
		width: 12rpx;
		height: 12rpx;
		background: rgba(255, 255, 255, 0.8) !important;
	}

	.swiper :deep(.uni-swiper-dot-active) {
		width: 30rpx;
		height: 12rpx;
		border-radius: 6rpx;
		background: #ff416c !important;
	}

	/* 垂直通知栏 */
	.notice-bar {
		margin: 0 30rpx 16rpx;
		background-color: #fff0f3;
		height: 64rpx;
		border-radius: 32rpx;
		display: flex;
		align-items: center;
		padding: 0 24rpx;
	}

	.notice-icon-box {
		margin-right: 16rpx;
		display: flex;
		align-items: center;
	}

	.notice-speaker {
		font-size: 28rpx;
		color: #ff416c;
	}

	.notice-swiper {
		flex: 1;
		height: 100%;
	}

	.notice-item {
		height: 100%;
		display: flex;
		align-items: center;
	}

	.notice-avatar {
		width: 40rpx;
		height: 40rpx;
		border-radius: 50%;
		margin-right: 12rpx;
	}

	.notice-text {
		font-size: 24rpx;
		color: #ff416c;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	/* 金刚区 */
	.grid-menu-wrap {
		background: #ffffff;
		margin-bottom: 20rpx;
		padding-bottom: 16rpx;
	}

	.grid-swiper {
		height: 340rpx;
	}

	.grid-menu {
		display: flex;
		flex-wrap: wrap;
		padding: 20rpx 0 0;
	}

	.grid-item {
		width: 20%;
		display: flex;
		flex-direction: column;
		align-items: center;
		margin-bottom: 24rpx;
		position: relative;
	}

	.menu-icon {
		width: 88rpx;
		height: 88rpx;
		margin-bottom: 12rpx;
	}

	.menu-text {
		font-size: 24rpx;
		color: #333;
	}

	.menu-tag {
		position: absolute;
		top: -10rpx;
		right: 4rpx;
		background: linear-gradient(to right, #ff715a, #ff416c);
		color: #fff;
		font-size: 16rpx;
		padding: 2rpx 8rpx;
		border-radius: 16rpx;
		border-bottom-left-radius: 0;
		white-space: nowrap;
		transform: scale(0.9);
	}

	.grid-indicator {
		display: flex;
		justify-content: center;
		margin-top: 4rpx;
	}

	.indicator-bg {
		width: 60rpx;
		height: 8rpx;
		background: #eeeeee;
		border-radius: 4rpx;
		position: relative;
		overflow: hidden;
	}

	.indicator-slider {
		position: absolute;
		left: 0;
		top: 0;
		height: 100%;
		background: #ff416c;
		border-radius: 4rpx;
		transition: transform 0.3s ease;
	}

	.ad-img {
		width: 100%;
		height: 100%;
	}

	/* 活动专区 - 胶囊轮播图 */
	.ad-swiper-box {
		margin: 0 30rpx 16rpx;
	}

	.ad-swiper {
		height: 180rpx;
		border-radius: 90rpx; /* 高度的一半，形成胶囊形状 */
		overflow: hidden;
		/* 强制子元素继承圆角 */
		transform: translateY(0);
		-webkit-mask-image: -webkit-radial-gradient(white, black);
	}

	.ad-swiper-img {
		width: 100%;
		height: 100%;
		border-radius: 90rpx;
	}

	/* 修改 swiper 指示点样式 */
	.ad-swiper :deep(.uni-swiper-dot) {
		width: 12rpx;
		height: 6rpx;
		border-radius: 4rpx;
	}

	.ad-swiper :deep(.uni-swiper-dot-active) {
		width: 30rpx;
		border-radius: 4rpx;
	}

	/* 今日值得买 (1:1 还原) */
	.worth-buy-card {
		background-color: #ffffff;
		margin: 0 30rpx 16rpx;
		border-radius: 24rpx;
		padding: 24rpx 24rpx 10rpx;
		box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.03);
	}

	.worth-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 12rpx;
	}

	.worth-header-left {
		display: flex;
		align-items: center;
	}

	.worth-icon {
		width: 36rpx;
		height: 36rpx;
		margin-right: 12rpx;
	}

	.worth-title {
		font-size: 34rpx;
		font-weight: bold;
		color: #333;
	}

	.worth-header-right {
		display: flex;
		align-items: center;
	}

	.avatar-list {
		display: flex;
		margin-right: 12rpx;
	}

	.avatar {
		width: 40rpx;
		height: 40rpx;
		border-radius: 50%;
		border: 2rpx solid #fff;
		margin-right: -12rpx;
	}

	.avatar-more {
		width: 40rpx;
		height: 40rpx;
		border-radius: 50%;
		background: #666;
		color: #fff;
		font-size: 16rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border: 2rpx solid #fff;
	}

	.flash-sale-count {
		font-size: 24rpx;
		color: #ff416c;
	}

	.worth-subtitle-tag {
		display: inline-block;
		background-color: #f2f2f2;
		color: #999;
		font-size: 22rpx;
		padding: 4rpx 16rpx;
		border-radius: 8rpx;
		margin-bottom: 24rpx;
	}

	.worth-tabs {
		display: flex;
		background-color: #f7f7f7;
		border-radius: 12rpx;
		height: 80rpx;
		margin-bottom: 24rpx;
		overflow: visible;
	}

	.worth-tab-item {
		flex: 1;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 28rpx;
		color: #666;
		position: relative;
	}

	.worth-tab-item.active {
		background: linear-gradient(to right, #ff715a, #ff416c);
		color: #fff;
		border-radius: 12rpx;
		font-weight: bold;
	}

	.active-arrow {
		position: absolute;
		bottom: -12rpx;
		left: 50%;
		transform: translateX(-50%);
		width: 0;
		height: 0;
		border-left: 12rpx solid transparent;
		border-right: 12rpx solid transparent;
		border-top: 12rpx solid #ff416c;
	}

	.worth-swiper {
		height: 700rpx; /* 进一步压缩高度，消除底部留白 */
	}

	.worth-swiper :deep(.uni-swiper-dots) {
		bottom: 0rpx !important; /* 使指示点更贴近底部 */
	}

	.worth-goods-item {
		display: flex;
		padding: 20rpx 0;
		border-bottom: 1rpx solid #f2f2f2;
	}

	.worth-goods-item:last-child {
		border-bottom: none;
	}

	.worth-goods-img {
		width: 240rpx;
		height: 240rpx;
		border-radius: 16rpx;
		margin-right: 20rpx;
		background-color: #f9f9f9;
	}

	.worth-goods-info {
		flex: 1;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}

	.worth-goods-title {
		font-size: 28rpx;
		color: #333;
		line-height: 40rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}

	.worth-goods-labels {
		margin-top: 8rpx;
		display: flex;
		flex-wrap: nowrap;
		overflow: hidden;
	}

	.worth-label {
		font-size: 18rpx;
		padding: 2rpx 10rpx;
		border-radius: 6rpx;
		margin-right: 12rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		flex-shrink: 1;
	}

	.worth-label.red {
		color: #ff416c;
		border: 1rpx solid #ff416c;
	}

	.worth-label.orange {
		color: #ff715a;
		border: 1rpx solid #ff715a;
	}

	.worth-price-row {
		display: flex;
		justify-content: space-between;
		align-items: baseline;
		margin-top: 12rpx;
	}

	.worth-price-tip {
		font-size: 24rpx;
		color: #ff416c;
		margin-right: 4rpx;
	}

	.worth-price-symbol {
		font-size: 24rpx;
		color: #ff416c;
		font-weight: bold;
	}

	.worth-price-val {
		font-size: 40rpx;
		color: #ff416c;
		font-weight: bold;
		margin-right: 12rpx;
	}

	.worth-old-price {
		font-size: 22rpx;
		color: #999;
		text-decoration: line-through;
	}

	.worth-coupon-tag {
		background-color: #ff416c;
		color: #fff;
		font-size: 22rpx;
		padding: 4rpx 12rpx;
		border-radius: 4rpx;
		position: relative;
	}

	.worth-buy-btn-group {
		display: flex;
		height: 64rpx;
		margin-top: 16rpx;
		border-radius: 32rpx;
		overflow: hidden;
	}

	.worth-btn-left {
		flex: 1.2;
		background: #fff3d6;
		color: #8b572a;
		font-size: 24rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.worth-btn-right {
		flex: 1;
		background: linear-gradient(to right, #ff715a, #ff416c);
		color: #fff;
		font-size: 26rpx;
		font-weight: bold;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	/* 推荐页面 */
	.recommend-zone {
		display: flex;
		margin: 0 30rpx 20rpx;
		height: 320rpx;
		justify-content: space-between;
	}

	.recommend-left {
		width: 48%;
		background: linear-gradient(135deg, #fff0f0, #ffe4e4);
		border-radius: 20rpx;
		padding: 20rpx;
		position: relative;
	}

	.recommend-right {
		width: 48%;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}

	.rec-box {
		height: 47%;
		background: #ffffff;
		border-radius: 20rpx;
		padding: 16rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.rec-title {
		font-size: 30rpx;
		font-weight: bold;
		color: #333;
		margin-bottom: 6rpx;
	}

	.rec-sub {
		font-size: 22rpx;
		color: #ff4b2b;
		background: rgba(255, 75, 43, 0.1);
		padding: 2rpx 10rpx;
		border-radius: 10rpx;
		display: inline-block;
	}

	.rec-img-large {
		width: 180rpx;
		height: 180rpx;
		position: absolute;
		bottom: 10rpx;
		right: 10rpx;
	}

	.rec-text-wrap {
		flex: 1;
	}

	.rec-img-small {
		width: 100rpx;
		height: 100rpx;
	}

	/* 品牌特卖区 */
	.brand-zone {
		margin: 0 30rpx 20rpx;
		background: #ffffff;
		border-radius: 20rpx;
		padding: 20rpx;
	}

	.zone-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 20rpx;
	}

	.zone-title {
		font-size: 32rpx;
		font-weight: bold;
		color: #333;
	}

	.zone-more {
		font-size: 24rpx;
		color: #999;
	}

	.brand-scroll {
		white-space: nowrap;
	}

	.brand-item {
		display: inline-block;
		width: 180rpx;
		margin-right: 20rpx;
		text-align: center;
	}

	.brand-logo {
		width: 80rpx;
		height: 40rpx;
		margin-bottom: 10rpx;
		display: block;
		margin-left: auto;
		margin-right: auto;
	}

	.brand-goods-img {
		width: 180rpx;
		height: 180rpx;
		border-radius: 12rpx;
		background-color: #f5f5f5;
	}

	.brand-price {
		color: #ff416c;
		font-size: 28rpx;
		font-weight: bold;
		margin-top: 10rpx;
	}

	.brand-old-price {
		color: #999;
		font-size: 20rpx;
		text-decoration: line-through;
	}

	/* 品牌特卖区 (1:1 还原) */
	.brand-sale-module {
		margin: 0 30rpx 16rpx;
		background: #ffffff;
		border-radius: 24rpx;
		padding: 24rpx 24rpx 10rpx;
		box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.03);
	}

	.brand-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 24rpx;
	}

	.brand-header-left {
		display: flex;
		align-items: center;
	}

	.brand-tag-icon {
		width: 32rpx;
		height: 32rpx;
		margin-right: 12rpx;
	}

	.brand-title {
		font-size: 34rpx;
		font-weight: bold;
		color: #333;
		margin-right: 16rpx;
	}

	.brand-subtitle-tag {
		background-color: #f2f2f2;
		color: #999;
		font-size: 22rpx;
		padding: 4rpx 12rpx;
		border-radius: 6rpx;
	}

	.brand-more {
		font-size: 26rpx;
		color: #999;
	}

	.brand-highlight {
		height: 180rpx;
		position: relative;
		border-radius: 20rpx;
		overflow: hidden;
		margin-bottom: 20rpx;
	}

	.highlight-bg {
		width: 100%;
		height: 100%;
		filter: brightness(0.9);
	}

	.highlight-content {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		display: flex;
		align-items: center;
		padding: 0 30rpx;
		background: rgba(0,0,0,0.1);
	}

	.brand-logo-white-box {
		width: 130rpx;
		height: 130rpx;
		background: #ffffff;
		border-radius: 16rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-right: 24rpx;
		box-shadow: 0 4rpx 10rpx rgba(0,0,0,0.1);
	}

	.brand-logo-img {
		width: 100rpx;
		height: 100rpx;
	}

	.brand-feature-info {
		flex: 1;
	}

	.brand-name-row {
		color: rgba(255, 255, 255, 0.9);
		font-size: 24rpx;
		display: flex;
		align-items: center;
		margin-bottom: 8rpx;
	}

	.brand-name-row .arrow {
		margin-left: 8rpx;
		font-size: 22rpx;
	}

	.brand-discount-text {
		color: #fff;
		font-size: 32rpx;
		margin-bottom: 14rpx;
		font-weight: bold;
	}

	.brand-promo-tags {
		display: flex;
	}

	.p-tag {
		background: rgba(0, 0, 0, 0.25);
		color: #fff;
		font-size: 20rpx;
		padding: 4rpx 16rpx;
		border-radius: 20rpx;
		margin-right: 12rpx;
	}

	.brand-goods-swiper {
		height: 700rpx;
	}

	.brand-goods-grid {
		display: flex;
		justify-content: space-between;
	}

	.brand-grid-item {
		width: 31%;
	}

	.b-img-wrap {
		position: relative;
		width: 100%;
		height: 210rpx;
		border-radius: 12rpx;
		overflow: hidden;
		background-color: #f9f9f9;
		margin-bottom: 12rpx;
	}

	.anniversary-tag {
		position: absolute;
		top: 0;
		left: 0;
		background: linear-gradient(to right, #ff715a, #ff416c);
		color: #fff;
		font-size: 18rpx;
		padding: 4rpx 10rpx;
		border-bottom-right-radius: 12rpx;
		display: flex;
		align-items: center;
		z-index: 1;
	}

	.a-icon {
		font-size: 16rpx;
		margin-right: 4rpx;
	}

	.b-goods-img {
		width: 100%;
		height: 100%;
	}

	.b-sold-overlay {
		position: absolute;
		bottom: 0;
		left: 0;
		width: 100%;
		background: rgba(0,0,0,0.4);
		color: #fff;
		font-size: 20rpx;
		text-align: center;
		padding: 4rpx 0;
	}

	.b-goods-title {
		font-size: 24rpx;
		color: #333;
		line-height: 32rpx;
		height: 64rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		margin-bottom: 8rpx;
	}

	.b-promo-label {
		font-size: 20rpx;
		color: #4a4aff;
		border: 1rpx solid #4a4aff;
		padding: 0 8rpx;
		border-radius: 4rpx;
		display: inline-block;
		margin-bottom: 12rpx;
	}

	.b-price-row {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.b-price-blue {
		color: #4a4aff;
		font-size: 32rpx;
		font-weight: bold;
	}

	.b-coupon-tag {
		background: #ff416c;
		color: #fff;
		font-size: 18rpx;
		padding: 2rpx 8rpx;
		border-radius: 4rpx;
	}

	/* 平台切换选项卡 */
	.platform-tabs {
		display: flex;
		padding: 20rpx 40rpx;
		background-color: #f5f6f8;
	}

	.p-tab-item {
		flex: 1;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		position: relative;
	}

	.p-tab-item text {
		font-size: 32rpx;
		color: #333;
		font-weight: 500;
		transition: all 0.3s;
	}

	.p-tab-item.active text {
		color: #ff416c;
		font-weight: bold;
		font-size: 34rpx;
	}

	.p-active-line {
		width: 40rpx;
		height: 4rpx;
		background-color: #ff416c;
		border-radius: 4rpx;
		margin-top: 8rpx;
	}

	/* 商品列表 (1:1 还原) */
	.goods-list {
		display: flex;
		flex-wrap: wrap;
		padding: 10rpx 24rpx;
		justify-content: space-between;
	}

	.goods-item {
		width: calc(50% - 12rpx);
		background: #ffffff;
		border-radius: 20rpx;
		overflow: hidden;
		margin-bottom: 24rpx;
		box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.03);
	}

	.g-img-wrap {
		position: relative;
		width: 100%;
		height: 340rpx;
		background-color: #f9f9f9;
	}

	.g-anniversary-tag {
		position: absolute;
		top: 0;
		left: 0;
		background: linear-gradient(to right, #ff715a, #ff416c);
		color: #fff;
		font-size: 18rpx;
		padding: 4rpx 10rpx;
		border-bottom-right-radius: 12rpx;
		display: flex;
		align-items: center;
		z-index: 2;
	}

	.g-brand-tag {
		position: absolute;
		top: 0;
		right: 0;
		background: rgba(138, 93, 255, 0.8);
		color: #fff;
		font-size: 20rpx;
		padding: 4rpx 12rpx;
		border-bottom-left-radius: 12rpx;
		z-index: 2;
	}

	.g-bottom-banner {
		position: absolute;
		bottom: 0;
		left: 0;
		width: 100%;
		background: rgba(0, 200, 83, 0.9);
		color: #fff;
		font-size: 18rpx;
		padding: 6rpx 0;
		text-align: center;
		z-index: 2;
	}

	.goods-img {
		width: 100%;
		height: 100%;
	}

	.goods-info {
		padding: 20rpx 16rpx;
	}

	.goods-title {
		font-size: 28rpx;
		color: #333;
		line-height: 40rpx;
		height: 80rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		margin-bottom: 12rpx;
	}

	.tag-tmall, .tag-taobao {
		color: #fff;
		font-size: 20rpx;
		padding: 2rpx 8rpx;
		border-radius: 6rpx;
		margin-right: 8rpx;
		display: inline-block;
		vertical-align: middle;
	}

	.tag-tmall {
		background-color: #ff0036;
	}

	.tag-taobao {
		background-color: #ff5000;
	}

	.goods-lowest-tag {
		display: inline-block;
		border: 1rpx solid #ff416c;
		color: #ff416c;
		font-size: 20rpx;
		padding: 0 12rpx;
		border-radius: 20rpx;
		margin-bottom: 16rpx;
		opacity: 0.8;
	}

	/* 修正最低价标签样式 */
	.goods-lowest-price {
		display: inline-block;
		border: 1rpx solid #ffcdd2;
		color: #ff416c;
		font-size: 22rpx;
		padding: 2rpx 16rpx;
		border-radius: 20rpx;
		margin-bottom: 16rpx;
		background: #fff5f5;
	}

	.goods-price-row {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 12rpx;
	}

	.g-price-tip {
		font-size: 24rpx;
		color: #ff416c;
	}

	.g-price-val {
		font-size: 38rpx;
		color: #ff416c;
		font-weight: bold;
	}

	.g-coupon-tag {
		border: 1rpx solid #ff416c;
		color: #ff416c;
		font-size: 20rpx;
		padding: 0 8rpx;
		border-radius: 4rpx;
	}

	.price-coupon {
		display: flex;
		align-items: baseline;
		margin-top: 4rpx;
	}

	.coupon-tip {
		font-size: 22rpx;
		color: #ff8a00;
	}

	.coupon-val {
		font-size: 28rpx;
		color: #ff8a00;
		font-weight: bold;
	}

	.goods-sales {
		font-size: 24rpx;
		color: #999;
	}

	.loading-more {
		text-align: center;
		color: #999;
		font-size: 24rpx;
		padding: 30rpx 0 calc(120rpx + env(safe-area-inset-bottom));
	}

	/* 底部 Tab 栏 */
	.bottom-tab-bar {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		z-index: 999;
		display: flex;
		justify-content: space-around;
		align-items: center;
		height: 100rpx;
		background-color: #ffffff;
		border-top: 1rpx solid #eeeeee;
		padding-bottom: env(safe-area-inset-bottom);
	}

	.bottom-tab-bar .tab-item {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		flex: 1;
	}

	.bottom-tab-bar .tab-icon {
		width: 44rpx;
		height: 44rpx;
		margin-bottom: 6rpx;
	}

	.bottom-tab-bar .tab-text {
		font-size: 20rpx;
	}
</style>
