<template>
	<view class="container">

		<u-subsection :list="top_list" :current="current" keyName="name" activeColor="#f56c6c" mode="subsection"
			@change="sectionChange"></u-subsection>

		<view class="list">
			<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" @scrolltoupper="upper"
				@scrolltolower="lower">
				<view class="card" v-for="(item,index) in list" @click="toDetails(item.id)">
					<view class="title">运单编号：{{item.waybill_order}}<u-icon name="arrow-right"
							size="12"></u-icon></view>
					<view class="name_1 flex">车牌号：{{item.tow_license}}</view>
					<view class="name_1 flex">入园目的：{{item.w_mission}}</view>
					<view class="name_1 flex"><u-icon name="car-fill" class="icon-right" color="#2979ff"
							size="12"></u-icon>销售产品：{{item.sale_product}}</view>
					<view class="name_2 flex" v-if="item.w_mission == '装货'">
						<u-icon name="car-fill" class="icon-right" color="#ddbb0b" size="12"></u-icon>
						装货单位：{{item.waybill_loading}}
					</view>
					<view class="name_2 flex" v-else>
						<u-icon name="car-fill" class="icon-right" color="#ddbb0b" size="12"></u-icon>
						卸货单位：{{item.waybill_unloading}}
					</view>
				</view>
			</scroll-view>


		</view>


	</view>
</template>

<script>
	import {
		get,
		post
	} from '@/common/request.js'
	export default {
		data() {
			return {
				top_list: [{
					name: '全部'
				}, {
					name: '未查验'
				}, {
					name: '通过'
				}, {
					name: '未通过'
				}],
				current: 0,
				scrollTop: 0,
				list: [],
			}
		},
		mounted() {
			this.getWaybillList()
		},
		methods: {
			onPullDownRefresh() {
				setTimeout(() => {
					this.getWaybillList()
					uni.stopPullDownRefresh();
				}, 2000);
			},
			sectionChange(current) {
				this.current = current
				this.getWaybillList()
			},
			toDetails(id) {
				uni.navigateTo({
					url: '/pages/order/ordeDetails?id=' + id
				})
			},
			upper: function(e) {
				console.log(e)
			},
			lower: function(e) {
				console.log(e)
			},
			scroll: function(e) {
				console.log(e)
				this.old.scrollTop = e.detail.scrollTop
			},
			async getWaybillList() {
				await get('/myapi/api/yq_driver/waybillList', {
					current: this.current
				}).then((res) => {
					console.log(res)
					this.list = res.data
				})
			},
		},
	}
</script>

<style scoped lang="less">
	.container {
		padding-top: 2px;
		background-color: #f4f4f4;
		height: calc(100vh - 46px);

		.list {
			padding: 5px 20px;

			.scroll-Y {
				height: calc(100vh - 86px);

				.card {
					background-color: #fff;
					padding: 10px;
					margin-bottom: 10px;
					font-size: 14px;
					border-radius: 10px;

					.title {
						font-size: 16px;
						height: 40px;
						line-height: 40px;
						border-bottom: 1px solid #f4f4f4;
						display: flex;
						justify-content: space-between;
						align-items: center;
					}

					.flex {
						display: flex;

						.icon-right {
							margin-right: 5px;
						}
					}

					.name_1 {
						margin: 10px 0;

					}
				}
			}
		}
	}
</style>