<template>
	<view class="page">
		<u-navbar title="订单管理" :border-bottom="false" :background="bgc" title-color='#000' title-size='36'
			height='58'></u-navbar>
        <view class="box">
        	<view class="ordertongji">
        		<view class="orderday">
        				<text @click="btnriq(1)" :class="dateindex == 1 ? 'dateactive' : ''">今日</text>
        				<text @click="btnriq(2)" :class="dateindex == 2 ? 'dateactive' : ''">昨日</text>
        				<text @click="btnriq(3)" :class="dateindex == 3 ? 'dateactive' : ''">近七日</text>
        				<text @click="btnriq(4)" :class="dateindex == 4 ? 'dateactive' : ''">近30日</text>
        		</view>
        		<u-picker mode="time" v-model="show" :params="params" @confirm="confirm"></u-picker>
        		<view class="date">
        			<text @click="btnks(1)">{{firsTime}}</text> -- <text @click="btnks(2)">{{lasTime}}</text>
        		</view>
        	</view>
			
			<view class="shuju">
				<view class="ddje" @click="btnpage(0)">
					<view class="shu">
						322110
					</view>
					<view class="sb">
						订单总数<u-icon name="arrow-right" size="18"></u-icon>
					</view>
				</view>
				<text style="width: 1px;height: 60rpx;background: #979797;margin-top: 24rpx;"></text>
				<view class="ddje" @click="btnpage(1)">
					<view class="shu">
						91
					</view>
					<view class="sb">
						租借中<u-icon name="arrow-right" size="18"></u-icon>
					</view>
				</view>
				<text style="width: 1px;height: 60rpx;background: #979797;margin-top: 24rpx;"></text>
				<view class="ddje" @click="btnpage(2)">
					<view class="shu">
						322023
					</view>
					<view class="sb">
						已完成<u-icon name="arrow-right" size="18"></u-icon>
					</view>
				</view>
			</view>
			
			<view class="shuju">
				<view class="ddje" @click="btnpage(3)">
					<view class="shu">
						32
					</view>
					<view class="sb">
						弹出失败<u-icon name="arrow-right" size="18"></u-icon>
					</view>
				</view>
				<text style="width: 1px;height: 60rpx;background: #979797;margin-top: 24rpx;"></text>
				<view class="ddje" @click="btnpage(4)">
					<view class="shu">
						1256
					</view>
					<view class="sb">
						租转卖<u-icon name="arrow-right" size="18"></u-icon>
					</view>
				</view>
				<text style="width: 1px;height: 60rpx;background: #979797;margin-top: 24rpx;"></text>
				<view class="ddje" @click="btnpage(5)">
					<view class="shu">
						5223
					</view>
					<view class="sb">
						部分退款<u-icon name="arrow-right" size="18"></u-icon>
					</view>
				</view>
			</view>
			<view class="shujus">
				<view class="ddje" @click="btnpage(6)">
					<view class="shu">
						1235
					</view>
					<view class="sb">
						已全额退款<u-icon name="arrow-right" size="18"></u-icon>
					</view>
				</view>
				<text style="width: 1px;height: 60rpx;background: #979797;margin-top: 24rpx;margin-left: 54rpx;margin-right: 70rpx;"></text>
				<view class="ddje" @click="btnpage(7)">
					<view class="shu">
						96
					</view>
					<view class="sb">
						待扣款<u-icon name="arrow-right" size="18"></u-icon>
					</view>
				</view>
			</view>
			
        </view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
                params: {
                	year: true,
                	month: true,
                	day: true,
                	hour: false,
                	minute: false,
                	second: false
                },
                show: false,
                firsTime:'',
                lasTime:'',
                num: '',
                dateindex: 1,
			}
		},
		onLoad() {
			let today = new Date();
			this.firsTime = this.formatDate(today);
			this.lasTime = this.formatDate(today);
		},
		methods: {
			btnks(num) {
				this.show = true
				if (num == 1) {
					this.num = 1
				} else {
					this.num = 2
				}
			},
			confirm(e) {
				if (this.num == 1) {
					this.selector = e.year + '-' + e.month + '-' + e.day
				} else {
					this.selectors = e.year + '-' + e.month + '-' + e.day
				}
			},
			btnpage(num){
				if(num == 0){
					uni.navigateTo({
						url:'/page_user/order/detailshop?title=' + '订单总数列表' 
					})
				}else if(num == 1){
					uni.navigateTo({
						url:'/page_user/order/detailshop?title=' + '租借中列表'
					})
				}else if(num == 2){
					uni.navigateTo({
						url:'/page_user/order/detailshop?title=' + '已完成列表'
					})
				}else if(num == 3){
					uni.navigateTo({
						url:'/page_user/yunying/gongdan/tanchu' 
					})
				}else if(num == 4){
					uni.navigateTo({
						url:'/page_user/order/detailshop?title=' + '租转卖列表'
					})
				}else if(num == 5){
					uni.navigateTo({
						url:'/page_user/order/detailshop?title=' + '部分退款列表'
					})
				}else if(num == 6){
					uni.navigateTo({
						url:'/page_user/order/detailshop?title=' + '已全额退款列表'
					})
				}else if(num == 7){
					uni.navigateTo({
						url:'/page_user/order/detailshop?title=' + '待扣款列表'
					})
				}
			},
			
			btnriq(num) {
				this.dateindex = num
				if (num == 1) {
					let today = new Date();
					this.firsTime = this.formatDate(today);
					this.lasTime = this.formatDate(today);
				} else if (num == 2) {
					let yesterday = new Date();
					yesterday.setDate(yesterday.getDate() - 1);
					this.firsTime = this.formatDate(yesterday);
					this.lasTime = this.formatDate(new Date());
				} else if (num == 3) {
					let today = new Date();
					let firstDayOfMonth = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 6);
					this.firsTime = this.formatDate(firstDayOfMonth);
					this.lasTime = this.formatDate(new Date());
				} else if (num == 4) {
					let today = new Date();
					let firstDayOfLastMonth = new Date(today.getFullYear(), today.getMonth() - 1,today.getDate() + 1);
					let lastDayOfLastMonth = new Date(today.getFullYear(), today.getMonth(), today.getDate());
					this.firsTime = this.formatDate(firstDayOfLastMonth);
					this.lasTime = this.formatDate(lastDayOfLastMonth);
				} 
			},
			formatDate(date) {
				let year = date.getFullYear();
				let month = String(date.getMonth() + 1).padStart(2, '0');
				let day = String(date.getDate()).padStart(2, '0');
				return `${year}-${month}-${day}`;
			},
		}
	}
