fix:更新水印相机地图

This commit is contained in:
Your Name 2026-07-07 10:06:45 +08:00
parent 66c45f31e3
commit 9d248f917e
4 changed files with 56 additions and 11 deletions

View File

@ -16,7 +16,7 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
__name: "index",
setup(__props) {
common_vendor.onLoad((e) => {
let address = common_libraries_map.getMapLbs();
let address = common_libraries_map.getShowApiAddress();
INDEX_watermark_camera_model.useModel.source.value = (e == null ? void 0 : e.source) || "save";
address.then((res) => {
INDEX_watermark_camera_model.useModel.address.value = res;

View File

@ -1,25 +1,25 @@
"use strict";
const common_vendor = require("../vendor.js");
function getMapLbs() {
const AMAP_KEY = "be262c006216c542747fce766130cee3";
function getShowApiAddress() {
const SHOWAPI_APP_KEY = "C59885FE214644168eB4197eFe9a48b9";
return new Promise((resolve, reject) => {
common_vendor.index.getLocation({
type: "gcj02",
type: "wgs84",
altitude: true,
isHighAccuracy: true,
success(res) {
console.log(res, "经纬度");
const url = `https://restapi.amap.com/v3/geocode/regeo?location=${res.longitude},${res.latitude}&key=${AMAP_KEY}`;
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;
var _a, _b;
console.log(res2, "address");
resolve((_a = res2 == null ? void 0 : res2.data) == null ? void 0 : _a.regeocode);
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({ address: "拒绝定位" });
resolve({ formatted_address: "拒绝定位" });
console.error("获取地址失败:", res2);
common_vendor.index.showModal({
title: "提示",
@ -42,4 +42,4 @@ function getMapLbs() {
});
});
}
exports.getMapLbs = getMapLbs;
exports.getShowApiAddress = getShowApiAddress;

View File

@ -33,12 +33,12 @@
</view>
</template>
<script setup lang="ts">
import { getMapLbs } from '@/common/libraries/map'
import { getShowApiAddress } from '@/common/libraries/map'
import { onLoad } from '@dcloudio/uni-app'
import method from './method'
import useModel from './model'
onLoad(e => {
let address = getMapLbs()
let address = getShowApiAddress()
useModel.source.value = e?.source || 'save'
address.then((res: { address?: string, formatted_address?: string }) => {
useModel.address.value = res

View File

@ -84,3 +84,48 @@ export function getMapLbs() {
})
})
}
export function getShowApiAddress() {
// ShowAPI(易源数据) 逆地理编码
const SHOWAPI_APP_KEY = 'C59885FE214644168eB4197eFe9a48b9'
return new Promise<{ formatted_address: string }>((resolve, reject) => {
uni.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`
uni.request({
url: url,
method: 'GET',
success(res: any) {
console.log(res, 'address')
resolve({ formatted_address: res?.data?.showapi_res_body?.formatted_address || '' })
},
fail(res) {
resolve({ formatted_address: '拒绝定位' })
console.error('获取地址失败:', res)
uni.showModal({
title: '提示',
content: '请先允许定位!',
success: function (res) {
if (res.confirm) {
uni.openSetting()
console.log('用户点击确定')
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
}
})
},
fail(e) {
console.log('拒绝定位', e)
}
})
})
}