fix:更新水印相机地图
This commit is contained in:
parent
66c45f31e3
commit
9d248f917e
@ -16,7 +16,7 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
|||||||
__name: "index",
|
__name: "index",
|
||||||
setup(__props) {
|
setup(__props) {
|
||||||
common_vendor.onLoad((e) => {
|
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";
|
INDEX_watermark_camera_model.useModel.source.value = (e == null ? void 0 : e.source) || "save";
|
||||||
address.then((res) => {
|
address.then((res) => {
|
||||||
INDEX_watermark_camera_model.useModel.address.value = res;
|
INDEX_watermark_camera_model.useModel.address.value = res;
|
||||||
|
|||||||
16
dist/dev/mp-weixin/common/libraries/map.js
vendored
16
dist/dev/mp-weixin/common/libraries/map.js
vendored
@ -1,25 +1,25 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
const common_vendor = require("../vendor.js");
|
const common_vendor = require("../vendor.js");
|
||||||
function getMapLbs() {
|
function getShowApiAddress() {
|
||||||
const AMAP_KEY = "be262c006216c542747fce766130cee3";
|
const SHOWAPI_APP_KEY = "C59885FE214644168eB4197eFe9a48b9";
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
common_vendor.index.getLocation({
|
common_vendor.index.getLocation({
|
||||||
type: "gcj02",
|
type: "wgs84",
|
||||||
altitude: true,
|
altitude: true,
|
||||||
isHighAccuracy: true,
|
isHighAccuracy: true,
|
||||||
success(res) {
|
success(res) {
|
||||||
console.log(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({
|
common_vendor.index.request({
|
||||||
url,
|
url,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
success(res2) {
|
success(res2) {
|
||||||
var _a;
|
var _a, _b;
|
||||||
console.log(res2, "address");
|
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) {
|
fail(res2) {
|
||||||
resolve({ address: "拒绝定位" });
|
resolve({ formatted_address: "拒绝定位" });
|
||||||
console.error("获取地址失败:", res2);
|
console.error("获取地址失败:", res2);
|
||||||
common_vendor.index.showModal({
|
common_vendor.index.showModal({
|
||||||
title: "提示",
|
title: "提示",
|
||||||
@ -42,4 +42,4 @@ function getMapLbs() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getMapLbs = getMapLbs;
|
exports.getShowApiAddress = getShowApiAddress;
|
||||||
|
|||||||
@ -33,12 +33,12 @@
|
|||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getMapLbs } from '@/common/libraries/map'
|
import { getShowApiAddress } from '@/common/libraries/map'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
import method from './method'
|
import method from './method'
|
||||||
import useModel from './model'
|
import useModel from './model'
|
||||||
onLoad(e => {
|
onLoad(e => {
|
||||||
let address = getMapLbs()
|
let address = getShowApiAddress()
|
||||||
useModel.source.value = e?.source || 'save'
|
useModel.source.value = e?.source || 'save'
|
||||||
address.then((res: { address?: string, formatted_address?: string }) => {
|
address.then((res: { address?: string, formatted_address?: string }) => {
|
||||||
useModel.address.value = res
|
useModel.address.value = res
|
||||||
|
|||||||
@ -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)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user