<template>
  <view class="store-address" @click="openMap">
    <uni-icons type="location" size="18" color="#999" />
    <text>{{ orderData.commodityAddress }}</text>
    <uni-icons type="right" size="14" color="#999" />
  </view>
</template>

<script setup>
import { defineProps } from "vue";

defineProps({
  orderData: {
    type: Object,
    required: true,
    default: () => ({}),
  },
});

// 打开地图
const openMap = () => {
  const address = props.orderData.commodityAddress;
  const latitude = Number(props.orderData.commodityLatitude);
  const longitude = Number(props.orderData.commodityLongitude);

  uni.getLocation({
    type: "gcj02", //返回可以用于uni.openLocation的经纬度
    success: (res) => {
      console.log("当前经纬度", latitude, longitude);

      uni.openLocation({
        latitude: latitude,
        longitude: longitude,
        address: address,
        success: () => {
          console.log("success");
        },
      });
    },
  });
};
</script>

<style scoped lang="scss">
@import "./styles/index.scss";
</style>