<template>
  <div>
    <div class="tabBox">
      <div class="tab" v-for="(item,index) in tabArr" :key="index" @click="$emit('tabClick',item)">
        <img :src="item.icon" alt="" />
        <div>{{item.tabName}}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      tabArr: []
    }
  },
  props: {
    isApplet: Boolean
  },
  computed: {
    user () {
      return this.$store.state.user
    },
    pageData () {
      return this.$store.state.pageData
    }
  },
  created () {
    if (this.pageData.remarks.tabArr && this.pageData.remarks.tabArr.length > 0) {
      this.tabArr = this.pageData.remarks.tabArr
      let arr = []
      this.tabArr.forEach(val => {
        // if (val.tabName == '订购记录') {
        //   let obj = {}
        //   obj.tabName = val.tabName
        //   obj.tabUrlBasics = val.tabUrlBasics
        //   obj.tabUrlApplet = val.tabUrlApplet
        //   obj.icon = require("../templates/assets/record.png")
        //   arr.push(obj)
        // }
        if (val.tabName == '流量激活') {
          let obj = {}
          obj.tabName = val.tabName
          obj.tabUrlBasics = val.tabUrlBasics
          obj.tabUrlApplet = val.tabUrlApplet
          obj.icon = require("./img/icon_jihuo.png")
          arr.push(obj)
        } if (val.tabName == '一键反馈') {
          let obj = {}
          obj.tabName = val.tabName
          obj.tabUrlBasics = val.tabUrlBasics
          obj.tabUrlApplet = val.tabUrlApplet
          obj.icon = require("./img/icon_fankui.png")
          arr.push(obj)
        }
        if (val.tabName == '退订产品') {
          let obj = {}
          obj.tabName = val.tabName
          obj.tabUrlBasics = val.tabUrlBasics
          obj.tabUrlApplet = val.tabUrlApplet
          obj.icon = require("./img/icon_tuiding.png")
          arr.push(obj)
        }
        if (val.tabName == '剩余流量查询' && this.isApplet == false) {
          let obj = {}
          obj.tabName = '流量查询'
          obj.tabUrlBasics = val.tabUrlBasics
          obj.tabUrlApplet = val.tabUrlApplet
          obj.icon = require("./img/icon_chaxun.png")
          arr.push(obj)
        }
        if (val.tabName == '会员领取') {
          let obj = {}
          obj.tabName = val.tabName
          obj.tabUrlBasics = val.tabUrlBasics
          obj.tabUrlApplet = val.tabUrlApplet
          obj.icon = require("./img/icon_huiyuan.png")
          arr.push(obj)
        }
      })
      this.tabArr = arr
    } else {
      // if (this.pageData.remarks.jiluBtn === '1') {
      //   let obj = {}
      //   obj.tabUrlBasics = ""
      //   obj.tabUrlApplet = ""
      //   obj.icon = require("../templates/assets/record.png")
      //   obj.tabName = '订购记录'
      //   this.tabArr.push(obj)
      // } 
      if (this.pageData.remarks.jihuoBtn === '1') {
        let obj = {}
        obj.tabUrlBasics = ""
        obj.tabUrlApplet = ""
        obj.icon = require("./img/icon_jihuo.png")
        obj.tabName = '流量激活'
        this.tabArr.push(obj)
      }
      if (this.pageData.remarks.memberBtn === '1') {
        let obj = {}
        obj.tabUrlBasics = ""
        obj.tabUrlApplet = ""
        obj.icon = require("./img/icon_huiyuan.png")
        obj.tabName = '会员领取'
        this.tabArr.push(obj)
      }
      if (this.pageData.remarks.chaxunBtn === '1' && this.isApplet == false) {
        let obj = {}
        obj.tabUrlBasics = ""
        obj.tabUrlApplet = ""
        obj.icon = require("./img/icon_chaxun.png")
        obj.tabName = '流量查询'
        this.tabArr.push(obj)
      }
      if (this.pageData.remarks.guanzhuBtn === '1') {
        let obj = {}
        obj.tabUrlBasics = ""
        obj.tabUrlApplet = ""
        obj.icon = require("./img/icon_fankui.png")
        obj.tabName = '一键反馈'
        this.tabArr.push(obj)
      } if (this.pageData.remarks.tuidingBtn === '1') {
        let obj = {}
        obj.tabUrlBasics = ""
        obj.tabUrlApplet = ""
        obj.icon = require("./img/icon_tuiding.png")
        obj.tabName = '退订产品'
        this.tabArr.push(obj)
      }
    }
  },

}
</script>

<style lang="scss" scoped>
.tabBox {
  // margin: 20px 30px;
  width: 714px;
  margin: 0 auto;
  border-radius: 20px;
  background: #ffffff;
  margin-bottom: 40px;
  display: flex;
  justify-content: space-around;
  // overflow-x: scroll;
  // -webkit-overflow-scrolling: touch;

  .tab {
    width: 115px;
    // margin-right: 21px;
    // margin: 21px 5px;
    text-align: center;
    img {
      width: 62px;
      height: 62px;
      margin-top: 29px;
    }

    div {
      text-align: center;
      font-size: 28px;
      font-weight: 400;
      // font-weight: bold;
      color: #222222;
      margin-top: 21px;
      margin-bottom: 28px;
      // line-height: 28px;
    }
  }
}
</style>