<template>
	<view  style="height: 100vh; width: 100vw; display: flex;flex-direction: column;" @click="ejectOpen=false">
		<view class="seach_body">
			<view class="seach_content">
				<uni-easyinput
				:candidate='candidate'
				 :ejectOpen='ejectOpen'
				 @ejectFn='ejectFn' 
				 :letfText='letfText'
				 confirmType='search' 
				 @confirm='seachFn'
				 placeholder-style="color:#bbbbbb;font-weight: 100;" 
				 v-model="getData.params.param"
				 placeholder="司机姓名、司机ID、电话号码"
				 @iconClick="onClick"
				 >
				</uni-easyinput>
			</view>
		</view>
			<scroll-view v-if="listData.length!==0" class="seledriverList" style="" scroll-y="true" @scrolltolower='scrolltolower'>
				<view v-for="(item,index) in listData"  class="form_body">
					<view @tap="seleFn(item)" class="form_body_item">
						<view class="form_body_item_body">
							<view class="form-item_body_left" style="">
								<image v-if="item.headPhoto" :src="item.headPhoto" style="width: 100rpx; height: 100rpx;border-radius: 50%;"></image>
								<image v-if="!item.headPhoto"  src="../../static/tx.png" style="width: 100rpx; height: 100rpx;border-radius: 50%;"></image>
								<view class="form_body_item_body_container">
									<view style="display: flex; justify-content: space-between;">
									<view>{{item.userName?item.userName:'未设置'}}</view>
									<view class="form-item_body_right" style="">
										<view  :class="item.globalEnable==0?'seletypeyuan':'typeyuan'"></view>
										{{item.globalEnable==0?'禁用':'启用'}}
									</view>
									</view>
									<view style="display: flex;justify-content: space-between; margin-top: 20rpx;">
										<view>{{item.phone}}</view>
										<view class="form-item_body_right" >
											账户余额:{{item.balance}}
										</view>
									</view>
								</view>
							</view>
							
						</view>
						<view class="form_body_item_footer">
							<view>{{item.id}}</view>
						</view>
					</view>
				</view>
			</scroll-view>
		<view v-if="listData.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>
</template>

<script>
	import addDirver from '@/api/addDirver'
	export default {
		data() {
			return {
				listData:[],
				timer:null,
				getData: {
					pageSize: 15,
					currentPage: 1,
					params: {
						companyCustomerNature: 1,
						companyId: '',
						param:''
					}
				},
				ejectOpen: false,
				letfText: '自营',
				candidate:['自营','外请']
			}
		},
		onLoad(e) {
			this.barheight = uni.getSystemInfoSync().statusBarHeight+45
			if(e.jsData){
				console.log(JSON.parse(e.jsData))
				this.getData.params.companyId = JSON.parse(e.jsData).id
				this.getlist()
			}
		},
		methods: {
			seleFn(e){
				clearTimeout(this.timer)
				this.timer = setTimeout(()=>{
					console.log(e)
					uni.$emit('driverfn', e )
					uni.navigateBack()
				},500)
			},
			getlist(){
				addDirver.getDriverSelectionList(this.getData).then(res=>{
					if(res.code!==20000)return
					if(res.data.list.length==0){
						uni.showToast({
							title:'没有数据了哦',
							icon:'none'
						})
					}
					if(this.getData.currentPage!==1){
						this.listData = this.listData.concat(res.data.list);
						console.log(this.listData,'*-*--*')
						return
					}
					this.listData = res.data.list
					console.log(this.listData,'*-*--*')
				})
			},
			scrolltolower(){
				this.getData.currentPage+=1
				console.log('触底了')
				this.getlist()
			},
			onClick() {
				this.ejectOpen = !this.ejectOpen
				console.log('点击图标事件')
			},
			seachFn() {
				this.getlist()
			},
			ejectFn(e) {
				this.letfText = e
				this.getData.params.companyCustomerNature =  this.letfText=='自营'? 1:0
				this.getlist()
				console.log(e,this.getData.params.companyCustomerNature)
			},
		}
	}
</script>

<style>
	.typeyuan{
			background-color: #17A00E;
			width: 14rpx;
			height: 14rpx;
			border-radius: 50px;
			margin-right: 6rpx;
		}
	.seletypeyuan{
		background-color: red;
		width: 14rpx;
		height: 14rpx;
		border-radius: 50px;
		margin-right: 6rpx;
	}
	.form_body_item_footer {
		display: flex;
		color: #BBBBBB;
		font-size: 22rpx;
		justify-content: space-between;
		/* margin-top: 15rpx; */
		align-items: center;
		flex: 1;
	}
	.form-item_body_right {
		
		text-align: end;
		color: #999999;
		font-size: 24rpx;
		    height: max-content;
		    display: flex;
		    justify-content: flex-end;
		    align-items: center;
	}
	.form-item_body_left_bottom_text {
		font-size: 24rpx;
		color: #999999;
	}
	.form_body_item_body_container {
		margin-left: 24rpx;
		font-size: 28rpx;
		flex: 1;
	}
	.form-item_body_left {
		display: flex;
		align-items: center;
		flex: 1;
	}
	.form_body_item_body {
		display: flex;
		/* height: 100rpx; */
		border-bottom: 1rpx solid #F0F0F0;
		padding-bottom: 31rpx;
	}
	.form_body_item {
		height: 217rpx;
		background: #FFFFFF;
		box-shadow: 0px 3px 9px 0px rgba(88, 88, 88, 0.2);
		border-radius: 12rpx;
		font-size: 28rpx;
		padding: 20rpx;
		display: flex;
		flex-direction: column;
		padding-bottom: 0;
	}
	.form_body {
		width: 100vw;
		padding: 0 10px;
		margin-top: 40rpx;
		box-sizing: border-box;
	}
	.seledriverListItem{
		height: 200rpx;
		background: #FFFFFF;
		box-shadow: 0px 3px 9px 0px rgba(88, 88, 88, 0.2);
		border-radius: 12rpx;
		padding: 23rpx 20rpx;
	}
	.seledriverList{
		/* height: 500rpx; */
		flex-grow: 1;
		overflow: auto;
		
	}
	.seach_content{
		background-color: #FFFFFF;
		border-radius: 8rpx;
	}
.seach_body{
	background-color: #2866FF;
	padding: 30rpx 40rpx;
	width: 100vw;
}
</style>
