新增IOS跳转高德,优化安卓跳转高德
This commit is contained in:
parent
e9da383a41
commit
23d9264123
@ -71,6 +71,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"apple":{
|
||||||
|
"urlschemewhitelist":["iosamap"]
|
||||||
|
},
|
||||||
"splashscreen" : {
|
"splashscreen" : {
|
||||||
"useOriginalMsgbox" : true
|
"useOriginalMsgbox" : true
|
||||||
},
|
},
|
||||||
|
@ -101,6 +101,7 @@
|
|||||||
import {
|
import {
|
||||||
takeGoods
|
takeGoods
|
||||||
} from "@/api/logistics.js"
|
} from "@/api/logistics.js"
|
||||||
|
import { Toast } from "../../libs/uniApi";
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -165,35 +166,82 @@
|
|||||||
|
|
||||||
// 唤起高德
|
// 唤起高德
|
||||||
test() {
|
test() {
|
||||||
if (this.is_captain) return
|
if (this.is_captain) return;
|
||||||
var packageName = 'com.autonavi.minimap';
|
let that = this;
|
||||||
var main = plus.android.runtimeMainActivity();
|
uni.getSystemInfo({
|
||||||
var packageManager = main.getPackageManager();
|
success(e) {
|
||||||
var PackageManager = plus.android.importClass(packageManager)
|
if(e.platform ==='ios'){
|
||||||
var packageInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
|
// Toast('不支持');
|
||||||
if (packageInfo) {
|
// iOS上获取本机是否安装了百度高德地图,需要在manifest里配置
|
||||||
var Uri = plus.android.importClass("android.net.Uri");
|
// 在manifest.json文件app-plus->distribute->apple->urlschemewhitelist节点下添加
|
||||||
var url =
|
//(如urlschemewhitelist:["iosamap","baidumap"])
|
||||||
`amapuri://route/plan?sourceApplication=maxuslife+
|
plus.nativeUI.actionSheet({
|
||||||
&sid=A&slat=36.702558&slon=116.876678&sname=我的位置&did=B&dlat=${this.markers[0].latitude}&dlon=${this.markers[0].longitude}&dname=${this.goodsDetil.logistics.shop_name}&dev=0&t=0`;
|
title: "选择地图应用",
|
||||||
var Intent = plus.android.importClass('android.content.Intent');
|
cancel: "取消",
|
||||||
var intent = new Intent();
|
buttons: [{title: "高德地图"}]
|
||||||
intent.setAction(Intent.ACTION_VIEW);
|
}, function(e) {
|
||||||
intent.addCategory(Intent.CATEGORY_DEFAULT);
|
if(e.index!=1)return;
|
||||||
var uri = Uri.parse(url);
|
try{
|
||||||
//将功能Scheme以URI的方式传入data
|
let url = `iosamap://viewMap?sourceApplication=applicationName&poiname=${that.goodsDetil.logistics.shop_name}&lat=${that.markers[0].latitude}&lon=${that.markers[0].longitude}&dev=0`;
|
||||||
intent.setData(uri);
|
if (url != "") {
|
||||||
intent.setPackage("com.autonavi.minimap");
|
url = encodeURI(url);
|
||||||
var main = plus.android.runtimeMainActivity();
|
plus.runtime.openURL(url, function(e) {
|
||||||
main.startActivity(intent);
|
plus.nativeUI.alert("本机未安装指定的地图应用");
|
||||||
} else {
|
});
|
||||||
// alert('未安装' + packageName + '')
|
}
|
||||||
uni.showToast({
|
}catch(e){
|
||||||
title: `只支持高德地图`,
|
console.log(e);
|
||||||
icon: 'none'
|
Toast('暂不支持唤起地图')
|
||||||
})
|
}
|
||||||
}
|
})
|
||||||
console.log("唤醒高德线路规划")
|
}
|
||||||
|
else {
|
||||||
|
plus.nativeUI.actionSheet({
|
||||||
|
title: "选择地图应用",
|
||||||
|
cancel: "取消",
|
||||||
|
buttons: [{title: "高德地图"}]
|
||||||
|
}, function(e) {
|
||||||
|
if(e.index!=1)return;
|
||||||
|
try{
|
||||||
|
var packageName = 'com.autonavi.minimap';
|
||||||
|
var main = plus.android.runtimeMainActivity();
|
||||||
|
var packageManager = main.getPackageManager();
|
||||||
|
var PackageManager = plus.android.importClass(packageManager)
|
||||||
|
var packageInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
|
||||||
|
if (packageInfo) {
|
||||||
|
var Uri = plus.android.importClass("android.net.Uri");
|
||||||
|
var url =
|
||||||
|
`amapuri://route/plan?sourceApplication=maxuslife+
|
||||||
|
&sid=A&slat=36.702558&slon=116.876678&sname=我的位置&did=B&dlat=${that.markers[0].latitude}&dlon=${that.markers[0].longitude}&dname=${that.goodsDetil.logistics.shop_name}&dev=0&t=0`;
|
||||||
|
var Intent = plus.android.importClass('android.content.Intent');
|
||||||
|
var intent = new Intent();
|
||||||
|
intent.setAction(Intent.ACTION_VIEW);
|
||||||
|
intent.addCategory(Intent.CATEGORY_DEFAULT);
|
||||||
|
var uri = Uri.parse(url);
|
||||||
|
//将功能Scheme以URI的方式传入data
|
||||||
|
intent.setData(uri);
|
||||||
|
intent.setPackage("com.autonavi.minimap");
|
||||||
|
var main = plus.android.runtimeMainActivity();
|
||||||
|
main.startActivity(intent);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// alert('未安装' + packageName + '')
|
||||||
|
uni.showToast({
|
||||||
|
title: `只支持高德地图`,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
console.log("唤醒高德线路规划")
|
||||||
|
}catch(e){
|
||||||
|
console.log(e);
|
||||||
|
Toast('启动出错')
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
showToast() {
|
showToast() {
|
||||||
this.$refs.uToast.show({
|
this.$refs.uToast.show({
|
||||||
|
BIN
static/img/logistics/SL.png
Normal file
BIN
static/img/logistics/SL.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
@ -113,7 +113,7 @@
|
|||||||
id: 2,
|
id: 2,
|
||||||
latitude: undefined,
|
latitude: undefined,
|
||||||
longitude: undefined,
|
longitude: undefined,
|
||||||
iconPath: '../../static/img/logistics/QS.png', //显示的图标
|
iconPath: '../../static/img/logistics/SL.png', //显示的图标
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
polyline: [],
|
polyline: [],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user