<template>
  <div class="invite" @click="go">
    <div class="btn">
      <div class="icon"></div>
    </div>
    <div class="title">邀请</div>
  </div>
</template>
<script>
import { mapGetters } from 'vuex';

export default {
  name: 'suspension-invite',
  data() {
    return {
      info: {}
    };
  },
  computed: {
    ...mapGetters({
      type: 'type',
      userInfo: 'userInfo',
      channelInfo: 'channelInfo'
    })
  },
  methods: {
    go() {
      if (!this.userInfo.id) {
        this.$layer.msg('请先登录');
        this.$Bus.$emit('bus-showLogin', true);
      } else {
        const uin = this.channelInfo.uin;
        const channelId = this.channelInfo.id;
        const type = this.type;
        const watchUrl = `${window.location.origin}${window.location.pathname}?uin=${uin}`;
        window.location.href = `/invite/?id=${channelId}&uin=${uin}&type=${type}&watchUrl=${encodeURIComponent(
          watchUrl
        )}`;
      }
    }
  }
};
</script>
<style lang="less" scoped>
.invite {
  width: 0.8rem;
  height: 0.8rem;
  .btn {
    position: relative;
    padding: 0 0.1rem;
    width: 0.8rem;
    height: 0.6rem;
    background: var(--suspension-invite-bg) no-repeat center center;
    background-size: contain;
    .icon {
      width: 100%;
      height: 100%;
      background: url(./img/icon-invite.png) no-repeat center center;
      background-size: auto 60%;
    }
  }
  .title {
    margin-top: 0.02rem;
    line-height: 0.18rem;
    text-align: center;
    white-space: nowrap;
    font-size: 0.16rem;
    color: #666;
  }
}
</style>
