<template>
	<view class="newselecompany_body">
		<view class="newselecompany_tip">请选择司机油卡类型<br />及接收方司机...</view>
		<view style=" overflow: hidden;" class="newselecompany_container ">
			<view class="sele_Bar mar">
				<view :style="{transform:`translateX(calc(${page.params.companyCustomerNature}*100%))`}"
					class="move_item"></view>
				<view @tap="seleBarFn(0)" :style="{color:page.params.companyCustomerNature==0? 'white' : ''}"
					class="sele_Bar_item">外请</view>
				<view @tap="seleBarFn(1)" :style="{color:page.params.companyCustomerNature==1? 'white' : ''}"
					class="sele_Bar_item">自营</view>
			</view>
			<view class="newselecompany_seach mar">
				<view class="newselecompany_seach_title">查找司机</view>
				<view class="newselecompany_seach_input">
					<uni-easyinput prefixIcon="search" confirmType='search' @confirm='seachFn'
						placeholder-style="color:#bbbbbb;font-weight: 100;" v-model="page.params.param"
						placeholder="司机名或司机ID">
					</uni-easyinput>
				</view>
			</view>
			<view style=" overflow: hidden;" class="newselecompany_container_list">
				<view style="flex: 1; margin-top:26rpx;  overflow: hidden; ">
					<scroll-view v-if="list.length!==0" style="height: 100%;overflow: hidden; " scroll-y="true" @scrolltolower='scrolltolower'>
						<view  @click="seleFn(item)" v-for="(item,index) in list"
							class="newselecompany_container_list_item mar">
							<view class="newselecompany_container_list_name">
								<view class="felx acenter">
									<!-- <view class="yuan"></view> -->
									<view>
										<view>{{item.phone}}</view>
										<view>{{item.userName}}</view>
									</view>
								</view>
								<text
									class="newselecompany_container_list_identification">{{item.companyType | companyType}}</text>
							</view>
							<view class="companyDetails">
								<text class="smallText">{{item.accountCardCode}}</text>
								<text v-if="item.shareCompanyQuota=='0'" class="listtext">账户余额 <text
										style="margin-left: 5rpx;font-size: 27rpx;">{{item.balance}}</text> </text>
								<text v-if="item.shareCompanyQuota=='1'" class="newlisttext">共享企业额度</text>
							</view>
						</view>
						
					</scroll-view>
					<view v-if="list.length==0"
						style="width: 100vw; height: 100%; display: flex;align-items: center;justify-content: center;">
						<image src="@/static/qx.png" style="width: 536rpx; height: 399rpx;"></image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import scroll from '@/components/scroll'
	import driverManagement from '@/api/driverManagement'
	export default {
		components: {
			scroll
		},
		data() {
			return {
				barIndex: 0,
				timer: null,
				seachValue: '',
				windowHeight: '',
				lately: [],
				list: [],
				page: {
					pageSize: 15,
					currentPage: 1,
					params: {
						companyCustomerNature: 0,
						companyId: '',
						companyType: '',
						param: ''
					},
					columns: []
				}
			}
		},
		onLoad(e) {
			if (e.jsData) {
				console.log(JSON.parse(e.jsData))
				this.page.params.companyId = JSON.parse(e.jsData).id
				this.page.params.companyType = JSON.parse(e.jsData).companyType
				this.getlist()
			}
		},
		filters: {
			companyType(e) {
				switch (Number(e)) {
					case 0:
						return 'FUEL'
					case 1:
						return 'OIL'
					case 2:
						return 'LNG'
					case 3:
						return 'SCR'
				}
			}
		},
		methods: {
			seleFn(e) {
				clearTimeout(this.timer)
				this.timer = setTimeout(() => {
					console.log(e)
					uni.$emit('driverfn', e)
					uni.navigateBack()
				}, 200)
			},
			getlist() {
				driverManagement.getDriverSelectionListByCompanyId(this.page).then(res => {
					if (res.code !== 20000) return
					if (res.data.list.length == 0) {
						uni.showToast({
							title: '没有数据了哦',
							icon: 'none'
						})
					}
					if (this.page.currentPage !== 1) {
						this.list = this.list.concat(res.data.list);
						return
					}
					this.list = res.data.list
				})
			},
			scrolltolower() {
				this.currentPage += 1
				this.getlist()
			},
			seachFn() {
				this.page.currentPage = 1
				this.getlist()
			},
			seleBarFn(e) {
				this.page.currentPage = 1
				this.page.params.companyCustomerNature = e
				this.getlist()
			}
		}
	}
