<template>
  <div class="abroad_des">
    <div class="tag_item">
      <div class="content_box">
        <div class="content_all open">
          <p class="tag_text" v-html="detailData.productFeatures + detailData.productDescription + detailData.extraService"></p>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: ['detailData'],
  data() {
    return {
      courseTable: [], //课程表
      active: 0,
      isOpen: true,
      showCourseTable: true,
    }
  },
  mounted() {
    for (let i in this.detailData.courseScheduleList) {
      this.getWeekCard(i)
    }
  },
  methods: {
    // 设置第几天的课程表
    getWeekCard(index) {
      var data = this.detailData.courseScheduleList[index].courseScheduleList
      var morning = []
      var afternoon = []
      var night = []
      data.forEach(function(k, j) {
        if (k.type == 1 && k.content != '') {
          morning.push(k)
        } else if (k.type == 2 && k.content != '') {
          afternoon.push(k)
        } else if (k.type == 3 && k.content != '') {
          night.push(k)
        }
      })
      if (morning.length == 0 && afternoon.length == 0 && night.length == 0) {
        this.showCourseTable = false
      }
      var strMorning = '',
        strAfternoon = '',
        strNight = ''
      if (morning.length > 0) {
        strMorning = `<tr>
								<td class="td_left" rowspan="${morning.length}">上午</td>
								<td style="text-align: left;">${morning[0].content ? morning[0].content : '无安排'}</td>
							</tr>`
        morning.forEach(function(k, j) {
          if (j > 0) {
            strMorning += `<tr>
								<td style="text-align: left;">${k.content ? k.content : '无安排'}</td>
							</tr>`
          }
        })
      }
      if (afternoon.length > 0) {
        strAfternoon = `<tr>
								<td class="td_left" rowspan="${afternoon.length}">下午</td>
								<td style="text-align: left;">${afternoon[0].content ? afternoon[0].content : '无安排'}</td>
							</tr>`
        afternoon.forEach(function(k, j) {
          if (j > 0) {
            strAfternoon += `<tr>
								<td style="text-align: left;">${k.content ? k.content : '无安排'}</td>
							</tr>`
          }
        })
      }
      if (night.length > 0) {
        strNight = `<tr>
								<td class="td_left" rowspan="${night.length}">晚上</td>
								<td style="text-align: left;">${night[0].content ? night[0].content : '无安排'}</td>
							</tr>`
        night.forEach(function(k, j) {
          if (j > 0) {
            strNight += `<tr>
								<td style="text-align: left;">${k.content ? k.content : '无安排'}</td>
							</tr>`
          }
        })
      }
      this.courseTable.push(strMorning + strAfternoon + strNight)
    },
    // 展开关闭院校简介
    extend_btn() {
      this.isOpen = !this.isOpen
    },
  },
}
</script>
