fix:水印相机,地图切换成天地图

This commit is contained in:
Your Name 2026-07-09 14:36:43 +08:00
parent dff94da7b6
commit ac0c95dbe7
4 changed files with 13 additions and 13 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.getShowApiAddress();
let address = common_libraries_map.getMapAddress();
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,7 +1,7 @@
"use strict";
const common_vendor = require("../vendor.js");
function getShowApiAddress() {
const SHOWAPI_APP_KEY = "C59885FE214644168eB4197eFe9a48b9";
function getMapAddress() {
const TIANDITU_KEY = "ee3611ed7d1e3061a5271f6e40cda354";
return new Promise((resolve, reject) => {
common_vendor.index.getLocation({
type: "wgs84",
@ -9,17 +9,17 @@ function getShowApiAddress() {
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`;
const url = `https://api.tianditu.gov.cn/geocoder?postStr={'lon':${res.longitude},'lat':${res.latitude},'ver':2}&type=geocode&tk=${TIANDITU_KEY}`;
common_vendor.index.request({
url,
method: "GET",
success(res2) {
var _a, _b;
resolve({ address: ((_b = (_a = res2 == null ? void 0 : res2.data) == null ? void 0 : _a.result) == null ? void 0 : _b.formatted_address) || "" });
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: "拒绝定位" });
resolve({ address: "拒绝定位" });
console.error("获取地址失败:", res2);
common_vendor.index.showModal({
title: "提示",
@ -42,4 +42,4 @@ function getShowApiAddress() {
});
});
}
exports.getShowApiAddress = getShowApiAddress;
exports.getMapAddress = getMapAddress;

View File

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

View File

@ -1,6 +1,6 @@
export function getMapAddress() {
// 高德配置
const TIANDITU_KEY = '4ce26ecef55ae1ec47910a72a098efc0'
// 天地图配置
const TIANDITU_KEY = 'ee3611ed7d1e3061a5271f6e40cda354'
return new Promise<{ address: string }>((resolve, reject) => {
uni.getLocation({
type: 'wgs84',
@ -94,7 +94,7 @@ export function getShowApiAddress() {
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`
const url = `https://route.showapi.com/238-3?appKey=${SHOWAPI_APP_KEY}&lng=${res.longitude}&lat=${res.latitude}&from=1`
uni.request({
url: url,
method: 'GET',