<template>
	<view class="page">
		<u-navbar title="保洁订单" :border-bottom="false" :background="bgc" back-icon-color="#262B37" title-color='#262B37'
			title-size='36' height='50' id="navbar">
		</u-navbar>
        <view class="serch">
        	<view class="lt">
        		<image src="https://api.ccttiot.com/smartmeter/img/static/uaG7R4JLfYOzBhWfDN0j" mode=""></image><input type="text" v-model="keyword" placeholder="搜索"/> <view class="sousuo" @click="btnsousuo">搜索</view>
        	</view>
			<view class="tab">
				<view @click="btntab(1)" :class="tabindex == 1 ? 'active' : ''">
					待保洁
				</view>
				<view @click="btntab(2)" :class="tabindex == 2 ? 'active' : ''">
					已保洁
				</view>
			</view>
        </view>
		<scroll-view class="list"
		  scroll-y="true"
		  :scroll-with-animation="true"
		  @scrolltolower="handleScrollToLower">
			<view class="item_list" v-for="(item,index) in orderlist" :key="index">
				<view class="top">
					<view class="lt">
						<image src="https://api.ccttiot.com/smartmeter/img/static/upHnI7g3Y6IAzV0LdRyP" mode=""></image> 2025-01-01 16:00
					</view>
					<view class="rt">
						已保洁
					</view>
				</view>
				<view class="name">
					<view class="lt">
						门店名称
					</view>
					<view class="lt">
						茶馆
					</view>
				</view>
				<view class="bd">
					<view class="">
						包厢名称：竹韵
					</view>
					<view class="">
						开始时间：2025-01-01 16:00
					</view>
					<view class="">
						预计结束时间：2025-01-01 16:30
					</view>
					<view class="">
						完成时间：--
					</view>
				</view>
				<view class="bot">
					<view class=""></view>
					<view class="wc">完成保洁</view>
				</view>
			</view>
			<view style="width: 100%;text-align: center;font-size: 32rpx;color: #ccc;font-weight: 600;margin-top: 30rpx;">
				没有更多保洁订单啦...
			</view>
		</scroll-view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
                bgc: {
                	backgroundColor: "#fff",
                },
				tabindex:1,
				orderlist:[],
				pagenum:1,
				pagesize:10,
				total:0,
			}
		},
		onLoad() {
            this.getlist()
		},
		methods: {
			// 点击切换列表状态
			btntab(num){
				this.tabindex = num
			},
			// 请求保洁记录列表
			 getlist(){
				this.$u.get(`/app/clean/list?pageNum=${this.pagenum}&pageSize=${this.pagesize}`).then(res =>{
					if(res.code == 200){
						this.total = res.total
						if(this.pagenum > 1){
							this.pagenum++
							this.orderlist = this.orderlist.concat(res.rows) 
						}else{
							this.pagenum++
							this.orderlist = res.rows
						}
					}
				}) 
			 },
			// 监听滚动到底部
			handleScrollToLower() {
			    if(this.total == this.orderlist.length){
					uni.showToast({
						title: '没有更多订单了',
						icon: 'none',
						duration:2000
					})
				}else{
					this.getlist()
				}
			},
		}
	}
</script>

<style lang="scss">
	/deep/ .u-iconfont,
	/deep/ .u-title{
		padding-bottom: 20rpx;
	}
	.list{
		width: 100%;
		height: 74vh;
		overflow: scroll;
		.item_list{
			margin: auto;
			margin-top: 20rpx;
			padding: 20rpx 18rpx;
			box-sizing: border-box;
			width: 674rpx;
			max-height: 650rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 2rpx 12rpx 0rpx rgba(0,0,0,0.15);
			border-radius: 18rpx 18rpx 18rpx 18rpx;
			.bot{
				border-top: 1px solid #D8D8D8;
				margin-top: 30rpx;
				padding-top: 20rpx;
				box-sizing: border-box;
				display: flex;
				justify-content: space-between;
				.wc{
					width: 194rpx;
					height: 64rpx;
					background: #48893B;
					border-radius: 14rpx 14rpx 14rpx 14rpx;
					font-weight: 600;
					font-size: 32rpx;
					color: #FFFFFF;
					text-align: center;
					line-height: 64rpx;
				}
			}
			.bd{
				margin-top: 30rpx;
				view{
					font-size: 28rpx;
					color: #3D3D3D;
					margin-top: 16rpx;
				}
			}
			.name{
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-top: 22rpx;
				padding-bottom: 24rpx;
				box-sizing: border-box;
				border-bottom: 1px solid #D8D8D8;
				.lt{
					font-weight: 600;
					font-size: 28rpx;
					color: #3D3D3D;
				}
				.rt{
					font-size: 24rpx;
					color: #7C7C7C;
				}
			}
			.top{
				width: 634rpx;
				height: 90rpx;
				background: #DEF1DA;
				display: flex;
				justify-content: space-between;
				padding: 22rpx;
				box-sizing: border-box;
				border-radius: 20rpx;
				.lt{
					display: flex;
					align-items: center;
					image{
						width: 46rpx;
						height: 46rpx;
						margin-right: 14rpx;
					}
				}
			}
		}
	}
	page {
		background: #F6F6F6;
		padding-bottom: 30rpx;
		box-sizing: border-box;
	}
	.active{
		color: #48893B !important;
		border-bottom: 6rpx solid #48893B !important;
	}
    .serch{
    	padding: 0 36rpx;
    	box-sizing: border-box;
    	padding-top: 20rpx;
    	padding-bottom: 22rpx;
    	background-color: #fff;
		.tab{
			display: flex;
			width: 100%;
			justify-content: space-between;
			padding: 0 138rpx;
			box-sizing: border-box;
			margin-top: 32rpx;
			view{
				font-size: 32rpx;
				color: #3D3D3D;
				padding-bottom: 6rpx;
				box-sizing: border-box;
				border-bottom: 6rpx solid #fff;
			}
		}
    	.lt{
    		display: flex;
    		align-items: center;
    		width: 100%;
    		height: 68rpx;
    		border: 2rpx solid #48893B;
    		border-radius: 24rpx;
    		padding-left: 30rpx;
    		box-sizing: border-box;
    		.sousuo{
    			width: 140rpx;
    			height: 66rpx;
    			text-align: center;
    			line-height: 66rpx;
    			font-size: 32rpx;
    			color: #FFFFFF;
    			background: #48893B;
    			border: 2rpx solid #48893B;
    			border-radius: 0 20rpx 20rpx 0;
    		}
    		image{
    			width: 46rpx;
    			height: 46rpx;
    		}
    		input{
    			width: 460rpx;
    			margin-left: 30rpx;
    			height: 68rpx;
    			line-height: 68rpx;
    		}
    	}
    }

</style>