Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
groupPurchase-miniapp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
彭佳妮(贵阳日报)
groupPurchase-miniapp
Commits
56f287f1
Commit
56f287f1
authored
Aug 02, 2024
by
石建新(贵阳日报)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
地图分享
parent
6a8da824
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
41 deletions
+69
-41
shop.vue
src/pages/shop/shop.vue
+19
-16
common.js
src/utils/common.js
+49
-24
vite.config.ts
vite.config.ts
+1
-1
No files found.
src/pages/shop/shop.vue
View file @
56f287f1
...
@@ -68,7 +68,7 @@
...
@@ -68,7 +68,7 @@
<view
class=
"shop-map-phone"
>
<view
class=
"shop-map-phone"
>
<image
<image
mode=
"aspectFill"
mode=
"aspectFill"
@
click=
"
selectMapApp
"
@
click=
"
openMapApp(shopInfo)
"
class=
"img1"
class=
"img1"
src=
"@/static/shop/map.png"
src=
"@/static/shop/map.png"
></image>
></image>
...
@@ -284,9 +284,7 @@ import {
...
@@ -284,9 +284,7 @@ import {
addImgUrlPrefixToImages
,
addImgUrlPrefixToImages
,
getDistance
,
getDistance
,
addImgUrlPrefix
,
addImgUrlPrefix
,
openAmap
,
navigationSelect
,
openBaiduMap
,
openTencentMap
,
}
from
'@/utils/common'
;
}
from
'@/utils/common'
;
const
imgUrl
=
import
.
meta
.
env
.
VITE_APP_IMG_URL
;
const
imgUrl
=
import
.
meta
.
env
.
VITE_APP_IMG_URL
;
const
current
=
ref
(
0
);
const
current
=
ref
(
0
);
...
@@ -403,26 +401,31 @@ function getLocationFn() {
...
@@ -403,26 +401,31 @@ function getLocationFn() {
/**
/**
* 跳转地图
* 跳转地图
*/
*/
function
selectMapApp
()
{
xma
.
showActionSheet
({
function
openMapApp
(
info
)
{
itemList
:
[
'高德地图'
,
'百度地图'
,
'腾讯地图'
],
console
.
log
(
'info'
,
info
);
uni
.
showActionSheet
({
itemList
:
[
'高德地图'
,
'百度地图'
],
success
:
(
res
)
=>
{
success
:
(
res
)
=>
{
const
latitude
=
39.90960456049752
;
// 示例纬度
const
item
=
{
const
longitude
=
116.3972282409668
;
// 示例经度
shopAddress
:
info
.
shopAddress
,
const
name
=
'测试'
;
// 目标地点名称
latitude
:
info
.
location
.
lat
,
longitude
:
info
.
location
.
lon
,
name
:
''
,
};
console
.
log
(
'item'
,
item
);
switch
(
res
.
tapIndex
)
{
switch
(
res
.
tapIndex
)
{
case
0
:
case
0
:
// 打开高德地图
// 打开高德地图
openAmap
(
latitude
,
longitude
,
name
);
item
.
name
=
'高德地图'
;
navigationSelect
(
item
);
break
;
break
;
case
1
:
case
1
:
item
.
name
=
'百度地图'
;
// 打开百度地图
// 打开百度地图
openBaiduMap
(
latitude
,
longitude
);
navigationSelect
(
item
);
break
;
case
2
:
// 打开腾讯地图
openTencentMap
(
latitude
,
longitude
,
name
);
break
;
break
;
default
:
default
:
break
;
break
;
...
...
src/utils/common.js
View file @
56f287f1
...
@@ -73,30 +73,55 @@ export function debounce(func, wait) {
...
@@ -73,30 +73,55 @@ export function debounce(func, wait) {
},
wait
);
},
wait
);
};
};
}
}
/**
* 跳转地图
* @param {*} param0
*/
export
function
navigationSelect
(
item
)
{
console
.
log
(
item
);
const
{
osName
}
=
uni
.
getSystemInfoSync
();
const
{
name
,
latitude
,
longitude
,
shopAddress
}
=
item
;
const
to
=
{
name
:
shopAddress
,
longitude
,
latitude
,
};
const
getMapScheme
=
(
to
)
=>
{
const
u
=
navigator
.
userAgent
;
const
isAndroid
=
osName
===
'android'
;
export
function
openMapApp
(
url
,
packageName
,
appName
)
{
const
andriodBaidu
=
(
to
)
=>
{
plus
.
runtime
.
openURL
(
url
,
function
(
e
)
{
return
`bdapp://map/direction?destination=name:
${
to
.
name
}
|latlng:
${
to
.
latitude
}
,
${
to
.
longitude
}
&coord_type=gcj02&mode=driving&src=andr.jianghu.jianhao`
;
xma
.
showModal
({
};
title
:
'提示'
,
content
:
`
${
appName
}
未安装,是否前往应用市场下载?`
,
success
:
function
(
res
)
{
if
(
res
.
confirm
)
{
plus
.
runtime
.
openURL
(
`market://details?id=
${
packageName
}
`
);
}
},
});
});
}
export
function
openAmap
(
latitude
,
longitude
,
name
)
{
const
iOSBaidu
=
(
to
)
=>
{
const
url
=
`amapuri://poi?sourceApplication=uniapp&poiname=
${
name
}
&lat=
${
latitude
}
&lon=
${
longitude
}
&dev=0`
;
return
`baidumap://map/direction?destination=name:
${
to
.
name
}
|latlng:
${
to
.
latitude
}
,
${
to
.
longitude
}
&coord_type=gcj02&mode=driving&src=ios.jianghu.jianhao`
;
openMapApp
(
url
,
'com.autonavi.minimap'
,
'高德地图'
);
};
}
export
function
openBaiduMap
(
latitude
,
longitude
)
{
const
andriodGaode
=
(
to
)
=>
{
const
url
=
`baidumap://map/geocoder?location=
${
latitude
}
,
${
longitude
}
`
;
return
`amapuri://route/plan/?sourceApplication=mhc&dlat=
${
to
.
latitude
}
&dlon=
${
to
.
longitude
}
&dname=
${
to
.
name
}
&dev=0&t=0`
;
openMapApp
(
url
,
'com.baidu.BaiduMap'
,
'百度地图'
);
};
}
export
function
openTencentMap
(
latitude
,
longitude
,
name
)
{
const
iOSGaode
=
(
to
)
=>
{
const
url
=
`qqmap://map/marker?marker=coord:
${
latitude
}
,
${
longitude
}
;title:
${
name
}
&referer=uniapp`
;
return
`iosamap://path?sourceApplication=mhc&dlat=
${
to
.
latitude
}
&dlon=
${
to
.
longitude
}
&dname=
${
to
.
name
}
&dev=0&t=0`
;
openMapApp
(
url
,
'com.tencent.map'
,
'腾讯地图'
);
};
if
(
item
.
name
===
'百度地图'
)
{
if
(
isAndroid
)
{
return
andriodBaidu
(
to
);
}
else
{
return
iOSBaidu
(
to
);
}
}
else
if
(
item
.
name
===
'高德地图'
)
{
if
(
isAndroid
)
{
return
andriodGaode
(
to
);
}
else
{
return
iOSGaode
(
to
);
}
}
};
const
a
=
document
.
createElement
(
'a'
);
document
.
body
.
appendChild
(
a
);
a
.
href
=
getMapScheme
(
to
);
a
.
click
();
href
.
value
=
getMapScheme
(
to
);
}
}
vite.config.ts
View file @
56f287f1
...
@@ -41,7 +41,7 @@ export default defineConfig({
...
@@ -41,7 +41,7 @@ export default defineConfig({
// 代理配置
// 代理配置
proxy
:
{
proxy
:
{
'/api'
:
{
'/api'
:
{
target
:
'http://
test.rhhzkj.com:8080
'
,
target
:
'http://
192.168.0.147:9999
'
,
changeOrigin
:
true
,
changeOrigin
:
true
,
rewrite
:
(
path
)
=>
path
.
replace
(
/^
\/
api/
,
''
),
rewrite
:
(
path
)
=>
path
.
replace
(
/^
\/
api/
,
''
),
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment