<template>
  <!-- 招生中心 -->
  <div>
    <Project-title></Project-title>
    <Project-content v-bind:menu="menu" @urlChange="updateUrl">
      <div v-html="content"></div>
    </Project-content>
  </div>
</template>

<script>
import ProjectTitle from '../../components/ProjectTitle.vue'
import ProjectContent from '../../components/ProjectContent.vue'
import { introduction } from '../../action/axiosService.js'

export default {
  components: {
    ProjectTitle,
    ProjectContent
  },
  data() {
    return {
      // 这个是传给组件的项目列表
      menu: [
        { name: '报名须知', url: '/know?tag=报名须知' },
        { name: '申请流程', url: '/know?tag=申请流程' },
        { name: '招生简章', url: '/know?tag=招生简章' },
        { name: '学费信息', url: '/know?tag=学费信息' }
      ],
      content: '',
      tag: '报名须知'
    }
  },
  created() {
    let _tag = this.$route.query.tag
    if (_tag) this.tag = _tag
  },
  mounted() {
    const that = this
    introduction({
      tag: that.tag,
      cb: function(obj) {
        that.content = obj
      }
    })
  },
  methods: {
    updateUrl() {
      const that = this
      if (that.tag === that.$route.query.tag) return
      this.tag = this.$route.query.tag
      introduction({
        tag: that.tag,
        cb: function(obj) {
          that.content = obj
        }
      })
    }
  }
}
</script>
<style scoped></style>
