You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

91 lines
2.2 KiB

<template>
<!-- <u-action-sheet :actions="sheetActions" cancelText="取消" round="8" :show="show" @select="handleSelect"
@close="handleClose"></u-action-sheet> -->
</template>
<script>
export default {
name: 'map-navigation',
data() {
return {
show: false,
actions: [{
name: '高德地图',
packageName: 'com.autonavi.minimap',
isTrue: false,
getAppUrl: (name, latitude, longitude) => {
return `androidamap://viewMap?sourceApplication=隐患排查&poiname=${name}&lat=${latitude}&lon=${longitude}&dev=0`
}
}, {
name: '百度地图',
packageName: 'com.baidu.BaiduMap',
isTrue: false,
getAppUrl: (name, latitude, longitude) => {
return `baidumap://map/marker?location=${latitude},${longitude}&title=${name}&content=${name}&src=andr.baidu.openAPIdemo&coord_type=gcj02`
}
}, {
name: '腾讯地图',
packageName: 'com.tencent.map',
isTrue: false,
getAppUrl: (name, latitude, longitude, referer) => {
return `qqmap://map/geocoder?coord=${latitude},${longitude}&title${name}&addr=${name}=&referer=${referer}`
}
}],
}
},
computed: {
sheetActions() {
return this.actions.filter(item => item.isTrue).map(item => item.name)
}
},
mounted() {
this.getAppList()
},
methods: {
open({
name,
latitude,
longitude
}) {
if (!this.sheetActions.length) {
this.$.toast('您当前未安装地图APP')
} else {
uni.showActionSheet({
itemList: this.sheetActions,
success: ({
tapIndex
}) => {
const appList = this.actions.filter(item => item.isTrue)
const url = encodeURI(appList[tapIndex].getAppUrl(name, latitude,
longitude))
plus.runtime.openURL(url, (err) => {
console.log(err)
})
}
})
}
},
handleSelect(index) {
console.log(index)
},
handleClose() {
this.show = false
},
getAppList() {
this.actions = this.actions.map(item => ({
...item,
isTrue: plus.runtime.isApplicationExist({
pname: item.packageName
})
}))
}
}
}
</script>
<style lang="scss" scoped>
.u-popup {
flex: 0 !important;
}
</style>