<template>
  <transition name="msgbox-fade">
    <div class="pub-wrapper" v-if="visible">
      <div class="pub-mask" @click="visible = false"></div>
      <div class="pub-modal avater-modal">
        <div class="modal-hd">
          <i class="el-icon-close" @click="visible = false"></i>
        </div>
        <div class="modal-bd" v-if="userInfo">
          <div class="user-top">
            <div class="user-avatar">
              <img v-if="userInfo.cover_photo" :src="userInfo.cover_photo" @click="$showImgPreview(userInfo.cover_photo)" alt="">
              <div v-else class="user-avatar"
              :class="'avatar_bg' + userInfo.user_id % 9"
              :data-name="userInfo.nick_name.slice(0,2).toUpperCase()"
              ></div>
            </div>
            <div class="r-info">
              <span class="name">{{userInfo.nick_name}}</span>
              <div class="introduce">@{{userInfo.user_name}}</div>
            </div>
          </div>
          <div class="account-wrap min-height-account">
            <div class="title">{{$t('userinfo.bindAccounts')}}</div>
            <template v-if="accountList">
              <div class="account-item" v-for="(item, key) in accountList" :key="key">
                <div class="type">
                  <strong>{{item.type.toUpperCase()}}</strong>
                </div>
                <p v-if="item.account && item.is_visible" class="key">{{item.account}}</p>
                <p v-else>{{$t('userinfo.notBindOrHide')}}</p>
              </div>
            </template>
          </div>
          <a v-if="$store.state.userId != userId && meechatType === 'mini'"
            :href="linkToOther"
            @click="visible = false"
            class="send-msg-btn"
            target="meechatpc">{{$t('public.sendMessage')}}</a>
          <button v-else-if="$store.state.userId != userId" class="send-msg-btn" @click="sendMsg">{{$t('public.sendMessage')}}</button>
        </div>
      </div>
    </div>
  </transition>
</template>

<script>
import { Button, Message, Switch } from 'element-ui'
import Vue from 'vue'
import { otherInfoMixins } from '@/mixins/user'

Vue.component(Button.name, Button)
Vue.component(Message.name, Message)
Vue.component(Switch.name, Switch)

export default {
  name: 'infoPopup',
  mixins: [otherInfoMixins]
}
</script>

<style lang="scss">
@import "./style.scss";
.min-height-account{
  min-height: 218px;
}
</style>
