<template>
  <div class="invite" @click="go">
    <div class="btn">
      <div class="icon" :style="{background: channelInfo &&  channelInfo.screenDirection === 'vertical' ? `url(${defaultIcon}) no-repeat center center` : ''}"></div>
    </div>
    <div class="title">邀请</div>
  </div>
</template>
<script>
import { mapGetters } from 'vuex';

export default {
  name: 'suspension-invite',
  data() {
    return {
      info: {},
      defaultIcon: require('./img/icon-invite.png')
    };
  },
  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: var(--suspension-invite-icon) no-repeat center center;
      background-size: auto 50%;
    }
  }
  .title {
    margin-top: 0.04rem;
    line-height: 0.18rem;
    text-align: center;
    white-space: nowrap;
    font-size: 0.16rem;
  }
}
</style>
