<template>
  <!--  -->
  <div class="force">
    <div class="map">
      <ForceMap :optionList="optionList" :mapStyle="mapStyle" title="兴趣值" @setrankList="setrankList"/>
    </div>
    <div class="user-rank-list">
      <RankList title="城市技术兴趣榜" @clear="clear" :dropdownList="dropdownList" listTitle="兴趣值" @dropdownFn="dropdownFn" :city="city" :rankData="rankData"/>
    </div>
  </div>
</template>
<script>
import ForceMap from './mapInterest.vue'
import RankList from "./interestRankList.vue";
import { getInterestInfo } from '@/server/screen-data'
export default {
  data() {
    return {
      optionList: [],
      rankData: [],
      rankList:[],
      city:'全国',
      dropdownList:[],
      mapStyle:{
        width:'1000',
        height:'900',
        tooltip:true,
        zoom:1.5
      },
    }
  },
  methods: {
    dropdownFn (val){
      this.city = val
      this.rankData = this.optionList.find(it=>it.city == val).list
    },
    clear(){
      this.rankData = this.rankList
      this.city = '全国'
    },
    getlist() {
      getInterestInfo().then((res) => {
        if (res.status == 200) {
          this.optionList = res.data.data.cityInfoList
          this.rankData = res.data.data.countryTop
          this.rankList = res.data.data.countryTop
          this.dropdownList = res.data.data.cityInfoList.map(it=>it.city)
        }
      }).catch(() => {

      })
    },
    setrankList(data){
      this.rankData = data.list
      this.city = data.city
    }
  },
  created(){
    this.mapStyle.width = document.documentElement.clientWidth
    this.mapStyle.height = document.documentElement.clientHeight-66
  },
  mounted() {
    this.getlist()
  },
  components: {
    ForceMap,
    RankList
  },
}
</script>
<style scoped lang="scss">
.force {
  width: 100%;
  display: flex;
  justify-content: space-between;
  position: relative;
  .user-rank-list {
    top: 40px;
    position: absolute;
    right: 40px;
  }
}
</style>