<template>
  <div class="homeMap">
    <div class="map">
      <div :scroll-x="true" class="scrolldiv-box">
        <div class="chinaMap" v-show="show">
          <echarsMap :data="province" v-if="province.length"></echarsMap>
        </div>
        <div class="allMap" v-show="!show">
          <div class="goChina" @click="show = !show"></div>
        </div>
      </div>
    </div>
    <div class="people">
      <img
        height="30px"
        width="30px"
        mode="heightFix"
        src="/static/img/icon_lotus_dark@2x.png"
      ></img>
      <span class="peopleNum">祈愿人数</span>
      <span class="peopleNum">{{ people }}</span>
    </div>
    <div class="bottom flex justify-between items-end">
      <div class="list">
        <vue-seamless-scroll :data="list" class="wrap">
        <div class="listItem" v-for="item in list" :key="item.id">
          {{item.creatorName}}
          <span style="color: #7EE3DE">【{{item.province}}】</span>
          {{item.name}}
        </div>
      </vue-seamless-scroll>
      </div>
      <div class="qiyuan" @click="handleqiyuan">
        <img
              height="70px"
              width="70px"
              mode="heightFix"
              src="/static/img/btn_wish@2x.png"
            ></img>
      </div>
    </div>
  </div>
</template>

<script>
import echarsMap from '@/components/echars/index.vue'
import { Toast } from 'vant';
import vueSeamlessScroll from 'vue-seamless-scroll'
export default {
  components: {
    echarsMap,
    vueSeamlessScroll
  },
  data() {
    return {
      show: false,
      people: 0,
      province: [],
      list: []
    }
  },
  onReady() {},
  created() {
    this.getRequest('/api/show/pray/getList').then(res => {
      console.log(res, 'getList')
      this.list = res.data
    })
    this.getRequest('/api/show/pray/count').then(res => {
      console.log(res, 'getList')
      this.people = res.data.total
      let province = []
      for (let key of Object.keys(res.data.province)) {  
        console.log(key); // 'a', 'b', 'c'  
        province.push({
          name: key,
          value: res.data.province[key]
        })
      }
      this.province = province
    })
  },
  methods: {
    handleHome() {
      // console.log('开启云上观灯', uni)
      // uni.$u.route('/pages/home/home')
    },
    handleqiyuan() {
      this.show = false
      // this.getRequest('/api/wx/getCode').then((res) => {
      //   let codeList = res.data || []
      //   if(codeList.length > 6){
          this.$router.push('/prayers/list')
      //   }else {
      //     Toast('请至少完成6次打卡~');
      //   }
      // })
    },
  }
}
</script>

<style lang="scss">
.homeMap {
  width: 100%;
  height: 100%;
  position: relative;
  background: url(https://4dscene.4dage.com/new4dkk/deng/static/img/bg03@2x.png) 100% 100% no-repeat;
  background-size: cover;
  .bottom {
    width: calc(100% - 47px);
    position: absolute;
    bottom: 50px;
    left: 0;
    height: 25vh;
    padding: 0 27px 0 20px;
    .list {
      height: 100%;
      overflow: hidden;
      // overflow-y: scroll;
      .listItem {
        padding: 6px 10px;
        background: rgba(0, 0, 0, 0.3);
        border-radius: 50px;
        margin-top: 10px;
        font-weight: 400;
        font-size: 12px;
        color: #ffffff;
        line-height: 14px;
        text-align: center;
        font-style: normal;
      }
    }
  }
  .people {
    position: absolute;
    height: 35px;
    padding: 0 5px;
    background: rgba(0, 0, 0, 0.5);
    right: 0;
    top: 125px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 20px 0 0 20px;
    .peopleNum {
      font-size: 24rpx;
      color: #fff;
      margin-right: 8px;
    }
  }
  .map {
    width: 100%;
    height: 100%;
    .scrolldiv-box {
      white-space: nowrap; // 滚动必须加的属性
      width: 100%;
      height: 100%;
    }
    .chinaMap {
      overflow: hidden;
      width: 100vw;
      height: 100%;
      background: url(https://4dscene.4dage.com/new4dkk/deng/static/img/chinaMap.jpg) 100% 100%
        no-repeat;
      // background-position: 20px 34px;
      background-size: 100%;
      background-position: 2px 11px;
    }
    .allMap {
      width: 375px;
      height: calc(100vh - 358px);
      background: url(https://4dscene.4dage.com/new4dkk/deng/static/img/map@2x.png) 100% 55%
        no-repeat;
      background-position-y: 47px;
      background-position-x: -231px;
      // background-size: 100vh 1097px;
      // background-size: cover;
      background-size: 183vw auto;
      position: relative;
      // background-position: -1758px -600px;
      .goChina {
        width: 100px;
        height: 100px;
        position: absolute;
        left: 240px;
        top: 236px;
      }
    }
  }
}
</style>
