1. 新增多语言文件覆盖组件、页面、公共模块的翻译文案 2. 修复多处动态拼接lang key的调用,增加兜底逻辑避免空值或原始key暴露 3. 补全DIY组件、业务页面的国际化适配 4. 新增P2动态key国际化处理方案文档
109 lines
2.8 KiB
JavaScript
109 lines
2.8 KiB
JavaScript
import util from '@/common/js/util.js'
|
|
import TransformCoordinate from './transformCoordinate.js'
|
|
import Lang from '@/common/js/lang.js'
|
|
|
|
function openMapByDefault(latitude, longitude, name) {
|
|
uni.openLocation({
|
|
latitude: latitude,
|
|
longitude: longitude,
|
|
name: name,
|
|
fail: (e) => {
|
|
uni.showModal({
|
|
content: Lang.lang('common.map.openMapFailed')
|
|
})
|
|
},
|
|
})
|
|
}
|
|
|
|
function openMapByAndroid(latitude, longitude, name) {
|
|
let url = ''; // 回调地址
|
|
let identity = ''; // 程序名称
|
|
if (plus.runtime.isApplicationExist({
|
|
pname: 'com.baidu.BaiduMap'
|
|
})) {
|
|
url =
|
|
`baidumap://map/marker?location=${latitude},${longitude}&title=${name}&coord_type=gcj02&src=andr.baidu.openAPIdemo`
|
|
identity = 'com.baidu.BaiduMap'
|
|
openURL(url, identity)
|
|
} else if (plus.runtime.isApplicationExist({
|
|
pname: 'com.autonavi.minimap'
|
|
})) { // 高德
|
|
url = `androidamap://viewMap?sourceApplication=appname&poiname=${name}&lat=${latitude}&lon=${longitude}&dev=0`
|
|
identity = 'com.autonavi.minimap'
|
|
openURL(url, identity)
|
|
} else {
|
|
openMapByDefault(latitude, longitude, name)
|
|
}
|
|
}
|
|
|
|
function openMapByIos(latitude, longitude, name) {
|
|
let url = ''; // 回调地址
|
|
let errorCB = ''; // url失败的回调地址
|
|
let identity = ''; // 程序名称
|
|
|
|
if (plus.runtime.isApplicationExist({
|
|
action: 'baidumap://'
|
|
})) {
|
|
url =
|
|
`baidumap://map/marker?location=${latitude},${longitude}&title=${name}&content=${name}&src=ios.baidu.openAPIdemo&coord_type=gcj02`;
|
|
openURL(url, identity)
|
|
} else if (plus.runtime.isApplicationExist({
|
|
action: 'iosamap://'
|
|
})) { // 高德
|
|
url = `iosamap://viewMap?sourceApplication=applicationName&poiname=${name}&lat=${latitude}&lon=${longitude}&dev=0`
|
|
openURL(url, identity)
|
|
} else {
|
|
openMapByDefault(latitude, longitude, name)
|
|
}
|
|
}
|
|
|
|
function openURL(url, identity) {
|
|
let newurl = encodeURI(url);
|
|
plus.runtime.openURL(newurl, function(res) {
|
|
uni.showModal({
|
|
content: res.message
|
|
})
|
|
}, identity);
|
|
}
|
|
|
|
function getCoordByType(longitude, latitude, coord_type) {
|
|
switch (coord_type) {
|
|
case 'gcj02':
|
|
return [longitude, latitude]
|
|
break;
|
|
case 'bd09':
|
|
return TransformCoordinate.bd09togcj02(longitude, latitude)
|
|
break;
|
|
case 'wgs84':
|
|
return TransformCoordinate.wgs84togcj02(longitude, latitude)
|
|
break;
|
|
default:
|
|
return [longitude, latitude]
|
|
break;
|
|
}
|
|
}
|
|
export default {
|
|
/* 打开地图 */
|
|
openMap(latitude, longitude, name, coord_type = 'gcj02') {
|
|
let arr = getCoordByType(longitude, latitude, coord_type)
|
|
// #ifdef APP-PLUS
|
|
let platform = util.getDeviceInfo().platform;
|
|
switch (platform) {
|
|
case 'android':
|
|
case 'harmony':
|
|
openMapByAndroid(arr[1], arr[0], name)
|
|
break;
|
|
case 'ios':
|
|
openMapByIos(arr[1], arr[0], name)
|
|
break;
|
|
default:
|
|
openMapByDefault(arr[1], arr[0], name)
|
|
break;
|
|
}
|
|
// #endif
|
|
// #ifndef APP-PLUS
|
|
openMapByDefault(arr[1], arr[0], name)
|
|
// #endif
|
|
}
|
|
}
|