<template>
    <div>
      <Header></Header>
      <IndexSwiper :swiperList="swiperList" v-if="swiperList.length > 0"></IndexSwiper>
      <div v-for="(newsType, index) in newsTypeList" :key="index">
        <news-view1 :news-directories-parent-id="newsType.newsDirectoriesId" :nav-title="newsType.directoriesName" v-if="newsType.directoriesWebView === 'newsView1'"/>
        <news-view2 :news-directories-parent-id="newsType.newsDirectoriesId" :nav-title="newsType.directoriesName" v-if="newsType.directoriesWebView === 'newsView2'"/>
        <news-view3 :news-directories-parent-id="newsType.newsDirectoriesId" :nav-title="newsType.directoriesName" v-if="newsType.directoriesWebView === 'newsView3'"/>
      </div>
      <IndexService :activityList="activityList" v-if="activityList.length > 0"></IndexService>
      <Footer></Footer>
    </div>
</template>

<script>
import Header from '../..//common/components/Header'
import IndexSwiper from './components/Swiper'
import IndexService from './components/IndexService'
import NewsView1 from './components/NewsView1'
import NewsView2 from './components/NewsView2'
import NewsView3 from './components/NewsView3'
import Footer from '../../common/components/Footer'
import common from '../../common/components/common.js'
import axios from 'axios'

export default {
  name: 'Index',
  components: {
    Header,
    IndexSwiper,
    IndexService,
    NewsView1,
    NewsView2,
    NewsView3,
    Footer
  },
  data () {
    return {
      bannerList: [],
      activityList: [],
      activityPage: {
        page: 1,
        rows: 8
      },
      swiperList: [],
      url: common.url,
      newsTypeList: []
    }
  },
  methods: {
    getNewsTypeList: function () {
      var self = this
      axios.get(`${common.url}app/newsdirectories/list/areaplate/release/${common.area.areaCode}`, {}).then(function (res) {
        self.newsTypeList = res.data
      })
    },
    getActivityList: function () {
      var self = this
      axios.get(self.url + 'app/activitylibrary/listpageactivitylibraryfornetrelease/' + common.area.areaCode, {
        params: self.activityPage
      }).then(function (res) {
        self.activityList = res.data.rows
      })
    },
    // 轮播图
    getSwiper: function () {
      var self = this
      axios.get(self.url + 'app/newscontent/listpagenewscontentrelease/' + common.area.areaCode, {
        params: {
          page: 1,
          rows: 3,
          newsDirectoriesId: 'eab0ca3c-d35d-4c02-9397-ace2bdd10fc1'
        }
      }).then(function (res) {
        for (var i = 0; i < res.data.rows.length; i++) {
          res.data.rows[i].newsContentCoverList = res.data.rows[i].newsContentCoverList[0].contentCoverId
        }
        self.swiperList = res.data.rows
      })
    }
  },
  mounted () {
    this.getNewsTypeList()
    this.getActivityList()
    this.getSwiper()
  }
}
</script>

<style lang="stylus" rel="stylesheet/stylus" scoped>

</style>
