<template>
  <div class="dm-tabs el-tabs">
   <div class="el-tabs__header">
    <div class="overflow-hidden">
       <div id="tab-first" @click="$router.push('/mall/'+v.value)" class="el-tabs__item" v-for="(v,i) in tabs" :key="i" :class="{'is-active':v.value === $route.meta.menu}">
        {{v.name === '待发货'?(v.name+'('+total+')'):v.name}}
       </div>
    </div>
   </div>
   <div class="el-tabs__content">
      <router-view></router-view>
   </div>
  </div>
</template>

<script>
import { getNotSendCount } from '@/service/api/mallApi.js';
export default {
  name: "mall",
  data() {
    const vm = this;
    return {
      activeMenu:'',
      tabs:[{name:'优惠券',value:'coupon'},{name:'礼品',value:'gift'},{name:'待发货',value:'goods'}],
      total:0,
    };
  },
  created() {
    this.$store.commit("mutations_breadcrumb", [{ name: "积分商城" }]);
    this.$store.commit("aside_handler", false);
    this.getNotSendCount();
    $bus.$on('refresh-not-send-count',() => {
      this.getNotSendCount();
    });
  },
  methods:{
    async getNotSendCount(){
      let res = await getNotSendCount();
      if (res.errorCode === 0) {
        this.total = res.result;
      }
    }
  }
};
</script>
