<!--
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2019-11-12 10:59:45
 * @LastEditors  : 无尘
 * @LastEditTime : 2020-01-09 09:57:52
 -->
<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" -->

        <in-progress-active></in-progress-active>
        <!-- <div class="separator-space">- 当前有未开始的活动 -</div>
        <will-start-active></will-start-active> -->

        <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 willStartActive from '@/components/active/will-start-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,
    // willStartActive
  },
  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
          });
        });
    },
    /**
     *   是否可以创建活动
     */
    judgePay() {
      const that = this;
      let para = {};
      getRequest('/sharing-core-web/get-open-enterprise', para)
        .then(res => {
          let resData = res.data;
          if (resData.errorCode == 1) {
            if (resData.result) {
              return false;
            }else {
              that.$router.push('/leaflets');
            }
            return false;
          }
          errMsg.errorMsg(resData);
        })
        .catch(function(error) {
          that.$message.error({
            duration: 1000,
            message: error.message
          });
        });
    }
  },
  beforeMount() {
    const that = this;
    that.judgePay();
  },
  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>
