<template>
	<view class="content">
		<view class="top-">
			<u-search @change="changeInput" placeholder="搜索" v-model="keyword"></u-search>
		</view>

		<view class="tab-box">
			<view :class="{ 'acv':tabindex == item.id }" v-for="(item,index) in tablist" :key="index"
				@click="getindex(item.id)">
				{{item.name}}
			</view>
		</view>

		<view class="box_" v-for="(item,index) in cadetList.rows" :key="index " @click="goDetails(item.userId)">
			<view style="display: flex;justify-content: space-between;align-items: center;">
				<view class="d-s">
					<view class="touxiang">
						<image :src="imagesUrl + item.vactor" mode=""></image>
					</view>
					<view class="">
						<view class="name_">{{item.name}}</view>
						<view class="tel_">{{item.phone}}</view>
					</view>

				</view>
				<view style="color: #009905;">
					{{item.courseName}}
				</view>
			</view>

			<view class="b-s">
				<view class="w-d-s">
					<view class="hui_">教学教练：</view>

					<view class="hei_">{{item.jlName}}</view>
				</view>

				<view class="w-d-s">
					<view class="hui_">入学时间：</view>

					<view class="hei_">{{item.createTime}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import request from "@/utils/request.js"
	import {
		imagesUrl
	} from "@/config.js"
	export default {
		data() {
			return {
				tabindex: 2,
				tablist: [{
						name: "可练科二",
						id: 2
					},
					{
						name: "可练科三",
						id: 3
					},
				],
				keyword: '',

				cadetList: []
			}
		},
		onShow() {
			this.findCadetList()
		},
		onPullDownRefresh() {
			console.log("刷新");
			uni.stopPullDownRefresh()
		},
		onReachBottom() {
			// this.show = true
			setTimeout(() => {
				console.log("加载执行");
			}, 2000)
		},

		methods: {
			async getindex(id) {
				this.tabindex = id
				if (id == 2) {
					let res = await request({
						url: '/system/pay/stuListByCoachId?type=2',
						method: 'get',
					})
					this.cadetList = res
				}
				if (id == 3) {
					let res = await request({
						url: '/system/pay/stuListByCoachId?type=3',
						method: 'get',
					})
					this.cadetList = res
				}

			},
			async changeInput() {
				if (this.keyword) {
					let res = await request({
						url: `/system/pay/stuList?name=${this.keyword}`,
						method: 'get'
					})
					this.cadetList = res
				} else {
					this.findCadetList()
				}
			},
			async findCadetList() {
				let res = await request({
					url: '/system/pay/stuListByCoachId',
					method: 'get'
				})
				this.cadetList = res
			},
			goDetails(userId) {
				uni.navigateTo({
					url: `/pages/index/cadetDetails?userId=${userId}`
				})
			},
			goback() {
				uni.navigateBack()
			}
		}
	}
</script>

<style scoped lang="scss">
	.content {
		width: 100%;
		background: #f4f5f6;
		height: 100vh;
	}

	.container {
		width: 100%;
		background: #f4f5f6;
		box-sizing: border-box;
		padding-top: 88px;
	}

	.top- {
		width: 100%;

		height: 50px;
		background: #FFFFFF;
		box-sizing: border-box;
		padding: 10px 15px;

	}

	.box_ {
		width: 95%;
		margin: 15px auto;
		background: #FFFFFF;
		border-radius: 8px;
		box-sizing: border-box;
		padding: 15px;

	}

	.d-s {
		display: flex;
		align-items: center;
	}

	.touxiang {
		width: 46px;
		height: 46px;
		overflow: hidden;
		border-radius: 50%;
		margin-right: 10px;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.name_ {
		font-weight: bold;
		font-size: 16px;
		color: #333333;
	}

	.tel_ {
		font-size: 14px;
		color: #999999;
	}

	.g_ {
		width: 95%;
		margin: 10px auto;
	}

	.b-s {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.w-d-s {
		width: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-top: 15px;


	}

	.hui_ {
		width: 40%;
		font-weight: 400;
		font-size: 12px;
		color: #999999;
		margin-right: 10px;
	}

	.hei_ {
		width: 60%;
		font-weight: 400;
		font-size: 12px;
		color: #333333;
	}

	.tab-box {
		width: 95%;
		margin: 15px auto;
		display: flex;
		align-items: center;
		justify-content: space-around;
	}

	.tabbox {
		text-align: center;
	}

	.acv {
		color: #41a863 !important;
		font-weight: bold;
	}
</style>