<template>
	<view class="center">
		<view class="top">
			<image class="top-bg" src="../../static/img/top-bg.png" mode=""></image>
			<view class="top-main flex">
				<view class="search-box flex" @click="clickSearch()">
					<image class="search" src="../../static/img/search.png" mode=""></image>
					<view class="search-font">输入关键词搜索</view>
				</view>
			</view>
		</view>
		<swiper class="carousel" autoplay="true" duration="400" interval="5000" @change="swiperChange">
			<swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item" @click="bannerNavToUrl(item)"><image :src="item.pic" /></swiper-item>
		</swiper>
		<view class="navbar flex">
			<view class="navbar-item" @click="nav('/pages/product/classify')">
				<image class="nitem-image" src="../../static/img/autotrophy.png" mode=""></image>
				<view class="nitem-font">趣豆自营</view>
			</view>
			<view class="navbar-item" @click="nav('/pages/product/classify')">
				<image class="nitem-image" src="../../static/img/integral.png" mode=""></image>
				<view class="nitem-font">积分商城</view>
			</view>
			<view class="navbar-item" @click="nav('/pages/product/classify')">
				<image class="nitem-image" src="../../static/img/replacement.png" mode=""></image>
				<view class="nitem-font">置换商城</view>
			</view>
			<view class="navbar-item" @click="nav('/pages/product/classify')">
				<image class="nitem-image" src="../../static/img/Hang.png" mode=""></image>
				<view class="nitem-font">挂售商城</view>
			</view>
			<view class="navbar-item" @click="nav('/pages/hall/hall')">
				<image class="nitem-image" src="../../static/img/offline.png" mode=""></image>
				<view class="nitem-font">线下会馆</view>
			</view>
		</view>
		<view class="product"><image class="product-image" src="../../static/img/index-product.png" mode=""></image></view>
		<view class="shingle">
			<view class="shingle-top flex">
				<view class="shingle-title">艺术品挂牌交易区</view>
				<view class="shingle-btn" @click="nav('/pages/hall/hall')">
					查看更多趣豆会馆
					<text>></text>
				</view>
			</view>
			<view class="shingle-main" @click="nav('/pages/hall/halllist')">
				<view class="shingle-bg"><image src="../../static/img/sim-bg.png" mode=""></image></view>
				<view class="shinglem-title flex">
					<image class="address" src="../../static/img/address.png" mode=""></image>
					<view class="shingle-font">浙江馆</view>
				</view>
				<view class="shingle-mmain flex">
					<view class="smmain-item">
						<view class="smitem-top">开放中</view>
						<view class="smitem-bottom">状态</view>
					</view>
					<view class="shu"></view>
					<view class="smmain-item">
						<view class="smitem-top">纯平</view>
						<view class="smitem-bottom">馆长</view>
					</view>
					<view class="shu"></view>
					<view class="smmain-item">
						<view class="people flex">
							<view class="peopleitem" v-for="item in 1"><image src="../../static/img/busy.png" mode=""></image></view>
							<view class="peopleitem" v-for="item in 4"><image src="../../static/img/leisure.png" mode=""></image></view>
						</view>
						<view class="smitem-bottom">流畅</view>
					</view>
				</view>
				<image class="right-bottom" src="../../static/img/right-bottom.png" mode=""></image>
			</view>
		</view>
		<view class="good-title" v-if="dataList.length > 0"><image src="../../static/img/goodtitle.png" mode=""></image></view>
		<view class="main" v-if="dataList.length > 0">
			<view class="list-box-h">
				<view v-for="(item, index) in dataList" :key="index" class="guess-item" @click="navToDetailPage(item)">
					<image :src="item.image"></image>
					<view class="guess-box">
						<view class="title clamp2">{{ item.store_name }}</view>
						<view class="price-box flex">
							<view class="yuanprice">{{ item.ot_price }}</view>
							<image src="../../static/img/jiantou.png" mode=""></image>
							<view class="jiang">直降{{ (item.ot_price - item.price).toFixed(2) }}元</view>
						</view>
						<view class="price" v-if="item.integral != 0">￥{{ item.price }} + {{ item.integral }}消费补贴券</view>
						<view class="price" v-else>￥{{ item.price }}</view>
						<view class="btn">立即购买</view>
					</view>
				</view>
			</view>
		</view>
		<u-tabbar activeColor="#375AFE" v-model="current" :list="tabbar" :mid-button="true"></u-tabbar>
	</view>