</script>

<style scoped>
	.newlisttext {
		font-size: 24rpx;
		color: #EBA10F;
		padding: 12rpx 24rpx;
		background: rgba(235, 161, 15, 0.1);
	}

	.acenter {
		align-items: center;
	}

	.felx {
		display: flex;
	}

	.yuan {
		width: 10rpx;
		height: 10rpx;
		background-color: #17A00E;
		margin-right: 10rpx;
		border-radius: 50%;
	}

	.newselecompany_container_list_identification {
		color: #BBBBBB;
		font-size: 48rpx;
		position: absolute;
		right: 0;
		/* top: -21rpx; */
		font-weight: 600;
		line-height: 56rpx;
	}

	.newselecompany_container_list_name {
		margin-top: 21rpx;
		font-size: 28rpx;
		color: #666666;
		display: flex;
		justify-content: space-between;
		position: relative;
	}

	.listtext {
		font-size: 28rpx;
		color: #666666;
	}

	.smallText {
		font-size: 20rpx;
		color: #BBBBBB;
	}

	.companyDetails {
		display: flex;
		justify-content: space-between;
		margin-top: 20rpx;
		align-items: flex-end;
	}

	.newselecompany_container_list_lable {
		font-size: 16rpx;
		width: 80rpx;
		height: 40rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		background-color: #9F43CC;
		color: white;

	}

	.newselecompany_container_list_item {
		background-color: white;
		padding: 20rpx 40rpx;
		border-radius: 15rpx;
		margin-bottom: 20rpx;
	}

	.newselecompany_container_list_tip {
		margin-top: 60rpx;
		font-size: 28rpx;
		color: #BBBBBB;
	}

	.newselecompany_container_list {
		flex: 1;
		display: flex;
		flex-direction: column;
	}

	.newselecompany_seach_input {
		background-color: white;
		overflow: hidden;
		border-radius: 20rpx;
		margin-top: 30rpx;
	}

	.newselecompany_seach_title {
		font-size: 35rpx;
	}

	.newselecompany_seach {
		background-color: #2866FF;
		padding: 40rpx;
		border-radius: 15rpx;
		color: white;
		margin-top: 70rpx;
	}

	.move_item {
		position: absolute;
		left: 10rpx;
		width: calc((100% - 20rpx) / 2);
		height: 60rpx;
		background: #2866FF;
		border-radius: 10rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #999999;
		z-index: 0;
		transition: all .3s;
	}

	.mar {
		margin-left: 42rpx;
		margin-right: 42rpx;
	}

	.sele_Bar_item {
		/* width: 287rpx; */
		flex: 1;
		height: 60rpx;
		/* background: #2866FF; */
		border-radius: 10rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #999999;
		z-index: 1;
		transition: color .4s;
	}

	.sele_Bar {
		/* background-color: #18B566; */
		/* margin: 31rpx 40rpx; */
		padding: 10rpx;
		display: flex;
		position: relative;
		background-color: #FFFFFF;
		border-radius: 10px;
	}

	.newselecompany_container {
		flex: 1;
		/* padding: 0 42rpx; */
		display: flex;
		flex-direction: column;
	}

	.newselecompany_tip {
		font-size: 48rpx;
		color: #666666;
		margin-top: 100rpx;
		margin-left: 70rpx;
		margin-bottom: 70rpx;
	}

	.newselecompany_body {
		width: 100%;
		height: calc(100vh - var(--status-bar-height));
		display: flex;
		flex-direction: column;
		position: relative;
		/* overflow: hidden; */
	}
</style>
