feat:蓝牙绑定和在线客服

This commit is contained in:
李伊帆
2026-10-13 16:23:43 +08:00
parent d4b02745e1
commit e22ebd6bef
128 changed files with 10429 additions and 385 deletions

42
src/utils/map-geocode.ts Normal file
View File

@@ -0,0 +1,42 @@
const TENCENT_MAP_KEY = import.meta.env.VITE_TENCENT_MAP_KEY as string | undefined
interface TencentGeocodeResponse {
status?: number
message?: string
result?: {
address?: string
formatted_addresses?: {
recommend?: string
}
}
}
/** 逆地理编码(需配置 VITE_TENCENT_MAP_KEY) */
export async function reverseGeocode(
latitude: number,
longitude: number,
): Promise<string | undefined> {
if (!TENCENT_MAP_KEY) return undefined
try {
const res = await uni.request({
url: 'https://apis.map.qq.com/ws/geocoder/v1/',
method: 'GET',
data: {
location: `${latitude},${longitude}`,
key: TENCENT_MAP_KEY,
get_poi: 0,
},
})
const data = res.data as TencentGeocodeResponse
if (data.status !== 0) return undefined
return data.result?.formatted_addresses?.recommend
|| data.result?.address
} catch {
return undefined
}
}
export function formatCoordinateAddress(latitude: number, longitude: number): string {
return `纬度 ${latitude.toFixed(4)},经度 ${longitude.toFixed(4)}`
}