</script>

<style lang="scss">
	/deep/ .u-title,
	/deep/ .uicon-nav-back {
		padding-bottom: 40rpx;
	}
	page {
		background: linear-gradient(180deg, #25CE88 0%, rgba(255, 255, 255, 0) 100%);
	}
	.dateactive {
		background: #E1F3ED;
	}

	.page {
		width: 750rpx;
		position: fixed;
		top: 0;
		left: 0;
		.box{
			width: 750rpx;
			height: 1440rpx;
			background: #F4F5F7;
			border-radius: 0rpx 0rpx 0rpx 0rpx;
			.shujus {
				width: 680rpx;
				height: 152rpx;
				background: #FFFFFF;
				border-radius: 24rpx 24rpx 24rpx 24rpx;
				margin: auto;
				display: flex;
				padding: 24rpx 60rpx;
				box-sizing: border-box;
			   margin-top: 30rpx;
				.ddje {
					text-align: center;
			
					.shu {
						font-weight: 500;
						font-size: 40rpx;
						color: #3D3D3D;
					}
			
					.sb {
						margin-top: 20rpx;
						font-weight: 500;
						font-size: 20rpx;
						color: #3D3D3D;
					}
				}
			}
			.shuju {
				width: 680rpx;
				height: 152rpx;
				background: #FFFFFF;
				border-radius: 24rpx 24rpx 24rpx 24rpx;
				margin: auto;
				display: flex;
				justify-content: space-between;
				padding: 24rpx 60rpx;
				box-sizing: border-box;
			   margin-top: 30rpx;
				.ddje {
					text-align: center;
			
					.shu {
						font-weight: 500;
						font-size: 40rpx;
						color: #3D3D3D;
					}
			
					.sb {
						margin-top: 20rpx;
						font-weight: 500;
						font-size: 20rpx;
						color: #3D3D3D;
					}
				}
			}
			.ordertongji {
				width:750rpx;
				height: 200rpx;
				background: #FFFFFF;
				margin-bottom: 30rpx;
				.date {
					padding-left: 80rpx;
					padding-right: 80rpx;
					box-sizing: border-box;
					display: flex;
					justify-content: space-between;
					margin-top: 26rpx;
			
					text {
						padding: 6rpx 18rpx;
						box-sizing: border-box;
						background: #eee;
						border-radius: 10rpx 10rpx 10rpx 10rpx;
						font-size: 24rpx;
						color: #808080;
					}
				}
			
				.orderday {
					display: flex;
					justify-content: space-between;
					width: 100%;
					padding: 10rpx 12rpx;
					box-sizing: border-box;
			
					text {
						margin-right: 10rpx;
						border-radius: 20rpx;
						text-align: center;
						display: inline-block;
						width: 148rpx;
						height: 84rpx;
						// background: #E1F3ED;
						text-align: center;
						line-height: 84rpx;
					}
				}
			}
		}
	}
</style>