<template>
	<view class="content">
		<scroll-view scroll-x="true" class="class-box flex b-t" :scroll-with-animation="true">
			<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>
		</scroll-view>
		<swiper :style="{ height: maxheight }" :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="title">
						<view class="title-item flex">
							<view class="title-font">
								提交人：
							</view>
							<view class="title-font">
								全包员工
							</view>
						</view>
						<view class="xian">
						</view>
						<view class="title-item flex">
							<view class="title-font">
								当前检验阶段：
							</view>
							<view class="title-font">
								下料
							</view>
						</view>
					</view>
					<view v-for="(item,index) in tabItem.orderList">
						<view class="main" v-if="tabCurrentIndex == 0">
							<view class="main-top">
								<image class="main-icon" src="../../static/icon/order.png" mode=""></image>
								<view class="main-font">
									{{item.name}}
								</view>
							</view>
							<view class="xian"></view>
							<view class="main-bottom flex">
								<view class="num">
									总数量：
								</view>
								<view class="main-input red">
									363
								</view>
							</view>
							<view class="xian"></view>
							<view class="main-bottom flex">
								<view class="num">
									合格数量：
								</view>
								<view class="main-input red">
									{{item.number}}
								</view>
							</view>
							<view class="xian"></view>
							<view class="main-bottom flex">
								<view class="num">
									品质评级：
								</view>
								<view class="main-input">
									{{item.pj}}
								</view>
							</view>
						</view>
						<view class="main" v-if="tabCurrentIndex == 1">
							<view class="main-top">
								<image class="main-icon" src="../../static/icon/order.png" mode=""></image>
								<view class="main-font">
									{{item.name}}
								</view>
							</view>
							<view class="main-bottom flex">
								<view class="num">
									合格/不合格：
								</view>
								<view class="main-input">
									不合格
								</view>
							</view>
							<view class="xian"></view>
							<view class="main-bottom flex">
								<view class="num">
									总数量：
								</view>
								<view class="main-input red">
									363
								</view>
							</view>
							<view class="xian"></view>
							<view class="main-bottom flex">
								<view class="num">
									不合格数量：
								</view>
								<view class="main-input red">
									{{item.number}}
								</view>
							</view>
							<view class="xian"></view>
							<view class="main-bottom">
								<view class="num">
									图片：
								</view>
								<view class="banner-box">
									<view class="banner" v-for="(imgitem,imgindex) in item.images" :key="index">
										<view class="banner-main">
											<image :src="imgitem" mode=""></image>
										</view>
									</view>
								</view>
							</view>
						</view>
						<view class="main" v-if="tabCurrentIndex == 2">
							<view class="main-top">
								<image class="main-icon" src="../../static/icon/order.png" mode=""></image>
								<view class="main-font">
									{{item.name}}
								</view>
							</view>
							<view class="main-bottom flex">
								<view class="num">
									总数量：
								</view>
								<view class="main-input red">
									363
								</view>
							</view>
							<view class="xian"></view>
							<view class="main-bottom flex">
								<view class="num">
									缺漏数量：
								</view>
								<view class="main-input red">
									{{item.number}}
								</view>
							</view>
						</view>
					</view>
					<uni-load-more :status="tabItem.loadingType"></uni-load-more>
				</scroll-view>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				maxheight: '',
				tabCurrentIndex: 0,
				navList: [{
						state: 0,
						text: '合格记录',
						loadingType: 'more',
						orderList: [{
							name: '规格1(黄色,37码）',
							number: 10,
							pj: '优',
							images: []
						}, {
							name: '规格2(黄色,37码）',
							number: 10,
							pj: '及',
							images: []
						}, {
							name: '规格3(黄色,37码）',
							number: 10,
							pj: '良',
							images: []
						}, {
							name: '规格4(黄色,37码）',
							number: 10,
							pj: '不及',
							images: []
						}, {
							name: '规格5(黄色,37码）',
							number: 10,
							pj: '优',
							images: []
						}, {
							name: '规格6(黄色,37码）',
							number: 10,
							pj: '优',
							images: []
						}, {
							name: '规格7(黄色,37码）',
							number: 10,
							pj: '及',
							images: []
						}, {
							name: '规格8(黄色,37码）',
							number: 10,
							pj: '及',
							images: []
						}],
						page: 1, //当前页数
						limit: 10 //每次信息条数
					},
					{
						state: 1,
						text: '不合格记录',
						loadingType: 'more',
						orderList: [{
							name: '规格1(黄色,37码）',
							number: 20,
							images: []
						}, {
							name: '规格2(黄色,37码）',
							number: 20,
							images: []
						}, {
							name: '规格3(黄色,37码）',
							number: 20,
							images: []
						}, {
							name: '规格4(黄色,37码）',
							number: 20,
							images: []
						}, {
							name: '规格5(黄色,37码）',
							number: 20,
							images: []
						}, {
							name: '规格6(黄色,37码）',
							number: 20,
							images: []
						}, {
							name: '规格7(黄色,37码）',
							number: 20,
							images: []
						}, {
							name: '规格8(黄色,37码）',
							number: 20,
							images: []
						}],
						page: 1, //当前页数
						limit: 10 //每次信息条数
					},
					{
						state: 2,
						text: '缺漏',
						loadingType: 'more',
						orderList: [{
							name: '规格1(黄色,37码）',
							number: 28,
							images: []
						}, {
							name: '规格2(黄色,37码）',
							number: 28,
							images: []
						}, {
							name: '规格3(黄色,37码）',
							number: 28,
							images: []
						}, {
							name: '规格4(黄色,37码）',
							number: 28,
							images: []
						}, {
							name: '规格5(黄色,37码）',
							number: 28,
							images: []
						}, {
							name: '规格6(黄色,37码）',
							number: 28,
							images: []
						}, {
							name: '规格7(黄色,37码）',
							number: 28,
							images: []
						}, {
							name: '规格8(黄色,37码）',
							number: 28,
							images: []
						}],
						page: 1, //当前页数
						limit: 10 //每次信息条数
					},
				],
			};
		},
		onLoad() {},
		onShow() {},
		onReachBottom() {},
		onReady(res) {
			var _this = this;
			uni.getSystemInfo({
				success: resu => {
					const query = uni.createSelectorQuery();
					query.select('.swiper-box').boundingClientRect();
					query.exec(function(res) {
						_this.maxheight = resu.windowHeight - res[0].top + 'px';
						console.log('打印页面的剩余高度', _this.maxheight);
					});
				},
				fail: res => {}
			});
		},
		methods: {
			tabClick(index) {
				this.tabCurrentIndex = index;
			},
			changeTab(e) {
				this.tabCurrentIndex = e.target.current;
				// this.loadData('tabChange');
			},
			loadData() {

			}
		}
	};
