<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="toptab">
        	<view class="" @click="show = true">
        		时间范围<u-icon name="arrow-down-fill" color="#3D3D3D" size="24"></u-icon>
        	</view>
			<view class="">
				<text class="one" @click="btntime(1)">{{kstime}}</text>--<text class="one" @click="btntime(2)">{{jstime}}</text>
			</view>
        </view>
		<u-picker mode="time" v-model="showtime" :params="params" @confirm='confirmkstime'></u-picker>
		<scroll-view class="list" 
		scroll-y="true"
      :scroll-with-animation="true"
      @scrolltolower="handleScrollToLower">
			<view class="list_item" v-for="(item,index) in 2" :key="index" @click="btnxq(item.orderNo)">
				<view class="top">
					2024-04-28
				</view>
				<view class="wz">
					<view class=""><text>支付金额:</text>¥0.00</view> <view class=""><text>已退款:</text>¥0.00</view>
				</view>
				<view class="wz">
					<view class=""><text>押金:</text>¥0.00</view> <view class=""><text>收入:</text>¥0.00</view>
				</view>
			</view>
			<view class="" style="width: 100%;text-align: center;font-size: 32rpx;color: #ccc;margin-top: 30rpx;">
				没有更多账单啦...
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
                bgc: {
                	backgroundColor: "#fff",
                },
				kstime:'',
				jstime:'',
				num:'',
				orderlist:[],
				pagenum:1,
				pagesize:10,
				total:0,
				params: {
					year: true,
					month: true,
					day: true,
					hour: false,
					minute: false,
					second: false
				},
				showtime: false,
			}
		},
		onLoad() {
            
		},
		onShow() {
			this.pagenum = 1
			this.orderlist = []
			this.getlist()
		},
		methods: {
			// 监听滚动到底部
			handleScrollToLower() {
			    if(this.total == this.orderlist.length){
					uni.showToast({
						title: '没有更多订单了',
						icon: 'none',
						duration:2000
					})
				}else{
					this.getlist()
				}
			},
			// 点击选择时间
			btntime(num){
				this.showtime = true
				this.num = num
			},
			// 筛选开始时间
			confirmkstime(e){
				if(this.num == 1){
					this.kstime = e.year + '-' + e.month + '-' + e.day
					if(this.jstime != ''){
						this.pagenum = 1
						this.orderlist = []
						this.getlist()
					}
				}else{
					this.jstime = e.year + '-' + e.month + '-' + e.day
					if(this.kstime != ''){
						this.pagenum = 1
						this.orderlist = []
						this.getlist()
					}
				}
			},
			// 请求订单列表
			 getlist(){
				this.$u.get(`/app/order/orderList?pageNum=${this.pagenum}&pageSize=${this.pagesize}&statusList=${this.zttxtid}&startTime=${this.kstime}&endTime=${this.jstime}`).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
						}
					}
				}) 
			 },
		}
	}
</script>

<style lang="scss">
	/deep/ .uicon-nav-back,
	/deep/ .u-title{
		padding-bottom: 20rpx;
	}
	/deep/ .uicon-arrow-down-fill{
		margin-left: 16rpx;
	}
	.list{
		width: 100%;
		height: 80vh;
		overflow: scroll;
		.list_item{
			width: 750rpx;
			max-height: 420rpx;
			background: #FFFFFF;
			margin-top: 20rpx;
			padding-bottom: 40rpx;
			box-sizing: border-box;
			.top{
				font-weight: 600;
				font-size: 32rpx;
				color: #3D3D3D;
				border-bottom: 1px solid  #D8D8D8;
				padding:22rpx 30rpx;
				box-sizing: border-box;
				margin-bottom: 26rpx;
			}
			.wz{
				display: flex;
				width: 100%;
				padding: 0 30rpx;
				box-sizing: border-box;
				margin-top: 10rpx;
				view{
					width: 50%;
				}
			}
		}
	}
	page {
		background: #F6F6F6;
	}
	.toptab{
		width: 100%;
		height: 90rpx;
		line-height: 90rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 50rpx;
		box-sizing: border-box;
		background-color: #fff;
		view{
			display: flex;
			align-items: center;
			.one{
				display: inline-block;
				width: 200rpx;
				height: 50rpx;
				border: 1px solid #ccc;
				border-radius: 10rpx;
				line-height: 50rpx;
				text-align: center;
			}
		}
	}


</style>