<template>
  <div class="more">
    <div class="btn" @click.stop="isShow = !isShow">
      <div class="icon"></div>
    </div>
    <div class="menu-list" v-show="isShow">
      <div class="item" v-if="channelInfo.isSendRed" @click="_sendRed">
        <div class="icon red"></div>
        <span>红包</span>
      </div>
      <div class="item" @click="_wallet">
        <div class="icon wallet"></div>
        <span>提现</span>
      </div>
      <div class="item" @click="_personal">
        <div class="icon personal"></div>
        <span>个人中心</span>
      </div>
      <div class="item" v-if="isQuestionnaire.isEnable" @click="_openQuestionnaire">
        <div class="icon questionnaire"></div>
        <span>问卷报表</span>
      </div>
    </div>
  </div>
</template>
<script>
import { mapGetters } from 'vuex';
export default {
  name: 'vertical-more-box',
  data() {
    return {
      isShow: false
    };
  },
  computed: {
    ...mapGetters({
      channelInfo: 'channelInfo',
      channelConfig: 'channelConfig',
      userInfo: 'userInfo',
      jumpUrls: 'jumpUrls'
    }),
    isQuestionnaire() {
      const info = this.channelConfig.questionnaire || {};
      return info;
    }
  },
  mounted() {
    this.$Bus.$on('bus-remEnclosure', this._remEnclosure);
  },
  methods: {
    _sendRed() {
      if (!this.userInfo.id) {
        this.$layer.msg('请登录');
        this.$Bus.$emit('bus-showLogin', true);
      } else {
        window.location.href = this.jumpUrls.pay_redPacket;
      }
    },
    _wallet() {
      if (!this.userInfo.id) {
        this.$layer.msg('请登录');
        this.$Bus.$emit('bus-showLogin', true);
      } else {
        window.location.href = this.jumpUrls.center_wallet;
      }
    },
    _personal() {
      if (!this.userInfo.id) {
        this.$layer.msg('请登录');
        this.$Bus.$emit('bus-showLogin', true);
      } else {
        window.location.href = this.jumpUrls.center;
      }
    },
    _openQuestionnaire() {
      if (!this.userInfo.id) {
        this.$layer.msg('请登录');
        this.$Bus.$emit('bus-showLogin', true);
      } else {
        this.$Bus.$emit('bus-questionnaire');
      }
    },
    _remEnclosure() {
      this.isShow = false;
    }
  },
  beforeDestroy() {
    this.$Bus.$off('bus-remEnclosure', this._remEnclosure);
  }
};
</script>
<style lang="less" scoped>
.more {
  position: relative;
  z-index: 100;
  width: 0.36rem;
  height: 0.36rem;
  .btn {
    position: relative;
    width: 0.36rem;
    height: 0.36rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 100%;
    .icon {
      width: 100%;
      height: 100%;
      background: url(./img/icon-more.png) no-repeat center center;
      background-size: 0.17rem auto;
    }
  }
  .menu-list {
    position: absolute;
    bottom: calc(100% + 0.1rem);
    right: -0.05rem;
    width: 1.1rem;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 0.04rem;
    .item {
      padding: 0 0.1rem;
      height: 0.4rem;
      line-height: 0.4rem;
      border-top: 1px solid rgba(102, 102, 102, 0.75);
      font-size: 0.12rem;
      color: #fff;
      .icon {
        vertical-align: middle;
        margin-right: 0.08rem;
        display: inline-block;
        width: 0.16rem;
        height: 0.16rem;
        &.red {
          background: url(./img/icon-red.png) no-repeat center center;
          background-size: contain;
        }
        &.wallet {
          background: url(./img/icon-wallet.png) no-repeat center center;
          background-size: contain;
        }
        &.personal {
          background: url(./img/icon-personal.png) no-repeat center center;
          background-size: contain;
        }
        &.questionnaire {
          background: url(./img/icon-questionnaire.png) no-repeat center center;
          background-size: contain;
        }
      }
      &:first-child {
        border-top: 0;
      }
    }
  }
}
</style>
