<template>
	<view>
		<my-coursedetail v-if="showDetail" :item="course" :location="location" :marker="marker" :timeAM="timeAM" :timePM="timePM" :timeEvening="timeEvening" buttonMessage="以此为模板新发布" :isShowCollect="false" :isShowPrivate="true" @publishButton="publishButton"></my-coursedetail>
	</view>
</template>

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

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