<template>
	<view class="content">
		<view class="status_bar"><!-- 这里是状态栏 --></view>
		<view class="content-money">
			<view class="money-box">
				<view class="goback-box" @click="toBack">
					<image class="goback" src="../../static/img/back.png" mode=""></image>
					</view>
				<view class="header">商品管理</view>
				<view class="bianj" @click="nav('/pages/merchant/compileCommodity')">
					编辑
				</view>
			</view>
		</view>
		<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" v-for="item in 10">
							<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>
				</scroll-view>
			</swiper-item>
		</swiper>
		<view class="input" @click="nav('/pages/merchant/Addcommodity')">添加商品</view>
	</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: [],
					loadingType: 'more',
					page: 1, //当前页面
					limit: 10 //每次信息条数
				},
				{
					state: 0,
					text: '已上架',
					loadingType: 'more',
					orderList: [],
					page: 1, //当前页面
					limit: 10 //每次信息条数
				},
				{
					state: 0,
					text: '已下架',
					loadingType: 'more',
					orderList: [],
					page: 1, //当前页面
					limit: 10 //每次信息条数
				}
			]
		};
	},
	onLoad() {
		this.loadData();
	},
	methods: {
		//顶部tab点击
		tabClick(index) {
			this.tabCurrentIndex = index;
		},
		changeTab(index) {
			this.tabCurrentIndex = index.detail.current;
		},
		loadData() {
			
		},
		// 点击返回 我的页面
		toBack() {
			uni.navigateBack({
				
			})
		},
		choose() {
			this.isBian = !this.isBian;
		},
		nav(url){
			uni.navigateTo({
				url
			})
		}
	}
};
</script>

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

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

.list-scroll-content {
	height: 100%;
}
.status_bar {
	height: var(--status-bar-height);
	width: 100%;
	background: #ffffff;
}
.money-box {
	height: 80rpx;
	color: #000000;
	text-align: center;
	font-size: 35rpx;
	position: relative;
	background-color: #FFFFFF;
	.header {
		position: absolute;
		left: 0;
		top: 0;
		width: 100%;
		height: 80rpx;
		font-size: 32rpx;
		font-weight: 700;
		z-index: 99;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.bianj {
		position: absolute;
		right: 28rpx;
		height: 80rpx;
		font-size: 28rpx;
		font-family: PingFangSC;
		font-weight: 400;
		color: #333333;
		z-index: 99;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.goback-box {
		position: absolute;
		left: 24rpx;
		top: 0;
		height: 80rpx;
		display: flex;
		align-items: center;
	}
	.goback {
		z-index: 100;
		width: 20rpx;
		height: 34rpx;
	}
}

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

	.commodity {
		width: 750rpx;

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

		.commodity-detail {
			padding: 30rpx 0;
			padding: 30 34rpx 0 30rpx;
			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;
				padding: 10rpx 0;
				.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 {
						padding: 6rpx;
						background: #fee1d7;
						border-radius: 5rpx;
						font-size: 20rpx;
						font-family: PingFangSC;
						font-weight: 500;
						color: #fd5b23;
					}
				}
			}
		}
	}
}

.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;
			}
		}
	}
}
.input {
	position: fixed;
	bottom: 38rpx;
	left: 30rpx;
	text-align: center;
	width: 674rpx;
	height: 88rpx;
	background: #52c696;
	border-radius: 44rpx;
	font-size: 36rpx;
	font-family: PingFang SC;
	font-weight: 500;
	line-height: 88rpx;
	color: #ffffff;
}
</style>
