Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Velpro187
uni-app
提交
9813d0e9
U
uni-app
项目概览
Velpro187
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9813d0e9
编写于
11月 05, 2020
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(h5): 优化定位
上级
30ffe52e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
12 addition
and
10 deletion
+12
-10
src/platforms/h5/service/api/location/get-location.js
src/platforms/h5/service/api/location/get-location.js
+12
-10
未找到文件。
src/platforms/h5/service/api/location/get-location.js
浏览文件 @
9813d0e9
...
...
@@ -20,7 +20,7 @@ export function getLocation ({
if
(
navigator
.
geolocation
)
{
navigator
.
geolocation
.
getCurrentPosition
(
res
=>
resolve
(
res
.
coords
),
reject
,
{
enableHighAccuracy
:
altitude
,
timeout
:
1000
*
60
*
5
timeout
:
1000
*
100
})
}
else
{
reject
(
new
Error
(
'
device nonsupport geolocation
'
))
...
...
@@ -35,28 +35,30 @@ export function getLocation ({
resolve
({
latitude
:
location
.
lat
,
longitude
:
location
.
lng
})
}
,
true
)
}
else
{
reject
(
new
Error
(
JSON
.
stringify
(
res
)))
reject
(
new
Error
(
res
.
message
||
JSON
.
stringify
(
res
)))
}
},
()
=>
reject
(
new
Error
(
'
network error
'
)))
})
}).
then
(
coords
=>
{
if
(
type
.
toUpperCase
()
===
'
WGS84
'
)
{
}).
then
(
(
coords
,
skip
)
=>
{
if
(
type
.
toUpperCase
()
===
'
WGS84
'
||
skip
)
{
return
coords
}
return
new
Promise
((
resolve
,
reject
)
=>
{
getJSONP
(
`https://apis.map.qq.com/ws/coord/v1/translate?locations=
${
coords
.
latitude
}
,
${
coords
.
longitude
}
&type=1&key=
${
key
}
&output=jsonp`
,
{},
(
res
)
=>
{
if
(
'
locations
'
in
res
&&
res
.
locations
.
length
)
{
const
location
=
res
.
locations
[
0
]
getJSONP
(
`https://apis.map.qq.com/jsapi?qt=translate&type=1&points=
${
coords
.
longitude
}
,
${
coords
.
latitude
}
&key=
${
key
}
&output=jsonp&pf=jsapi&ref=jsapi`
,
{
callback
:
'
cb
'
},
(
res
)
=>
{
if
(
'
detail
'
in
res
&&
'
points
'
in
res
.
detail
&&
res
.
detail
.
points
.
length
)
{
const
location
=
res
.
detail
.
points
[
0
]
resolve
(
Object
.
assign
({},
coords
,
{
longitude
:
location
.
lng
,
latitude
:
location
.
lat
}))
}
else
{
re
ject
(
new
Error
(
JSON
.
stringify
(
res
))
)
re
solve
(
coords
)
}
},
()
=>
re
ject
(
new
Error
(
'
network error
'
)
))
},
()
=>
re
solve
(
coords
))
})
}).
then
(
coords
=>
{
invoke
(
callbackId
,
Object
.
assign
(
coords
,
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录