import { getNewsList } from '@/api/Forestage/index.js'
export default {
  data() {
    return {
      list1: [],
      list2: [],
      newsData: {}
    }
  },
  created() {
    this.getNewsList()
    this.$eventBus.$on('langChange', (langType, routePath) => {
      if (routePath === '/Home') {
        this.newsData = this.$langFilter(this.newsData)
        this.list1 = this.newsData.items.filter((item, index) => index <= 1)
        this.list2 = this.newsData.items.filter((item, index) => index > 1 && index < 5)
      }
    })
  },
  methods: {
    getNewsList() {
      getNewsList().then(res => {
        this.newsData = res.data
        this.list1 = res.data.items.filter((item, index) => index <= 1)
        this.list2 = res.data.items.filter((item, index) => index > 1 && index < 5)
      })
    },
    goToUrl(item) {
      this.$router.push({ path: '/NewDetail', query: { id: item.id } })
    }
  },

}