<template>
  <div class="rank-list" ref="rank-list">
    <div class="title">
      <span>{{ title }}</span>
      <!-- <span class="clear" @click="clear" v-if="cityObj">回退</span> -->
      <p v-if="city&&!userItem"><img src="@/assets/img/place-pc.png" alt="" /><span style="font-size: 16px;">{{city}}</span></p>
      <p v-if="userItem"><img src="@/assets/img/user.png" alt="" /><a target="_blank" :href="`https://blog.csdn.net/${userItem.username}`">{{userItem.nickname||userItem.username}}</a></p>
    </div>
    <div class="rank-list-nav border">
        <span class="mar">排名</span>
        <p><span>明星成员</span></p>
        <span>城市</span><span>{{listTitle}}</span>
      </div>
    <ul class="user-list">
      <li class="rank-list-nav active" v-for="(item,index) in rankData" :key="index" @click="rankAdd(item)">
        <span class="mar">{{index+1}}</span>
        <p>
          <img :src="item.avatar" alt="" /><span
            >{{item.nickname || item.username}}</span
          >
        </p>
        <span>{{item.city}}</span><span>{{item.score}}</span>
      </li>
    </ul>
  </div>
</template>
<script>

export default {
  data() {
    return {
      userItem:''
    }
  },
  methods: {
    clear () {
      this.$emit('clear')
    },
    rankAdd(item){
      if (this.title == '用户原力榜') {
        window.open(`https://blog.csdn.net/`+item.username)
      }else{
        this.userItem = item
        this.$emit('rankFans',item)
      }
    }
  },
  props: ['title','rankData','city','listTitle','cityObj']
}
</script>
<style scoped lang="scss">
.rank-list {
  width: 400px;
  height: 800px;
  display: flex;
  flex-direction: column;
  .title {
    display: flex;
    justify-content: space-between;
    height: 50px;
    align-items: center;
    background-image: url("@/assets/img/rank-right.png");
    background-size: cover;
    padding: 8px 28px 0px 24px;
    span {
      font-size: 20px;
      font-weight: 500;
      color: #77c0ff;
    }
    .clear{
      cursor: pointer;
    }
    p {
      display: flex;
      align-items: center;
      max-width: 200px;
      img {
        width: 18px;
        height: 18px;
        margin-right: 4px;
      }
      a {
        color: #77C0FF;
        flex: 1;
        font-size: 16px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        word-break: break-all;
      }
    }
  }
  li,.rank-list-nav {
      display: flex;
      align-items: center;
      height: 50px;
      padding: 0 24px;
      &.border {
        border-bottom: 1px solid #2b4670;
      }
      &.active:hover {
        background: #141f38;
        cursor: pointer;
      }
      p {
        width: 188px;
        display: flex;
        align-items: center;
        img {
          width: 28px;
          height: 28px;
          border-radius: 50%;
          margin-right: 10px;
        }
      }
      & > span:nth-child(1) {
        margin-right: 14px;
        width: 40px;
        text-align: center;
      }
      & > span:nth-child(3) {
        margin-right: 10px;
        width: 60px;
        text-align: center;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        word-break: break-all;
      }
      &>span:nth-child(4) {
        width: 60px;
        text-align: center;
      }
      &.active > span:nth-child(4) {
        font-size: 14px;
        font-weight: 500;
        color: rgba(41, 255, 163, 0.8);
      }
      &.active > span {
        font-size: 14px;
      }
      & > p {
        // flex: 1;
        margin-right: 10px;
        span {
          // width:160px;
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 1;
          -webkit-box-orient: vertical;
          word-break: break-all;
        }
      }
      span {
        font-size: 16px;
        // font-weight: 500;
        color: #77c0ff;
      }
    }
    .border{
      border-left: 2px solid #5F97D5;
      border-right: 2px solid #5F97D5;
      background: #192645;
    }
  .user-list {
    flex: 1;
    overflow: auto;
    border:2px solid #5F97D5 ;
    background: #192645;
    border-top:none;
    &::-webkit-scrollbar {
      width: 4px;
    }
   &::-webkit-scrollbar-thumb {
    background-color: #375a87;
    border-radius: 3px;
    transition: background-color 0.3s ease-in-out;
  }
  }
}
@media screen and (max-width:1500px){
  .rank-list {
    // width: 368px;
    height: 645px;
    // .title{
    //   height: 40px;
    // }
    // .user-list li,.rank-list-nav{
    //   &>span:nth-child(1) {
    //     margin-right: 10px !important;
    //     width: 52px !important;
    //   }
    //   &>span:nth-child(4) {
    //     width: 64px !important;
    //   }
    // }
    }
}
</style>