<template>
	<view class="content">
		<view class="search-wrap">
			<view class="search flex">
				<image src="../../static/icon/search.png" mode=""></image>
				<input type="text" placeholder="请输入关键词搜索" confirm-type="search" @confirm="search" v-model="keys"/>
			</view>
		</view>
		<view class="navbar">
			<view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: current === index }" @click="changeCurrent(index)">{{ item.tit }}</view>
		</view>
		<view style="height: 20rpx;">
		</view>
		<swiper :current="current" class="swiper-box" :style="{'height': height}" @change="chanageC">
			<swiper-item v-for="item in navList" >
				<scroll-view scroll-y="true" :style="{'height': height}">
					<empty v-if="item.loaded === true && item.list.length === 0"></empty>
					<view class="order-item" v-for="items in item.list" >
						<view class="item-top flex">
							<view class="order-type">
								预约订单
							</view>
							<view class="order-id">
								订单编号:9876543211025666
							</view>
							<view class="order-status">
								待服务
							</view>
						</view>
						<view class="item-user flex">
							<image src="../../static/icon/where.png" mode="" class="where"></image>
							<view class="">
								<view class="">
									山西省太原市小店区谢涛清真羊肉汤(并州东街店)
								</view>
								<view class="phone">
									陈琪137****58343
								</view>
							</view>
						</view>
						<view class="item-user flex">
							<image src="../../static/icon/time.png" mode="" class="where"></image>
							<view class="">
								<view class="">
									山西省太原市小店区谢涛清真羊肉汤(并州东街店)
									山西省太原市小店区谢涛清真羊肉汤(并州东街店)
								</view>
							</view>
						</view>
						<view class="item-yg">
							<view class="" style="padding-bottom: 15rpx;">
								服务类型：<text>洗衣</text>
							</view>
							<view class="">
								代理人：<text>李丹丹</text>
							</view>
						</view>
						<view class="item-btm flex">
							下单时间：2024/12/15
						</view>
					</view>
					<uni-load-more :status="item.loadingType" v-if="!(item.loaded === true && item.list.length === 0)"></uni-load-more>
				</scroll-view>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	import empty from '@/components/empty';
	export default {
		components: {
			empty,
			uniLoadMore
		},
		data() {
			return {
				keys: '',
				height: '',
				current: 0,
				navList: [
					{
						tit: '待服务',
						status: 0,
						list: [],
						loadingType: 'more',
						loaded: true,
						page: 1,
						limit: 10
					},
					{
						tit: '进行中',
						status: 1,
						list: [1,2,1,2,1,2,1,2],
						loadingType: 'more',
						loaded: false,
						page: 1,
						limit: 10
					}
				]
			}
		},
		onLoad() {
			
		},
		onShow() {
			
		},
		onReachBottom() {
			
		},
		onReady(res) {
					var that = this;
					uni.getSystemInfo({
						success: resu => {
							const query = uni.createSelectorQuery();
							query.select('.swiper-box').boundingClientRect();
							query.exec(function(res) {
								that.height = resu.windowHeight - res[0].top + 'px';
							});
						},
						fail: res => {}
					});
				},
		methods: {
			search() {
				console.log('ddd');
			},
			chanageC(e) {
				this.current = e.detail.current;
				this.getOrderList('tab')
			},
			changeCurrent(index) {
				if(index == this.current) return;
				this.current = index;
			},
			getOrderList(type) {
				let that = this;
				let item = that.navList[that.current];
				if(type == 'tab' && item.loaded) return;
				if(item.loadingType == 'loading' || item.loadingType == 'noMore') return;
				item.loadingType = 'loading'
			}
		}
	}
</script>

<style lang="scss" scoped>
	.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: 15px;
			color: $font-color-dark;
			position: relative;
	
			&.current {
				color: #000;
				font-weight: bold;
	
				&:after {
					content: '';
					position: absolute;
					left: 50%;
					bottom: 0;
					transform: translateX(-50%);
					width: 44px;
					height: 0;
					border-bottom: 2px solid $base-color;
				}
			}
		}
	}
	.swiper-box {
	}
	.order-item {
		padding:0 20rpx;
		background-color: #fff;
		width: 700rpx;
		margin: 0 auto 20rpx;
		border-radius: 20rpx;
		&:last-of-type {
			margin-bottom: 0;
		}
		.item-top {
			height: 92rpx;
			border-bottom: #f5f5f5 3rpx solid;
			font-weight: 500;
			.order-type {
				// padding: 10;
				padding: 8rpx 10rpx;
				
				background: #ffeae5;
				border-radius: 0rpx 10rpx 0rpx 10rpx;
				font-size: 20rpx;
				color: #FF4E00;
			}
			.order-id {
				flex-grow: 1;
				font-size: 22rpx;
				color: #A3A8BB;
				padding-left: 10rpx;
			}
			.order-status {
				font-size: 26rpx;
				color: #FF4E00;
			}
		}
		.item-yg {
			width: 660rpx;
			height: 122rpx;
			background: #F5F5F5;
			font-size: 24rpx;
			color: #666666;
			padding: 25rpx 0 0 20rpx;
			margin-bottom: 24rpx;
			text {
				font-weight: bold;
				color: #333333;
			}
		}
		.item-btm {
			height: 92rpx;
			font-size: 24rpx;
			color: #A3A8BB;
			border-top: #f5f5f5 3rpx solid;
		}
		.item-user {
			justify-content: flex-start;
			align-items: flex-start;
			font-weight: bold;
			font-size: 26rpx;
			color: #000000;
			margin: 30rpx 0;
			.where {
				width: 24rpx;
				height: 28rpx;
				margin-right: 23rpx;
			}
			.time {
				width: 24rpx;
				height: 24rpx;
				
			}
			image {
				flex-shrink: 0;
				margin-top:5rpx;
			}
			.phone {
				padding-top: 15rpx;
				font-size: 23rpx;
				color: #666666;
			}
		}
	}
	.search-wrap {
		background-color: #ffffff;
		padding: 20rpx 0;
		.search {
			width: 702rpx;
			height: 64rpx;
			background: #F1F1F1;
			border-radius: 32rpx;
			margin: auto;
			padding: 0 30rpx;
			image {
				width: 31rpx;
				height: 32rpx;
				flex-shrink: 0;
			}
			input {
				height: 100%;
				flex-grow: 1;
				padding-left: 18rpx;
			}
		}
	}
</style>