2026-01-30 09:54:46 +08:00
|
|
|
"use strict";
|
|
|
|
|
const common_vendor = require("../vendor.js");
|
2026-05-28 09:48:42 +08:00
|
|
|
function getMapLbs() {
|
|
|
|
|
const AMAP_KEY = "be262c006216c542747fce766130cee3";
|
2026-01-30 09:54:46 +08:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
common_vendor.index.getLocation({
|
2026-05-28 09:48:42 +08:00
|
|
|
type: "gcj02",
|
2026-01-30 09:54:46 +08:00
|
|
|
altitude: true,
|
|
|
|
|
isHighAccuracy: true,
|
|
|
|
|
success(res) {
|
|
|
|
|
console.log(res, "经纬度");
|
2026-05-28 09:48:42 +08:00
|
|
|
const url = `https://restapi.amap.com/v3/geocode/regeo?location=${res.longitude},${res.latitude}&key=${AMAP_KEY}`;
|
2026-01-30 09:54:46 +08:00
|
|
|
common_vendor.index.request({
|
|
|
|
|
url,
|
|
|
|
|
method: "GET",
|
|
|
|
|
success(res2) {
|
2026-05-28 09:48:42 +08:00
|
|
|
var _a;
|
2026-01-30 09:54:46 +08:00
|
|
|
console.log(res2, "address");
|
2026-05-28 09:48:42 +08:00
|
|
|
resolve((_a = res2 == null ? void 0 : res2.data) == null ? void 0 : _a.regeocode);
|
2026-01-30 09:54:46 +08:00
|
|
|
},
|
|
|
|
|
fail(res2) {
|
|
|
|
|
resolve({ 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);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-05-28 09:48:42 +08:00
|
|
|
exports.getMapLbs = getMapLbs;
|