<template>
  <el-tabs v-model="tabActive" type="card" class="market-tabs">
    <el-tab-pane label="图文素材消息" name="first">
      <materia-list :imgList="imgList" @sendid="handleId"></materia-list>
      <push-detail></push-detail>
      <material-details v-if="materialChartList&&materialChartList.length" :datalist="datalist" :MediaSummary="MediaSummary" :materialChartList="materialChartList"></material-details>
      <article-details v-if="articleChartList&&articleChartList.length" :datalist="datalist"></article-details>
    </el-tab-pane>
    <el-tab-pane label="营销模版消息" name="second">
      <temp-list></temp-list>
    </el-tab-pane>
    <el-tab-pane label="短信营销消息" name="third">表格</el-tab-pane>
  </el-tabs>
</template>
<script>
import MateriaList from './MateriaList'
import PushDetail from './PushList'
import MaterialDetails from './MaterialDetails'
import ArticleDetails from './ArticleDetails'
import TempList from './TempList'

export default {
  data () {
    return {
      tabActive: 'first',
      imgList: [],
      mediaId: '',
      datalist: [],
      MediaSummary: {},
      articleChartList: [],
      materialChartList: []
    }
  },
  components: {
    PushDetail,
    MateriaList,
    MaterialDetails,
    ArticleDetails,
    TempList
  },
  created () {
    this.getDataList()
  },
  methods: {
    // 图文素材
    getDataList () {
      this.axios
      // .post('/materials-list', {
        .post('http://rap2api.taobao.org/app/mock/115626/materials-list', {
          pageNo: 1,
          pageSize: 10
        })
        .then(res => {
          if (res && res.data && res.data.code === 0) {
            res.data.result.result.forEach(item => {
              this.imgList = item.content.news_item
            })
            localStorage.materList = JSON.stringify(this.imgList)
          }
        })
    },
    // 素材详情
    GetMaterianDatail (id = this.mediaId) {
      this.axios
        .get('/static/getarticlesummary.json', {
          mediaId: id
        })
        .then(res => {
          // 文章流量分析
          this.datalist = res.data.result.mediaGetarticle
          // 文章单日流量分析
          this.datalist.forEach(item => {
            this.articleChartList = item.mediaGetarticles.reverse()
          })
          // 素材总流量分析
          this.MediaSummary = res.data.result.wechatMediaSummary
          // 素材单日流量分析
          this.materialChartList = res.data.result.wechatMediaSummary.mediaGetarticles.reverse()
        })
    },
    handleId (params) {
      this.mediaId = params
      this.GetMaterianDatail()
    }
  }
}
</script>
<style lang="stylus" scoped>
.market-tabs
  >>>.el-tabs__nav
    margin-left 36px
    border none
    background-color transparent
  >>>.el-tabs__item
    color rgb(115, 135, 156)
    border 1px solid #e4e7ed
    margin-right 10px
    background-color #e4e7ed
    border-radius 4px
  >>>.el-tabs__item:hover
    color #000
  >>>.el-tabs__item.is-active
    background #fff
    color #000
    border-right 5px solid #e4e7ed
    border-bottom 1px solid #e4e7ed
  >>>.el-tabs__item:first-child
    border-left 2px solid #e4e7ed
  >>>.el-tabs__header
    border none
  >>>.el-tabs__nav .el-tabs__item
    margin-right 12px
</style>
