<template>
	<view class="courseWrapper">
		<view v-for="(item, index) in requirement" :key="index">
			<view class="requires" @click="requireDetail(item.courseId)">
				<uni-row class="demo-uni-row">
					<uni-col offset="1">
						<view class="requires-col1">课程号：{{item.courseId}}</view>
					</uni-col>
				</uni-row>
				<uni-row class="demo-uni-row">
					<uni-col offset="1" :span="16">
						<view class="requires-col2">科目：{{item.subject}}</view>
					</uni-col>

				</uni-row>
				<view class="requires-col3">
					<uni-row class="demo-uni-row">
						<uni-col :span="4" offset="1">
							<view style="color: red;">{{item.verifyStatus}}</view>
						</uni-col>
						<uni-col :span="4" >
							<view style="color: red;">{{item.deal}}</view>
						</uni-col>
						<uni-col :span="4" >
							<view style="color: red;">{{item.locked}}</view>
						</uni-col>
						<uni-col :span="4" >
							<view :class="item.display == '已上架' ? 'setdisplaycolorgreen' : 'setdisplaycolorred'"  >
								<view>{{item.display}}</view>
							</view>
						</uni-col>
					</uni-row>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				requirement: []
			}
		},
		onShow() {
			this.getPublishCounts()
		},
		methods: {

			// 查询个人上架了多少课程
			async getPublishCounts() {
				const { data: result } = await uni.$http.get('/education/teacher-courses/showPersonCourse')
				this.publishCount = result.data.publishCounts
				let courses = []
				courses = result.data.list
				
				for (let i = 0; i < courses.length; i++) {
					if (courses[i].display === '上架') {
						courses[i].display = '已上架'

					} else {
						courses[i].display = '已下架'

					}
				}
				this.requirement = courses
			},
			requireDetail(id) {
				uni.redirectTo({
					url: '/subpkg/teacher/course/teacher_course_my_detail?courseId=' 
					+ encodeURIComponent(id)
					+ '&code=' + encodeURIComponent(0)
				})
			},
		}
	}
</script>

<!-- 设置页面背景 -->
<style lang="scss">
	page{
		height: 100%;
		padding: 20rpx;
		// background-color: #FFF;
	}
</style>

<style scoped lang="scss">
	.courseWrapper{
		width: 96%;
		height: 100%;
	}
	.requires {
		background-color: #FFF;
		border: 0px solid #41719C;
		border-radius: 30rpx;
		margin: 10rpx 0 20rpx;
		position: relative;
		font-size: 30rpx;
				
		.requires-col1 {
			margin-top: 15rpx;
		}
		
		.requires-col2 {
			margin: 15rpx 0;
		}
		
		.requires-col3 {
			padding-bottom: 15rpx;
		}
		
		.setdisplaycolorgreen{
			display: flex;
			background-color: #35b882;
			color: #fff;
			border-radius: 40rpx;
			justify-content: center;
		}
		
		.setdisplaycolorred{
			  display: flex;
			background-color: #ff5500;
			color: #fff;
			border-radius: 40rpx;
			justify-content: center;
		}
	}

</style>
