<!--
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2019-11-12 10:59:45
 * @LastEditors: 无尘
 * @LastEditTime: 2019-11-26 14:23:30
 -->
<template>
  <div class="share-index common-wrap">
    <div class="right-content border-box">
      <div v-if="canCreate">
        <div class="separator-space no-active">
          - 当前无进行中的活动，请创建活动，别让业绩白白流失！-
        </div>
        <active-select></active-select>
      </div>
      <div>
        <!-- v-if="!canCreate" -->
        <div class="separator-space">- 当前有正在进行的活动，无法创建新的活动 -</div>
        <in-progress-active></in-progress-active>
        <div class="separator-space">- 以下为已结束活动 -</div>
        <finished-active></finished-active>
      </div>
    </div>
    <vue-gic-footer></vue-gic-footer>
  </div>
</template>
<script>
import activeSelect from '@/components/active/active-select.vue';
import inProgressActive from '@/components/active/in-progress-active.vue';
import finishedActive from '@/components/active/finished-active.vue';
// import showMsg from '@/common/js/showmsg';
import errMsg from '@/common/js/error';
import { getRequest } from '@/api/api';
export default {
  name: 'share-index',
  components: {
    activeSelect,
    inProgressActive,
    finishedActive
  },
  data() {
    return {
      canCreate: true
    };
  },
  methods: {
    /**
     *   是否可以创建活动
     */
    judgeCreate() {
      const that = this;
      let para = {};
      getRequest('/sharing-core-web/can-create', para)
        .then(res => {
          let resData = res.data;
          if (resData.errorCode == 1) {
            that.canCreate = resData.result;
            return false;
          }
          errMsg.errorMsg(resData);
        })
        .catch(function(error) {
          that.$message.error({
            duration: 1000,
            message: error.message
          });
        });
    }
  },
  mounted() {
    const that = this;
    that.judgeCreate();
  }
};
</script>
<style lang="less" scoped>
.share-index {
  .separator-space {
    width: 100%;
    height: 60px;
    line-height: 60px;
    text-align: center;
    font-size: 14px;
    color: #909399;
    font-weight: 600;
    &.no-active {
      height: 40px;
      line-height: 20px;
    }
  }
}
</style>
