<template>
	<view>
		<lf-nav title="订单管理" :showIcon="true" bgColor="#fff" @changeHeight="e => nav_height = e"></lf-nav>
		<view class="head">
			<u-tabs :list="tab_list" active-color="#0F31A3" inactive-color='#777777' :is-scroll="true" :current="tab_current" @change="tabChange"></u-tabs>
		</view>
		
		<swiper :style="{height: autoHeight}" :current="tab_current" @change="swiperChange">
			<swiper-item v-for="(tab_item, tab_index) in tab_list" :key="tab_index">
				<scroll-view :style="{height: autoHeight}" :scroll-y="true">
					<view class="content">
						<view class="card" v-for="(item, index) in 10" :key="index">
							<view class="lf-flex">
								<image class="goods-img"></image>
								<view class="info">
									<view class="lf-font-26 lf-color-333 lf-line-2">爱他美较大婴儿配方奶粉较大配方奶粉较2段 </view>
									<view class="lf-row-between" style="line-height: 1;">
										<text class="lf-font-24 lf-color-777">1件；900g</text>
										<text class="lf-font-32 lf-font-bold" style="color: #F63434;">¥385</text>
									</view>
								</view>
							</view>
							<view class="order-num">
								<view class="deliver" v-if="index == 1" @click="deliver">发货</view>
								<view v-else>待付款</view>
								<view style="color: #F63434;">删除订单</view>
							</view>
						</view>
					</view>
				</scroll-view>
			</swiper-item>
		</swiper>
		<u-popup mode="bottom" v-model="show_deliver" :round="true" borderRadius="20">
			<view class="popup-content">
				<view class="title">选择物流商家</view>
				<picker mode="selector" :range="columns" :value="select_index" @change="selectChange">
					<view class="logistics" @click="show_logistics = true">
						<text>{{ columns[select_index] || '请选择物流' }}</text>
						<text class="lf-iconfont icon--1"></text>
					</view>
				</picker>
				<view class="title">订单编号</view>
				<input class="input" placeholder="请输入订单编号" v-model="orderNum" />
				<button class="btn" @click="confirm">确认发货</button>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data(){
			let _public = {
				page: 1,
				isPage: true,
				loadingClass: true,
				loadingText: '正在加载中'
			}
			return {
				tab_current: 0,
				tab_list: [{
					name: '全部',
					list: [],
					..._public
				},{
					name: '待付款',
					list: [],
					..._public
				},{
					name: '待发货',
					list: [],
					..._public
				},{
					name: '待提货',
					list: [],
					..._public
				}],
				scrollH: 0,
				nav_height: 0,
				show_deliver: false,
				columns: [
					'中通快递', '申通快递', '圆通快递', '国通快递', '百世汇通快递',
					'顺丰快递', '京东快递', '天猫快递', 'EMS特快'
				],
				show_logistics: false,
				select_index: null,
				orderNum: ''
			}
		},
		computed: {
			autoHeight(){
				return `calc(${this.scrollH}px - ${this.nav_height}px - 86rpx)`;
			}
		},
		onLoad(){
			let info = uni.getSystemInfoSync();
			this.scrollH = info.screenHeight;
		},
		methods: {
			tabChange(event){
				this.tab_current = event;
			},
			swiperChange(event){
				this.tab_current = event.detail.current;
			},
			deliver(){
				console.log("1111111");
				this.show_deliver = true;
			},
			selectChange(event){
				this.select_index = event.detail.value;
			},
			// 确认发货
			confirm(){
				console.log("选择的物流：", this.columns[this.select_index] || '未选择');
				console.log("订单号：", this.orderNum || '未输入');
				if(this.columns[this.select_index] && this.orderNum){
					this.show_deliver = false;
				}else{
					this.$msg('请将信息补充完整')
				}
			}
		}
	}
</script>

<style>
	page{
		background-color: #F8F8F8;
	}
</style>
<style lang="scss" scoped="scoped">
	.head{
		background-color: #FFFFFF;
	}
	.content{
		padding: 30rpx 32rpx;
		.card{
			width: 686rpx;
			height: max-content;
			background: #FFFFFF;
			border-radius: 20rpx;
			padding: 30rpx;
			box-sizing: border-box;
			&:nth-child(n+2){
				margin-top: 20rpx;
			}
			.shop-name{
				font-size: 28rpx;
				color: #222222;
				font-weight: bold;
				margin: 0 15rpx;
			}
			.goods-img{
				width: 130rpx;
				height: 130rpx;
				border-radius: 5rpx;
				margin-right: 15rpx;
				background-color: #EEEEEE;
			}
			.info{
				width: 480rpx;
				height: 130rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
			}
			.order-num{
				font-size: 24rpx;
				color: #555555;
				display: flex;
				justify-content: space-between;
				margin-top: 28rpx;
				.deliver{
					width: 109rpx;
					height: 35rpx;
					background: #0E2F9E;
					border-radius: 17rpx;
					font-size: 24rpx;
					color: #FFFFFF;
					line-height: 35rpx;
					text-align: center;
				}
			}
		}
	}
	.popup-content{
		width: 750rpx;
		height: max-content;
		background-color: #FFFFFF;
		box-sizing: border-box;
		padding: 60rpx 32rpx;
		.title{
			color: #555555;
			font-size: 28rpx;
			margin-bottom: 30rpx;
		}
		.logistics{
			width: 686rpx;
			height: 80rpx;
			background: rgba(14, 47, 158, 0.05);
			border-radius: 5rpx;
			border: 1rpx solid #0E2F9E;
			color: #0E2F9E;
			font-size: 28rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0 30rpx;
			box-sizing: border-box;
			margin-bottom: 60rpx;
		}
		.input{
			width: 686rpx;
			height: 80rpx;
			background: rgba(14, 47, 158, 0.05);
			border-radius: 5rpx;
			padding: 0 30rpx;
			font-size: 28rpx;
			margin-bottom: 100rpx;
		}
		.btn{
			width: 550rpx;
			height: 100rpx;
			background: #0D2E9A;
			border-radius: 50rpx;
			line-height: 100rpx;
			color: #FFFFFF;
		}
	}
	
	// tabs 样式修改
	/deep/.u-scroll-box {
		display: flex;
		justify-content: center;
		align-items: center;
		border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
	}
	/deep/.u-scroll-box .u-tab-bar {
		background-color: #0F31A3!important;
		width: 80rpx!important;
		position: absolute;
		left: 0;
		bottom: -12rpx;
	}
	
	/deep/.special_tab .u-tabs .u-scroll-box .u-tab-bar {
		background-color: #0F31A3!important;
		width: 56rpx!important;
		position: absolute;
		height: 5rpx!important;
		left: 8rpx;
		bottom: -4rpx;
	}
	
	/deep/ .u-tab-item {
		font-size: 28rpx!important;
	}

</style>