</template>

<script>
import { loadIndexs } from '@/api/index.js';
import { tabbar } from '@/utils/tabbar.js';
export default {
	data() {
		return {
			titleNViewBackground: '',
			swiperCurrent: 0,
			swiperLength: 0,
			dataList: '',
			carouselList:[],//轮播图列表
			tabbar: tabbar,
			current: 0
		};
	},
	onLoad() {
		this.loadData();
	},
	methods: {
		loadData() {
			loadIndexs({})
				.then(({ data }) => {
					let goods = data.info;
					this.dataList = goods.bastList; //精品推荐
					this.carouselList = data.banner;
				})
				.catch(e => {});
		},
		nav(url) {
			uni.navigateTo({
				url,
				fail() {
					uni.switchTab({
						url
					});
				}
			});
		},
		//轮播图切换修改背景色
		swiperChange(e) {
			const index = e.detail.current;
			this.swiperCurrent = index;
			this.titleNViewBackground = this.carouselList[index].background;
		},
		// 點擊搜索框
		clickSearch() {
			uni.navigateTo({
				url: '/pages/product/search'
			});
		},
		//详情页
		navToDetailPage(item) {
			let id = item.id;
			uni.navigateTo({
				url: '/pages/product/product?id=' + id
			});
		}
	}
};
</script>

