fans.vue 2.7 KB
Newer Older
!阳仔's avatar
!阳仔 已提交
1 2 3 4 5 6 7 8
<template>
  <!--  -->
  <div class="force">
    <div class="map">
      <FansceMap v-if="cityObj" :mapStyle="mapStyle" :optionList="optionList" :cityObj="cityObj"  />
      <ForceMap v-else :mapStyle="mapStyle" :optionList="optionList" :cityObj="cityObj" @setrankList="setrankList" title="铁粉数"/>
    </div>
    <div class="user-rank-list" ref="user-rank-list">
!阳仔's avatar
!阳仔 已提交
9
      <RankList title="铁粉榜" @clear="clear" :cityObj="cityObj" :dropdownList="dropdownList" @dropdownFn="dropdownFn" listTitle="铁粉数" :city="city" :rankData="rankData" @rankFans="rankFans"/>
!阳仔's avatar
!阳仔 已提交
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
    </div>
  </div>
</template>
<script>
import ForceMap from './mapForce.vue'
import FansceMap from './mapFans.vue'
import RankList from "./rankList.vue";
import { getHardcoreFanInfo,getFanDistribution } from '@/server/screen-data'
export default {
  data() {
    return {
      optionList:[],
      rankData:[],
      rankList:[],
      cityObj:'',
      dataList:[],
!阳仔's avatar
!阳仔 已提交
26 27
      dropdownList:[],
      rankList:[],
!阳仔's avatar
!阳仔 已提交
28 29 30 31 32 33 34 35 36 37
      city:'全国',
      mapStyle:{
        width:'1000',
        height:'900',
        tooltip:true,
        zoom:1.5
      },
    }
  },
  methods: {
!阳仔's avatar
!阳仔 已提交
38 39 40 41
    dropdownFn (val){
      this.city = val
      this.rankData = this.optionList.find(it=>it.city == val).list
    },
!阳仔's avatar
!阳仔 已提交
42 43 44 45 46 47 48 49 50 51 52
    setrankList(data){
      this.rankData = data.list
      this.city = data.city
    },
    getlist(){
       getHardcoreFanInfo().then((res) => {
        if (res.status == 200){
          this.rankData = res.data.data.countryTop
          this.rankList = res.data.data.countryTop
          this.dataList = res.data.data.cityInfoList
          this.optionList = res.data.data.cityInfoList
!阳仔's avatar
!阳仔 已提交
53 54
          this.rankList = res.data.data.countryTop
          this.dropdownList = res.data.data.cityInfoList.map(it=>it.city)
!阳仔's avatar
!阳仔 已提交
55 56 57 58 59 60 61 62 63
        }
        
      }).catch(() => {
      })
    },
    clear() {
      this.cityObj = null
      this.optionList = this.dataList
      this.rankData = this.rankList
!阳仔's avatar
!阳仔 已提交
64
      this.city = '全国'
!阳仔's avatar
!阳仔 已提交
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
    },
    rankFans(item) {
      getFanDistribution(item.username).then(re=>{
        if (re.status === 200){
          this.optionList = re.data.data.map(it=>{
            return {
              name:it.city,
              value:it.gps.concat(it.score),
              uv:it.score
            }
          })
          this.cityObj = item
        }
      })
    }
  },
  mounted(){
    this.getlist()
  },
  created(){
    this.mapStyle.width = document.documentElement.clientWidth
    this.mapStyle.height = document.documentElement.clientHeight-66
  },
  components: {
    ForceMap,
    RankList,
    FansceMap
  },
}
</script>
<style scoped lang="scss">
.force {
  width: 100%;
  display: flex;
  justify-content: space-between;
  position: relative;
  .user-rank-list{
    position: absolute;
    top: 40px;
    right: 40px;
  }
}
</style>