<template>
	<view id="warp">
		<view class="warp_search">
			<view class="top_search">
				<uni-search-bar 
					style="width: 100%"
					bgColor="white" 
					placeholder="搜索" 
					v-model="serchValue"
					@input="onSearch" 
					clearButton="none"
				></uni-search-bar>
			</view>
			<view class="top_img">
				<image
					:src="!show_shaixuan?'/static/images/common/shaixuan.png':'/static/images/common/shaixuan_have.png'"
					@click="click_shaixuan"></image>
			</view>
			<!-- 筛选框 -->
			<view class="search_box" v-if="show_shaixuan">
				<view :class="isEnabled==0?'search_box_item is_ok':'search_box_item'" @click="is_ok_fn(0)"> 全部 </view>
				<view :class="isEnabled==1?'search_box_item is_ok':'search_box_item'" @click="is_ok_fn(1)"> 启用 </view>
				<view :class="isEnabled==-1?'search_box_item is_ok':'search_box_item'" @click="is_ok_fn(-1)"> 停用 </view>
			</view>
		</view>
		<lndexlist 
			@onclick="changeUser" 
			@onRefresh="onRefresh" 
			:list="peopleList" 
			type="car" 
			:is_no="is_no"
			:triggered="triggered"
		></lndexlist>
	</view>
</template>

<script>
	import lndexlist from "@/components/index-list2/index-list2.vue"
	const {
		urlList,
		https
	} = require("@/static/api");
	export default {
		data() {
			return {
				peopleList: [],
				showNone: false,
				isLoading: false, //是否在加载中
				isEnabled: 1, //是否启用
				currentPage: 1,
				is_no: false,
				pageSize: 20,
				serchValue: "", //查找
				show_shaixuan: false, //筛选
				is_ok: 1, //筛选启用停用
				triggered: false,
			};
		},
		components: {
			lndexlist
		},
		onLoad() {

		},
		onShow() {
			this.reset()

		},
		methods: {
			onRefresh() {
				if (!this.isLoading) {
					this.triggered = true;
					this.isLoading = true;
					this.currentPage = 1;
					this.peopleList = [];
					this.get_list();
				}

				// setTimeout(() => {
				//  this.triggered = false;
				// }, 1000)
			},
			changeUser(item) {
				uni.navigateTo({
					url: "/pages/vehicle_eidt/vehicle_eidt?id=" + item.id,
				});
			},
			click_shaixuan() {
				//点击筛选
				this.show_shaixuan = !this.show_shaixuan;
			},
			// cz
			reset() {
				this.currentPage = 1;
				this.isEnabled = 1
				this.peopleList = []
				this.get_list();
			},
			is_ok_fn(e) { //确认筛选
				this.isEnabled = e
				if (!this.isLoading) {
					this.isLoading = true;
					this.currentPage = 1;
					this.peopleList = [];
					this.get_list();
				}
				this.show_shaixuan = false
			},
			Scrolltolower() {
				if (this.is_no == true) {
					return
				}
				this.currentPage = this.currentPage + 1;
				this.get_list();
			},
			// 搜索
			onSearch(e) {
				if (!this.isLoading) {
					this.isLoading = true;
					this.currentPage = 1;
					this.peopleList = [];
					this.get_list();
				}
			},
			get_list() {
				var url = urlList.getvehiclList + '?key=' + this.serchValue + '&currentPage=' + this.currentPage +
					'&pageSize=' + this.pageSize + '&status=' + this.isEnabled
				https(url, 'GET', '', '').then(res => {
					if(res.tatol==0){
						this.is_no=true
					}
					this.isLoading = false;
					this.triggered = false;
					this.peopleList = res.data.vehicleBaiscList;
					if(res.data.total==0){
						this.is_no=true
					}
				}).catch(err => {
					console.log(err)
				})
			}
		},
	};
</script>
<style lang="scss" scoped>
	/* 隐藏滚动条 */
	::-webkit-scrollbar {
		width: 0;
		height: 0;
		color: transparent;
	}

	#warp {
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;

		.warp_search {
			margin-left: 2%;
			box-sizing: border-box;
			width: 98%;
			background-color: #fff;
			position: relative;
			top: 0rpx;
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: space-between;
			height: 88rpx;
			box-sizing: border-box;

			.top_search {
				width: 660rpx;
			}

			.top_img {
				width: 48rpx;
				height: 48rpx;
				margin-right: 5%;
				display: flex;
				align-items: center;
				justify-content: space-between;

				image {
					width: 48rpx;
					height: 48rpx;
				}
			}

			.search_box {
				position: fixed;
				width: 120rpx;
				top: 88rpx;
				box-shadow: #ebebeb 2px 2px 2px;
				text-align: center;
				background: white;
				border-radius: 10rpx;
				font-size: 24rpx;
				left: 600rpx;
				border: solid 1rpx #ebebeb;
				z-index: 99;

				.search_box_item {
					padding: 10rpx 0;
				}

				.is_ok {
					background: #5597ed;
					color: white;
					border-radius: 10rpx;
				}
			}
		}

		.bottom {
			height: calc(100vh - 88rpx);
			box-sizing: border-box;

			.item {
				font-size: 24rpx;
				padding: 20rpx;
				border-bottom: 2rpx solid #eee;
				display: flex;

				.item_1 {
					flex: 1;
				}

				.item_2 {
					width: 200rpx;
				}

				.item_5 {
					width: 200rpx;
					color: #45b1e2;
				}

				.item_3 {
					width: 80rpx;
					color: #45b1e2;
				}

				.item_4 {
					width: 80rpx;
					color: #eee;

				}
			}
		}

		.top_user {
			width: 94%;
			height: 140rpx;
			margin: 0 auto;
			border-bottom: 1rpx solid #ebebeb;
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: space-between;

			.user_lef_name {
				display: flex;
				flex-direction: column;
				font-size: 36rpx;

				text:nth-child(2) {
					font-size: 28rpx;
					margin-top: 7rpx;
					color: #353535;
				}
			}

			.rig_icon {
				width: 28rpx;
				height: 28rpx;
			}
		}

		.bottomTitle {
			width: 100%;
			height: 100rpx;
			color: #666666;
			font-size: 24rpx;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}
</style>
