<template>
	<view>
		<my-requiredetail v-if="showDetail" :item="item" :location="location" :marker="marker" :timeAM="timeAM" :timePM="timePM" :timeEvening="timeEvening" :isShowPrivate="isShowPrivate" buttonMessage="新发布" @publishButton="publishButton"></my-requiredetail>
	</view>
</template>

<script>
	import formTime from '@/mixins/form-time.js'
	export default {
		mixins: [formTime],
		data() {
			return {
				showDetail: false,
				isShowPrivate: true,
				item: {},
				location: [],
				marker: [{
					id: 1,
					joinCluster:true,
					latitude: 0,
					longitude: 0,
					width: 40,
					height: 40,
					iconPath: '/static/location.png',
				}],
			};
		},
		onLoad(option) {
			if (option.requireId !== undefined) {
				const requireId = decodeURIComponent(option.requireId)
				this.getStuNeedDetailById(requireId)
			}
		},
		methods: {
			// 获取需求详情
			async getStuNeedDetailById(id) {
				const {data: result} = await uni.$http.get('/education/student-requirements/getPublishStuNeedsDetailById', {requireId: id})
				this.item = result.data.one
				this.formatForm()
			},
			// 上课表格格式化
			formatForm() {
				this.location = this.item.locationAl.split(",")
				this.marker[0].latitude = Number(this.location[0])
				this.marker[0].longitude = Number(this.location[1])
				this.courseWeekday = this.item.courseWeekday.split(",")
				this.parseCourseWeekday()
				this.showDetail = true
			},
			publishButton() {
				uni.navigateTo({
					url:'/subpkg/student/require/student_require_add?item='+encodeURIComponent(JSON.stringify(this.item))
				})
			}
		}
	}
</script>

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

<style lang="scss" scoped>
</style>
