<template>
  <div class="detail">
    <div class="grid-select" @click="show=true">
      <span class="label">网格选择</span>
      <div class="value">
        <span>新里程社区居委会</span>
        <u-icon name="arrow-right" color="#cccccc" size="14"></u-icon>
      </div>
    </div>
    <div class="map-content">
      <AiTMap :areaId="areaId" :map.sync="map" :lib.sync="lib" :ops="ops" :libraries="['service', 'tools']"></AiTMap>
    </div>
    <u-popup v-model="show" mode="bottom" border-radius="14">
      <div class="popup">
        <div class="bg"></div>
        <div class="title">恒大城西社区居委会</div>
        <div class="info-flex">
          <span class="label">网格类型</span>
          <span class="value">基础网格</span>
        </div>
        <div class="info-flex">
          <span class="label">网格层级</span>
          <span class="value">村/社区</span>
        </div>
        <div class="info-flex">
          <span class="label">网格管理员</span>
          <span class="value">林珊珊&nbsp;&nbsp;13782951281
            <img :src="$cdn + 'common/phone.png'" alt="" @click="call(item)" class="phone-icon">
          </span>
        </div>
      </div>
    </u-popup>
  </div>
</template>

<script>
import { mapState } from 'vuex'
export default {

  data() {
    return {
      areaId: '',
      ops: {},
      lib: '',
      map: null,
      markerArr: [],
      show: false
    }
  },
  computed: { ...mapState(['user']) },
  mounted() {
    this.areaId = this.user.areaId
    this.initMap()
  },

  methods: {
    initMap() {
      //初始化地图
      
      this.$nextTick(() =>{
        let {lib: TMap, map} = this
        var center = new TMap.LatLng(40.040422, 116.273521)
        var marker = null;
        var points = []
        map.setCenter(center)
        map.setZoom(18)

        marker = new TMap.MultiMarker({
          id: 'marker-layer', // 图层id
          map: map,
          styles: {
            // 点标注的相关样式
            marker: new TMap.MarkerStyle({
              width: 25,
              height: 35,
              anchor: { x: 16, y: 32 },
              src:'',
            }),
          },
          geometries: [
            {
              // 点标注数据数组
              id: 'demo',
              styleId: 'marker',
              position: new TMap.LatLng(40.040422, 116.273521),
            },
          ],
        });

        var infoWindow = null;
        var infoWindow2 = null
        var html = `<div style=" display: inline-block;padding: 6px 10px;line-height: 16px;border-radius: 24px; background: #5088FF;color: #fff;font-size: 12px;position: relative;">`
          +`腾讯大厦<span style=" width: 0;height: 0;border-left: 6px solid transparent;border-right: 6px solid transparent;border-top: 12px solid #5088FF;position: absolute;bottom: -12px;left: 50%;margin-left:-6px;"></span></div>`
        
        infoWindow = new TMap.InfoWindow(
          {
          map: map,
          enableCustom: true,
          position: new TMap.LatLng(40.040422, 116.273521),
          offset: { y: -70, x: -5 },
          content: html
          },
        );

        infoWindow2 = new TMap.InfoWindow(
          {
          map: map,
          enableCustom: true,
          position: new TMap.LatLng(40.03592, 116.27058),
          offset: { y: -70, x: -5 },
          content: html
          },
        );
      })
      
    },
    
  }
}
</script>

<style lang="scss" scoped>
uni-page-body{
  height: 100%;
}
.detail {
  height: 100%;
  .grid-select{
    width: 100%;
    padding: 34px 32px;
    box-sizing: border-box;
    background: #FFF;
    display: flex;
    justify-content: space-between;
    line-height: 44px;
    color: #333;
    .label{
      display: inline-block;
      width: 140px;
      font-size: 32px;
    }
    .value{
      font-size: 28px;
      .u-icon{
        margin-left: 8px;
      }
    }
  }
  .map-content{
    width: 100%;
    height: calc(100% - 112px);
  }
  .popup{
    padding: 0 32px 16px;
    .bg{
      width: 64px;
      height: 10px;
      background: #CCC;
      border-radius: 6px;
      margin: 32px 0 32px 344px;
    }
    .title{
      font-size: 36px;
      font-family: PingFang-SC-Heavy, PingFang-SC;
      font-weight: 800;
      color: #333;
      line-height: 50px;
      margin-bottom: 24px;
    }
    .info-flex{
      padding: 26px 0 30px 0;
      width: 100%;
      border-bottom: 1px solid #D8DDE6;
      line-height: 40px;
      font-size: 28px;
      .label{
        display: inline-block;
        width: 160px;
        font-weight: 800;
        color: #333;
      }
      .value{
        color: #666;
        font-size: 26px;
        .phone-icon{
          width: 40px;
          height: 40px;
          vertical-align: sub;
          margin-left: 16px;
        }
      }
    }
  }
}
</style>