</script>

<style lang="scss">
	page,
	.content {
		min-height: 100%;
		height: auto;
	}

	.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 {
			background: #fff;
			display: flex;
			justify-content: center;
			align-items: center;
			width: 33%;
			flex-shrink: 0;
			height: 100%;
			font-size: 15px;
			color: #9c9c9c;
			position: relative;

			&.current {
				color: #333333;

				&:after {
					content: '';
					position: absolute;
					left: 50%;
					bottom: 0;
					transform: translateX(-50%);
					width: 44px;
					height: 0;
					border-bottom: 2px solid #ff4c4c;
				}
			}
		}
	}


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

	.title {
		width: 700rpx;
		background: #FFFFFF;
		border: 2px solid #EAECED;
		box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50, 50, 52, 0.06);
		border-radius: 20rpx;
		margin: 20rpx auto 0;
		padding: 0 24rpx;

		.title-item {
			padding: 24rpx 6rpx;

			.title-font {
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #323333;
			}
		}
	}

	.main {
		margin: 20rpx auto 0;
		padding: 0 20rpx;
		width: 700rpx;
		background: #FFFFFF;
		border: 2px solid #EAECED;
		box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50, 50, 52, 0.06);
		border-radius: 20rpx;

		.main-top {
			display: flex;
			align-items: center;
			padding: 16rpx 0;
			border-bottom: 1px solid #EAECED;

			.main-icon {
				width: 32rpx;
				height: 37rpx;
			}

			.main-font {
				margin-left: 10rpx;
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #333333;
			}
		}

		.main-bottom {
			padding: 20rpx 0;

			.num {
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #666666;
			}

			.main-input {
				text-align: right;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #999999;
			}

			.red {
				color: #FF4C4C;
			}
		}
	}

	.banner-box {
		background: #ffffff;
		padding: 20rpx;
		display: flex;
		align-items: center;
		flex-wrap: wrap;

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

		.banner {
			position: relative;
			width: 110rpx;
			height: 110rpx;
			margin-right: 10rpx;

			.banner-main {
				position: absolute;
				top: 0;
				left: 0;
				right: 0;
				width: 160rpx;
				height: 160rpx;
				border-radius: 20rpx;

				image {
					border-radius: 20rpx;
				}
			}

			.cha {
				position: absolute;
				top: 0;
				right: 0;
				width: 40rpx;
				height: 40rpx;
			}
		}
	}
</style>