<style>
	.teacherOrderList .order_Content {
		width: 100%;
		height:100%;
		padding-top:15px;
		background-color: #F3F5F7;
	}

	.teacherOrderList .teacherOrder_List {
		width: 94%;
		padding:10px 15px;
		margin:0 auto 10px;
		background-color: #fff;
		border-radius:10px;
		position: relative;
	}
	.teacherOrderList .student_Title{
		display: flex;
		justify-content: space-between;
		border-bottom:1px solid #EFEEEB;
		align-items: center;
		padding-bottom:10px;
	}
	.teacherOrderList .teacher_ClassName{
		width:130px;
		color:#111111;
		font-size:14px;
		overflow: hidden;
		text-overflow:ellipsis;
		white-space: nowrap;
		margin-left:20px;
		font-weight: bold;
	}
	.teacherOrderList .teacherName{
		color:#111111;
		font-size:14px;
		margin-left:5px;
	}
	.teacherOrderList .stu_tookie{
		font-size:12px;
	}
	.teacherOrderList .stu_Dian{
		color:gray;
		margin:-6px 10px 0 10px;
	}
	.teacherOrderList .stu_StutasImg{
		width:22px;
		height:36px;
		position: absolute;
		left:10px;
		top:-4px;
	}
</style>
<template>
	<view class="quick-box teacherOrderList" style="height:100vh;background:#F3F5F7;">
		<view class="course-head">
			<u-tabs name="Name" :list="headData" v-if="headData&&headData.length>1" :is-scroll="false" :current="current" :bar-width="80" :font-size="28"
			 :active-color="mainColor" :bold="false" @change="getChild"></u-tabs>
		</view>
		<u-empty v-if="dataList.length==0" text="暂无数据" mode="data"></u-empty>
 		<scroll-view v-else :scroll-y="true" style="background-color: #f0f4f7;" :enable-back-to-top="true" :enable-flex="true"
		 @scrolltolower="lower" :style="{ 'height': `calc(100% - ${scrollHeight})`}">
			<view class="order_Content">
				<view class="teacherOrder_List" v-for="(item,index) in dataList" :key="index" @click="goDetail(item)">
					<image src="../../../static/images/dzf.png" class="stu_StutasImg"></image>
					<view class="student_Title">
						<view class="teacher_ClassName">{{item.CourseName}}</view>
						<view style="font-size: 13px;color: #12D9B0;" v-if="item.ConfirmNum>0">未确认{{item.ConfirmNum}}人</view>
						<!-- <text v-if="item.OrderStaus==2" style="color:#4699FC;">待确认</text>
						<text v-if="item.OrderStaus==3" style="color:#BBA16B;">待上课</text>
						<text v-if="item.OrderStaus==4" style="color:#969696;">完成</text> -->
					</view>	
					<view style="display: flex;align-items: center;margin:15px 0 8px 0;">
						<view style="display:flex;align-items: center;">
							<text class="teacherName">报名{{item.OrderNum}}</text>人
						</view>
						<view class="stu_tookie" style="display: flex;align-items: center;margin:3px 0 0 20px;">
							<image style="width:12px;height:12px;margin-right:3px;" src="../../../static/images/tookie.png" alt=""></image>
							{{item.StudyDate}} ({{item.StudyDuration}}{{item.DurationUnit}})
							<text class="stu_Dian">.</text>{{item.CourseClassTypeName}}<text class="stu_Dian">.</text>
						</view>
					</view>
				</view>
				<view style="padding:10px 0;">
					<u-loadmore :status="status" :load-text="loadText" :font-size="24" :margin-top="0" :margin-bottom="0" bg-color="#f0f4f7" />
				</view>
			</view>
		</scroll-view>
		<auth v-if="showAuth" @changeuserinfo="reloadUserinfo" @gbAuth='gbAuth'></auth>
	</view>
</template>
<script>
	import auth from "@/components/auth/index";
	import tabbar from "@/components/tabbar/index";
	export default {
		components: {
			auth
		},
		data() {
			return {
				pageTitle: "约课列表",
				loading: true,
				mainColor: "",
				u: {},
				scrollHeight: 0,
				pageCount: 1,
				loadText: {
					loadmore: "轻轻上拉，加载更多",
					loading: "努力加载中",
					nomore: "没有更多了",
				},
				msg:{
					pageIndex:1,
					pageSize:5,
					CourseStudyState:0
				},
				headData:[{
					Name:'不限',
					Id:0
				},{
					Name:'未上课',
					Id:1
				},{
					Name:'已上课',
					Id:2
				}],
				current: 0,
				//内容数据
				dataList: [],
				index: 0,
				showAuth:false,
			};
		},
		created() {
			this.mainColor = this.$uiConfig.mainColor;
		},
		mounted() {
			let currentPages = getCurrentPages();
			let u = "/" + currentPages[currentPages.length - 1].route;
			let pages = wx.getStorageSync("basedata") ?
				wx.getStorageSync("basedata").bar_title : [];
			pages.forEach((x) => {
				if (x.value == u) {
					this.pageTitle = x.new_name ? x.new_name : x.name;
				}
			});
			uni.setNavigationBarTitle({
				title: this.pageTitle,
			});
			setTimeout(() => {
				this.getHeadHeight();
			}, 1000);
		},
		onLoad(option) {
			this.u = uni.getStorageSync("mall_UserInfo");
			if (!this.u) {
				this.u = {
					nickName: "未登录",
					avatarUrl: ""
				};
				this.showAuth = true;
			} else {
				this.current = option.status || 0;
				this.getContent(1);
			}
		},
		methods: {
			reloadUserinfo() {
				this.u = uni.getStorageSync("mall_UserInfo");
				// this.showAuth=false;
				this.getContent();
			},
			//关闭登录窗口
			gbAuth() {
				uni.navigateBack()
			},
			getHeadHeight() {
				let that = this;
				const query = uni.createSelectorQuery().in(this);
				query
					.select(".course-head")
					.boundingClientRect((data) => {
						that.scrollHeight = data.height + "px";
					})
					.exec();
			},
			//获取列表数据
			getContent(num){
				if (num == 1) {
					this.dataList = [];
				}
				uni.showLoading({
					title: '加载中'
				});
				this.request2({
						url: "/api/AppletPoint/GetPointTeacherCoursePageList",
						data: this.msg,
					},
					(res) => {
						uni.hideLoading();
						if (res.resultCode == 1) {
							console.log(res,'数据来也');
							this.dataList = this.dataList.concat(res.data.pageData);
							this.pageCount = res.data.pageCount;
					    }
					}
				);
			},
			//点击头部切换
			getChild(i) {
				this.current = i;
				this.msg.CourseStudyState = this.headData[this.current].Id;
				this.getContent(1);
			},
			
			//滚动加载
			lower(e) {
				if (this.msg.pageIndex < this.pageCount) {
					this.msg.pageIndex++;
					this.status = "loading";
					this.getContent();
				} else {
					this.status = "nomore";
				}
			},
			
			//跳转到详情
			goDetail(item){
				uni.navigateTo({ url: '/pages/appointment/personal/teacherOrderInfo?ID='+item.ID})
			},
		},
	};
</script>
