<template>
    <div>
      <Header></Header>
      <IndexSwiper :swiperList="swiperList"></IndexSwiper>
      <Dynamic :dynamic="dynamic"></Dynamic>
      <IndexService :activityList="activityList"></IndexService>
      <DigitalResource :literature="literature"></DigitalResource>
      <IndexVideo :exhibition="exhibition"></IndexVideo>
      <Footer></Footer>
    </div>
</template>

<script>
import Header from '@/common/components/Header'
import IndexSwiper from './components/Swiper'
import Dynamic from './components/IndexDynamic'
import IndexService from './components/IndexService'
import IndexSpecialties from './components/IndexSpecialties'
import DigitalResource from './components/DigitalResource'
import IndexVideo from './components/IndexVideo'
import Footer from '@/common/components/Footer'
import axios from 'axios'
import common from '@/common/components/common.js'
export default {
  name: 'Index',
  components: {
    Header,
    IndexSwiper,
    Dynamic,
    IndexService,
    IndexSpecialties,
    DigitalResource,
    IndexVideo,
    Footer
  },
  data () {
    return {
      bannerList: [],
      dynamic: {
        picNews: {},
        news: []
      },
      activityList: [],
      specialties: [],
      exhibition: [],
      literature: [],
      dynamicsPage: {
        page: 1,
        rows: 5
      },
      activityPage: {
        page: 1,
        rows: 8
      },
      exhibitionPage: {
        page: 1,
        rows: 8,
        totalPage: 1,
        newsDirectoriesId: 'f1d5d313-f728-4dda-9843-1116d97e17b0'
      },
      swiperList: [],
      url: common.url
    }
  },
  methods: {
    getDynamicsList: function () {
      var self = this
      axios.get(self.url + 'news/app/newscontent/listpagenewscontentrelease', {
        params: self.dynamicsPage
      }).then(function (res) {
        var picNews = res.data.rows.splice(0, 1)[0]
        picNews.newsContentCoverList = picNews.newsContentCoverList[0].contentCoverId
        for (var i = 0; i < res.data.rows.length; i++) {
          var date = res.data.rows[i].newsContentPublishTime.split('-')[2]
          self.$set(res.data.rows[i], 'date', date)
          res.data.rows[i].newsContentPublishTime = res.data.rows[i].newsContentPublishTime.split('-')[0] + '-' + res.data.rows[i].newsContentPublishTime.split('-')[1]
        }
        var result = {
          picNews: picNews,
          news: res.data.rows
        }
        self.dynamic = result
      })
    },
    getActivityList: function () {
      var self = this
      axios.get(self.url + 'culturalactivity/app/activitylibrary/listpageactivitylibraryfornetrelease', {
        params: self.activityPage
      }).then(function (res) {
        self.activityList = res.data.rows
      })
    },
    getLiterature: function () {
      var self = this
      axios.get(self.url + 'library/app/intangiblelibrarydata/listpageintangiblelibrarydatarelease/48204626-2593-4ab7-9dda-4d6314c12556', {
        params: self.activityPage
      }).then(function (res) {
        self.literature = res.data.rows
      })
    },
    getExhibition: function () {
      var self = this
      axios.get(self.url + 'news/app/newscontent/listpagenewscontentrelease', {
        params: self.exhibitionPage
      }).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.exhibition = res.data.rows
      })
    },
    getSwiper: function () {
      var self = this
      axios.get(self.url + 'news/app/newscontent/listpagenewscontentrelease', {
        params: {
          page: 1,
          rows: 3,
          newsDirectoriesParentId: '51ae7beb-f277-47a4-937a-088e6d47656d'
        }
      }).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.getDynamicsList()
    this.getActivityList()
    this.getLiterature()
    this.getExhibition()
    this.getSwiper()
  }
}
</script>

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

</style>