<style lang="scss">
page,
.center {
	min-height: 100%;
	height: auto;
	background-color: #ffffff;
}
.top {
	position: relative;
	width: 100%;
	height: 400rpx;
	.top-bg {
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		width: 100%;
		height: 100%;
	}
	.top-main {
		position: relative;
		z-index: 2;
		padding: 30rpx;
		.search-box {
			justify-content: center;
			width: 698rpx;
			height: 60rpx;
			background: rgba(255, 240, 245, 0.4);
			box-shadow: 0px 10rpx 20rpx 0px rgba(4, 114, 69, 0.22);
			border-radius: 30rpx;
			.search {
				width: 34rpx;
				height: 34rpx;
			}
			.search-font {
				margin-left: 14rpx;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #ffffff;
			}
		}
	}
}
.navbar {
	margin-top: 42rpx;
	justify-content: space-around;
	.navbar-item {
		width: 20%;
		display: flex;
		flex-direction: column;
		align-items: center;
		.nitem-image {
			width: 90rpx;
			height: 90rpx;
		}
		.nitem-font {
			margin-top: 16rpx;
			font-size: 24rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #0c1732;
		}
	}
}
.product {
	width: 750rpx;
	height: 350rpx;
	margin-top: 50rpx;
	.product-image {
		width: 750rpx;
		height: 350rpx;
	}
}
.shingle {
	width: 690rpx;
	background: #efefef;
	border-radius: 10rpx;
	margin: 60rpx auto;
	padding: 28rpx 20rpx 40rpx;
	.shingle-top {
		padding-left: 2rpx;
		.shingle-title {
			font-size: 36rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #375afe;
		}
		.shingle-btn {
			width: 248rpx;
			height: 50rpx;
			border: 2rpx solid #375afe;
			border-radius: 10rpx;
			padding: 0 16rpx;
			text-align: left;
			font-size: 24rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #375afe;
			line-height: 50rpx;
			text {
				display: inline-block;
				padding-left: 10rpx;
			}
		}
	}
	.shingle-main {
		margin: 20rpx auto;
		width: 650rpx;
		height: 206rpx;
		position: relative;
		.shingle-bg {
			position: absolute;
			top: 0;
			left: 0;
			right: 0;
			width: 650rpx;
			height: 206rpx;
			image {
				width: 650rpx;
				height: 206rpx;
			}
		}
		.shinglem-title {
			position: relative;
			z-index: 2;
			justify-content: center;
			height: 70rpx;
			.address {
				width: 28rpx;
				height: 30rpx;
			}
			.shingle-font {
				font-size: 36rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #ffffff;
				line-height: 70rpx;
				margin-left: 14rpx;
			}
		}
		.shingle-mmain {
			position: relative;
			z-index: 2;
			margin-top: 30rpx;
			.smmain-item {
				width: 33%;
				display: flex;
				flex-direction: column;
				align-items: center;
				.smitem-top {
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #ffffff;
				}
				.smitem-bottom {
					margin-top: 10rpx;
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #ffffff;
				}
				.people {
					justify-content: center;
					.peopleitem {
						width: 24rpx;
						height: 34rpx;
						image {
							width: 100%;
							height: 100%;
						}
					}
				}
			}
			.shu {
				width: 2rpx;
				height: 70rpx;
				background: #ffffff;
			}
		}
		.right-bottom {
			position: absolute;
			z-index: 2;
			right: 0;
			bottom: 0;
			width: 94rpx;
			height: 92rpx;
		}
	}
}
.good-title {
	width: 376rpx;
	height: 34rpx;
	margin: 44rpx auto 0;
	image {
		width: 100%;
		height: 100%;
	}
}
.guess-item {
	display: flex;
	width: 710rpx;
	height: 300rpx;
	background: #ffffff;
	box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
	border-radius: 10rpx;
	padding: 15rpx;
	padding-bottom: 150rpx;
	margin: 20rpx auto 0;
	position: relative;
	image {
		width: 200rpx;
		height: 200rpx;
		border-radius: 10rpx;
	}
	.guess-box {
		padding: 12rpx 0 0 24rpx;
		width: 436rpx;
		.title {
			font-size: 36rpx;
			padding-left: 4rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #333333;
			width: 368rpx;
			line-height: 36rpx;
			.tuanF {
				display: inline-block;
				margin-right: 4rpx;
				position: relative;
				top: -6rpx;
				.tuan {
					display: flex;
					align-items: center;
					padding: 10rpx;
					height: 36rpx;
					background: #ffebe9;
					border-radius: 18rpx;
					.tuan-image {
						width: 18rpx;
						height: 18rpx;
					}
					.tuan-font {
						display: inline;
						font-size: 20rpx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #ff1135;
						margin-left: 2rpx;
					}
				}
			}
		}
		.ping-box {
			margin-top: 15rpx;
			justify-content: flex-start;
			.ping {
				margin-left: 10rpx;
				height: 39rpx;
				background: #fdf7eb;
				border-radius: 5rpx;
				font-size: 22rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #ff911f;
				display: flex;
				align-items: center;
				padding: 0 10rpx;
			}
		}
		.price-box {
			margin-top: 50rpx;
			justify-content: flex-start;
			.yuanprice {
				font-size: 26rpx;
				font-family: PingFang SC;
				font-weight: 500;
				text-decoration: line-through;
				color: #999999;
				padding-right: 6rpx;
			}
			image {
				width: 14rpx;
				height: 16rpx;
			}
			.jiang {
				padding-left: 2rpx;
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #b59467;
			}
		}
		.price {
			font-size: 36rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #ff1135;
		}
		.btn {
			width: 137rpx;
			height: 56rpx;
			background: linear-gradient(0deg, rgba(60, 237, 237, 0.99), #04b8ff, #375afe);
			border-radius: 28rpx;
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #ffffff;
			line-height: 56rpx;
			text-align: center;
			position: absolute;
			bottom: 10rpx;
			right: 25rpx;
		}
	}
}
</style>
