"use strict";
const common_vendor = require("../vendor.js");
function getShowApiAddress() {
  const SHOWAPI_APP_KEY = "C59885FE214644168eB4197eFe9a48b9";
  return new Promise((resolve, reject) => {
    common_vendor.index.getLocation({
      type: "wgs84",
      altitude: true,
      isHighAccuracy: true,
      success(res) {
        console.log(res, "经纬度");
        const url = `https://route.showapi.com/238-3?appKey=${SHOWAPI_APP_KEY}&lng=${res.longitude}&lat=${res.latitude}&from=5`;
        common_vendor.index.request({
          url,
          method: "GET",
          success(res2) {
            var _a, _b;
            console.log(res2, "address");
            resolve({ formatted_address: ((_b = (_a = res2 == null ? void 0 : res2.data) == null ? void 0 : _a.showapi_res_body) == null ? void 0 : _b.formatted_address) || "" });
          },
          fail(res2) {
            resolve({ formatted_address: "拒绝定位" });
            console.error("获取地址失败:", res2);
            common_vendor.index.showModal({
              title: "提示",
              content: "请先允许定位！",
              success: function(res3) {
                if (res3.confirm) {
                  common_vendor.index.openSetting();
                  console.log("用户点击确定");
                } else if (res3.cancel) {
                  console.log("用户点击取消");
                }
              }
            });
          }
        });
      },
      fail(e) {
        console.log("拒绝定位", e);
      }
    });
  });
}
exports.getShowApiAddress = getShowApiAddress;
