<template>
  <div class="pantoneNoGet">
    <div class="header">
      <van-nav-bar class="navBar" title="未签收门店" left-arrow @click-left="onClickLeft" />
    </div>
    <div class="content">
      <template v-if="list.length">
        <div class="item" v-for="(item, index) in list" :key="index">
          <div class="storeName">{{ item.storeName }}</div>
          <div class="address">
            <van-icon name="location-o" />
            {{ item.addressLine }}
            <!-- <img v-if="item.distance" style="width: 36px" :src="sbpmdh" @click="linkapp(item)" /> -->
          </div>
          <div class="distance" v-if="item.storeLonExist">
            (距离{{ Micrometer(item.distance) }}m)
          </div>
        </div>
      </template>
      <van-empty v-else description="暂无数据" />
    </div>
  </div>
</template>
<script>
import { getNotSignStoreList } from '@/api/index';
import { getPosition, getTicketFun } from '@/utils/TXApiFun';
import sbpmdh from '@/assets/sbpmdh.png';
export default {
  name: 'pantoneNoGet',
  data() {
    return {
      sbpmdh: sbpmdh,
      list: [],
      point: {}, //当前定位坐标
    };
  },
  created() {
    this.storeId = this.$route.query.storeId;
    // config授权
    getTicketFun().then(() => {
      getPosition()
        .then((res) => {
          let { TXisBD } = res;
          this.point = TXisBD;
          this.getNotSignStoreListFun(TXisBD);
        })
        .catch((error) => {
          this.$dialog.alert({
            message: error,
          });
        });
    });
  },
  methods: {
    getNotSignStoreListFun(TXisBD) {
      getNotSignStoreList({
        storeId: this.storeId, //	string	未签门店ID
        lon: TXisBD.lon, //	string	经度
        lat: TXisBD.lat, //	string	纬度
      }).then((res) => {
        this.list = res.data;
      });
    },
    linkapp(val) {
      // agentConfig授权
      getTicketFun(['launchMiniprogram'], 'agentConfig').then(() => {
        this.wx.invoke(
          'launchMiniprogram',
          {
            appid: 'wx238bbb5f6d958414',
            path:
              'pages/relayStation/relayStation?latitude=' +
              point.lat +
              '&longitude=' +
              point.lon +
              '&name=' +
              val.addressLine,
          },
          function (res) {
            if (res.err_msg == 'launchMiniprogram:ok') {
            } else {
            }
          }
        );
      });
    },
    onClickLeft() {
      this.$router.go(-1);
    },
  },
};
</script>
<style lang="scss" scoped>
.pantoneNoGet {
  height: 100%;
  width: 100%;
  /* overflow-y: auto; */
  .content {
    padding: 8px 10px;
    .item {
      background: #deedff;
      padding: 8px;
      margin: 10px 0;
      border-radius: 5px;
      .storeName {
        font-size: 15px;
        font-weight: bold;
        color: #333;
        padding: 3px 0;
      }
      .address,
      .distance {
        font-size: 14px;
        color: #909090;
        padding: 3px 0;
      }
      .distance {
        padding-left: 12px;
      }
    }
  }
}
</style>
