<template>
	<view class="requireWrapper">
		<view v-for="(item, index) in requirement" :key="index">
			<view class="requires" @click="requireDetail(item)">
				<uni-row class="demo-uni-row">
					<uni-col offset="1">
						<view class="requires-col1">需求号：{{item.requireId}}</view>
					</uni-col>

				</uni-row>
				<uni-row class="requires-col3">
					<uni-col offset="1" :span="16">
						<view class="requires-col2">科目：{{item.subjectBig}}{{item.subjectSmall}}</view>
					</uni-col>
			           <uni-col :span="7">
							<view class="requires-col22">{{item.salary}}元/节</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>
	import { mapState, mapMutations } from 'vuex'
	
	export default {
		data() {
			return {
				requirement: [],	// 需求列表
				//publishCount: 0,	// 上架数量
				//showMessage: '上架成功',
				//popupType: 'success'
			};
		},
		onShow() {
			this.getPublishCounts()
		},
		methods: {

			// 查询个人上架了多少课程
			async getPublishCounts() {
				const { data: result } = await uni.$http.get('/education/student-requirements/getPublishCounts')
				
			// //	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 = '下架'
				// 		courses[i].buttonType = 'warn'
				// 	} else {
				// 		courses[i].display = '上架'
				// 		courses[i].buttonType = 'primary'
				// 	}
				// }
				this.requirement = result.data.list
				//console.log(this.requirement)
			},
			
			requireDetail(item) {
				uni.redirectTo({
					url: '/subpkg/student/require/student_require_my_detail?requireId=' 
					+ encodeURIComponent(item.requireId)
					+ '&code=' + encodeURIComponent(0)
				})
			},

		}
	}
</script>

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

<style lang="scss" scoped>
.requireWrapper{
		width: 96%;
		height: 100%;
	}
	
.requires {
	background-color: #FFF;
	border-radius: 30rpx;
	margin: 10rpx 0 20rpx;
	position: relative;
	font-size: 30rpx;
	
	.requires-col1 {
		margin-top: 15rpx;
	}
	
	.requires-col2 {
		margin: 15rpx 0;
	}
	.requires-col22 {
		margin: 15rpx 0;
	}
	
	.requires-col3 {
		padding-bottom: 15rpx;
	}
	
	// button{
	// 	position: absolute;
	// 	right: 40rpx;
	// 	top: 30rpx;
	// 	font-size: 30rpx;
	// 		border-radius: 40rpx;
	// 		background-color: #35b882;
	// 		//font-weight: bold;
	// 		color: #FFF;
	// 		//padding: 10rpx;
	
	// }
}
		.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>
