<template>
	<view class="content">
		<view class="navbar">
			<view v-for="(item, index) in navList" :key="index" class="nav-item"
				:class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
		</view>
		<swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
			<swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
				<scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
					<!-- 空白页 -->
					<empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
					<!-- 已上架 -->
					<view class="commodity-box">
						<view class="commodity">
							<view class="commodity-detail">
								<view class="commodity-img">
									<image src="../../static/user/ground.png" mode=""></image>
								</view>
								<view class="commodity-content">
									<view class="top">
										满园春11111111111111111111111111111111111
									</view>
									<view class="bottom">
										<view class="price">
											<text class="text">￥</text>999
										</view>
										<view class="status">
											已上架
										</view>
									</view>
								</view>
							</view>
						</view>
						<uni-load-more :status="tabItem.loadingType"></uni-load-more>
						<view class="input">
							添加商品
						</view>
					</view>
					
				</scroll-view>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';

	export default {
		data() {
			return {
				tabCurrentIndex: 0,
				navList: [{
						state: 0,
						text: '全部',
						orderList: [],
						page: 1, //当前页面
						limit: 10 //每次信息条数
					},
					{
						state: 0,
						text: '已上架',
						orderList: [],
						page: 1, //当前页面
						limit: 10 //每次信息条数
					},
					{
						state: 0,
						text: '已下架',
						orderList: [],
						page: 1, //当前页面
						limit: 10 //每次信息条数
					}
				]
			};
		},
		methods: {
			//顶部tab点击
			tabClick(index) {
				this.tabCurrentIndex = index;
			},
		}
	}
</script>

<style lang="scss">
	page,
	.content {
		background: $page-color-base;
		height: 100%;
	}

	.swiper-box {
		height: calc(100% - 40px);
	}

	.list-scroll-content {
		height: 100%;
	}

	.commodity-box {
		width: 750rpx;
		margin: 20rpx 0;
		background-color: #FFFFFF;

		.commodity {
			.checkbox1 {

				font-size: 44rpx;
				line-height: 1;
				padding: 4rpx;
				color: $font-color-disabled;
				background: red;
				border-radius: 50rpx;
			}

			.commodity-detail {
				padding: 30rpx 0;
				display: flex;

				.commodity-img {
					margin: 0 30rpx;
					width: 147rpx;
					height: 146rpx;
					border-radius: 10rpx;

					image {
						width: 100%;
						height: 100%;
					}
				}

				.commodity-content {
					width: 500rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-between;

					.top {

						white-space: nowrap;
						overflow: hidden;
						text-overflow: ellipsis;
						font-size: 28rpx;
						font-family: PingFangSC;
						font-weight: 500;
						color: #333333;
					}

					.bottom {

						display: flex;
						justify-content: space-between;
						align-items: center;

						.price {
							font-size: 36rpx;
							font-family: PingFang SC;
							font-weight: bold;
							color: #FD5B23;
							.text{
								font-size: 24rpx;
								font-family: PingFang SC;
								font-weight: bold;
								color: #FD5B23;
							}
						}

						.status {
							
							width: 80rpx;
							height: 34rpx;
							background: #FEE1D7;
							border-radius: 5rpx;
							font-size: 20rpx;
							font-family: PingFangSC;
							font-weight: 500;
							color: #FD5B23;
						}
					}
				}
			}
		}
		.input{
			margin: 30rpx;
			text-align: center;
			position: absolute;
			bottom: 0;
			width: 674rpx;
			height: 88rpx;
			background: #52C696;
			border-radius: 44rpx;
			font-size: 36rpx;
			font-family: PingFang SC;
			font-weight: 500;
			line-height: 88rpx;
			color: #FFFFFF;
		}
	}

	.navbar {
		display: flex;
		height: 40px;
		padding: 0 5px;
		background: #fff;
		box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
		position: relative;
		z-index: 10;

		.nav-item {
			flex: 1;
			display: flex;
			justify-content: center;
			align-items: center;
			height: 100%;
			font-size: 12px;
			color: $font-color-dark;
			position: relative;

			&.current {
				color: $base-color;

				&:after {
					content: '';
					position: absolute;
					left: 50%;
					bottom: 0;
					transform: translateX(-50%);
					width: 44px;
					height: 0;
					border-bottom: 2px solid $base-color;
				}
			}
		}
	}
</style>
