<template>
  <div class="new-box">
    <tap class="child-tabs" :menu="data" @changeChildTab="changeChildTab"></tap>
    <div class="new-items" v-if="data[dataIndex]">
      <template v-if="data[0].type != 'list'">
        <div class="no-data" v-if="data[dataIndex].content == ''">暂无数据</div>
        <div v-html="data[dataIndex].content"></div>
        <div class="right-img">
          <div class="img-box">
            <img :src="data[dataIndex].image" alt="" class="photo">
            <div class="line"></div>
          </div>
          <slot name="imgBtn"></slot>
        </div>
      </template>
      <template v-else>
        <slot name="list"></slot>
      </template>
    </div>
  </div>
</template>
<script>
import tap from './tab/changeTab.vue'
export default {
  props: {
    data: {
      type: Array,
      default: {}
    },
    defaultPage: {
      type: Number,
      default: 0
    }
  },
  components: {
    tap,
  },
  data() {
    return {
      dataIndex: 0
    }
  },
  mounted() {
  },
  methods: {
    changeChildTab(index) {
      this.$emit('changeIndex', index)
      this.dataIndex = index
      this.$forceUpdate()
    }
  }
}
</script>
<style lang="scss" scoped>
.no-data{
  width: 100%;
  text-align: center;
  color: #999;
  font-size: 26px;
}
.new-box{
  width: 100%;
}
.child-tabs{
  width: 670px;
  margin-bottom: 40px;
}
.new-items{
  display: flex;
  .img-box{
    position: relative;
    margin-left: 15px;
  }
  .right-img{
    position: relative;
    margin-left: auto;
    .line{
      position: absolute;
      top: 35px;
      left: -15px;
      width: 213px;
      height: 280px;
      border: 1px solid #979797;
    }
    .photo{
      position: relative;
      z-index: 9;
      width: 235px;
      height: 300px;
      display: flex;
      position: relative;
    }
  }
}
</style>
