<template>
	<view class="main">
		<u-sticky>
			<view class="searchBox">
				<u-search placeholder="请输入教练姓名" v-model="params.coachName"  :show-action="false" @search="searchFn"> </u-search>
			</view>
		</u-sticky>
		
		<view class="ul">
			<view class="li" v-for="(item,index) in list" :key="index" @click="chooseClick(item)">
				<view class="leftT">{{item.coachName}}</view>
				<view class="rigthT">{{item.mobilePhone}}</view>
			</view>
		</view>
		<u-loadmore :status="status"  v-if="list.length>30" :icon-type="'flower'" />
	</view>
</template>

<script>
	// import learnDrive from '@/api/learnDrive.js'
	export default {
		data() {
			return {
				keyword: '',
				trainingSchoolId: '',
				list: [
					{coachName: '张教练', mobilePhone: '15698236123'}
				],
				params: {
					pageIndex: 1,
					pageSize: 30,
					trainingSchoolId: ''
				},
				status: 'loadmore',
				
			}
		},
		onLoad(options) {
			this.params.trainingSchoolId = options.trainingSchoolId
			this.querySchoolCoachFn()
		},
		
		onReachBottom() {
			if(status=='nomore') return
			this.querySchoolCoachFn()
			
		},
		methods: {
			chooseClick(item) {
				this.$store.commit('upDateCoachItem', item)
				uni.navigateBack()
			},
			searchFn() {
				this.list = []
				this.params.pageIndex = 1
				this.status = 'loadmore'
				this.querySchoolCoachFn()
			},
			// 获取教练
			async querySchoolCoachFn() {
				// const [nulls, res] = await learnDrive.querySchoolCoach(this.params)
				// this.list.push(...res.data)
				// this.params.pageIndex ++
				// if(res.data.length<this.params.pageSize) {
				// 	this.status = 'nomore'
				// }
				// console.log('获取教练')
				// console.log(res)
			},
		}
	}
</script>

<style lang="scss" scoped>
	.main {
		background-color: #f8f8f8;
		.searchBox {
			background-color: #fff;
			padding: 16rpx 32rpx;
		}
	}
	.ul {
		width: 100%;
		border-bottom: 10rpx solid #f8f8f8;
		font-size: 30rpx;
		padding: 0 32rpx;
		color: #333333;
		background-color: #fff;
		.li {
			width: 100%;
			height: 98rpx;
			line-height: 98rpx;
			display: flex;
			font-size: 30rpx;
			justify-content: space-between;
			align-center: center;
			border-bottom: 1px solid #F5F7FA;
		}
	}
</style>