Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
anyefeiyu
uni-app
提交
68cffbad
U
uni-app
项目概览
anyefeiyu
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
68cffbad
编写于
8月 30, 2022
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' into alpha
上级
3af59a95
8a100f41
变更
13
展开全部
隐藏空白更改
内联
并排
Showing
13 changed file
with
673 addition
and
595 deletion
+673
-595
.github/CONTRIBUTING.md
.github/CONTRIBUTING.md
+2
-2
packages/uni-app-plus/template/common/__uniappopenlocation.js
...ages/uni-app-plus/template/common/__uniappopenlocation.js
+1
-1
packages/uni-cli-shared/components/ad-interactive.vue
packages/uni-cli-shared/components/ad-interactive.vue
+126
-109
packages/vue-cli-plugin-uni/lib/mp/index.js
packages/vue-cli-plugin-uni/lib/mp/index.js
+9
-2
packages/vue-cli-plugin-uni/lib/mp/tips.js
packages/vue-cli-plugin-uni/lib/mp/tips.js
+67
-0
packages/vue-cli-plugin-uni/packages/mp-vue/dist/mp.runtime.esm.js
...vue-cli-plugin-uni/packages/mp-vue/dist/mp.runtime.esm.js
+379
-378
packages/vue-cli-plugin-uni/packages/uni-push/dist/uni-push.es.js
.../vue-cli-plugin-uni/packages/uni-push/dist/uni-push.es.js
+12
-16
packages/vue-cli-plugin-uni/packages/uni-push/dist/uni-push.plus.es.js
...cli-plugin-uni/packages/uni-push/dist/uni-push.plus.es.js
+0
-23
src/core/runtime/wrapper/util.js
src/core/runtime/wrapper/util.js
+0
-6
src/core/service/api/plugin/push.js
src/core/service/api/plugin/push.js
+19
-2
src/platforms/h5/components/system-routes/choose-location/index.vue
...rms/h5/components/system-routes/choose-location/index.vue
+13
-24
src/platforms/h5/service/api/location/get-location.js
src/platforms/h5/service/api/location/get-location.js
+45
-31
src/platforms/h5/view/components/map/index.vue
src/platforms/h5/view/components/map/index.vue
+0
-1
未找到文件。
.github/CONTRIBUTING.md
浏览文件 @
68cffbad
...
...
@@ -83,7 +83,7 @@
*
commands
*
lib
*
packages:内置依赖包
*
mp-vue:小程序平台使用的 Vue 依赖,由仓库
[
fxy060608/vue
](
https://github.com/fxy060608/vue
)
编译。
*
mp-vue:小程序平台使用的 Vue 依赖,由仓库
[
fxy060608/vue
#dev
](
https://github.com/fxy060608/vue
)
编译。
*
vue-cli-plugin-uni-optimize:Vue CLI 插件,主要处理 H5 平台摇树优化
*
webpack-uni-mp-loader:webpack loader,用于生成小程序平台的各种文件
*
webpack-uni-pages-loader:webpack loader,用于解析 pages.json
...
...
@@ -144,4 +144,4 @@
*
quickapp-native:快应用平台运行时
*
quickapp-webview:快应用平台运行时
*
shared
*
test:单元测试(运行时)
\ No newline at end of file
*
test:单元测试(运行时)
packages/uni-app-plus/template/common/__uniappopenlocation.js
浏览文件 @
68cffbad
此差异已折叠。
点击以展开。
packages/uni-cli-shared/components/ad-interactive.vue
浏览文件 @
68cffbad
<
template
>
<view
@
click=
"onclick"
>
<slot
:options=
"options"
:data=
"adData"
/>
<slot
:options=
"options"
:data=
"adData"
:loading=
"loading"
:error=
"errorMessage"
/>
</view>
</
template
>
<
script
>
const
AD_URL
=
'
https://wxac1.dcloud.net.cn/tuiaApplet
/acs
'
const
AD_REPORT_URL
=
'
https://wxac1.dcloud.net.cn/tuiaApplet
/acs
'
const
WEBVIEW_PATH
=
'
/uni_modules/uni-ad-interactive/pages/uni-ad-interactive/uni-ad-interactive
'
const
AD_URL
=
'
https://wxac1.dcloud.net.cn/openPage
/acs
'
const
AD_REPORT_URL
=
'
https://wxac1.dcloud.net.cn/openPage
/acs
'
//
const WEBVIEW_PATH = '/uni_modules/uni-ad-interactive/pages/uni-ad-interactive/uni-ad-interactive'
const
events
=
{
load
:
'
load
'
,
close
:
'
close
'
,
error
:
'
error
'
}
const
events
=
{
load
:
'
load
'
,
close
:
'
close
'
,
error
:
'
error
'
}
const
OpenTypes
=
{
Interactive
:
'
interactive
'
}
const
OpenTypes
=
{
Interactive
:
'
interactive
'
}
export
default
{
name
:
'
AdInteractive
'
,
props
:
{
options
:
{
type
:
[
Object
,
Array
],
default
()
{
return
{}
export
default
{
name
:
'
AdInteractive
'
,
props
:
{
options
:
{
type
:
[
Object
,
Array
],
default
()
{
return
{}
}
},
disabled
:
{
type
:
[
Boolean
,
String
],
default
:
false
},
adpid
:
{
type
:
[
Number
,
String
],
default
:
''
},
openType
:
{
type
:
String
,
default
:
'
interactive
'
},
openPagePath
:
{
type
:
String
,
default
:
""
}
},
adpid
:
{
type
:
[
Number
,
String
],
default
:
''
},
openUrl
:
{
type
:
String
,
default
:
WEBVIEW_PATH
}
},
data
()
{
return
{
adData
:
{}
}
},
created
()
{
this
.
_uniAdPlugin
=
null
this
.
_interactiveUrl
=
null
if
(
this
.
openType
===
OpenTypes
.
Interactive
)
{
this
.
getAdData
()
}
},
methods
:
{
show
()
{
if
(
this
.
_uniAdPlugin
===
null
)
{
this
.
_uniAdPlugin
=
this
.
selectComponent
(
'
.uni-ad-plugin
'
)
data
()
{
return
{
adData
:
null
,
loading
:
false
,
errorMessage
:
""
}
this
.
_uniAdPlugin
.
show
()
},
getAdData
()
{
if
(
!
this
.
adpid
)
{
this
.
$emit
(
events
.
error
,
{
code
:
-
5002
,
message
:
'
invalid adpid
'
})
return
created
()
{
this
.
_uniAdPlugin
=
null
this
.
_interactiveUrl
=
null
if
(
this
.
openPagePath
)
{
this
.
getAdData
()
}
},
methods
:
{
show
()
{
if
(
this
.
_uniAdPlugin
===
null
)
{
this
.
_uniAdPlugin
=
this
.
selectComponent
(
'
.uni-ad-plugin
'
)
}
this
.
_uniAdPlugin
.
show
()
},
getAdData
()
{
if
(
!
this
.
adpid
)
{
this
.
$emit
(
events
.
error
,
{
code
:
-
5002
,
message
:
'
invalid adpid
'
})
return
}
uni
.
request
({
url
:
AD_URL
,
method
:
'
POST
'
,
data
:
{
adpid
:
this
.
adpid
},
timeout
:
5000
,
dataType
:
'
json
'
,
success
:
(
res
)
=>
{
console
.
log
(
res
.
data
)
this
.
loading
=
true
if
(
res
.
statusCode
!==
200
)
{
this
.
$emit
(
events
.
error
,
{
code
:
res
.
statusCode
,
message
:
res
.
statusCode
})
return
}
uni
.
request
({
url
:
AD_URL
,
method
:
'
POST
'
,
data
:
{
adpid
:
this
.
adpid
},
timeout
:
5000
,
dataType
:
'
json
'
,
success
:
(
res
)
=>
{
if
(
res
.
statusCode
!==
200
)
{
this
.
$emit
(
events
.
error
,
{
errCode
:
res
.
statusCode
,
errMsg
:
res
.
statusCode
})
return
}
const
responseData
=
res
.
data
if
(
responseData
.
ret
===
0
)
{
this
.
_interactiveUrl
=
responseData
.
data
.
adp_url
this
.
adData
.
imgUrl
=
responseData
.
data
.
icon_url
this
.
adData
.
openUrl
=
this
.
openUrl
+
'
?url=
'
+
encodeURIComponent
(
this
.
_interactiveUrl
)
this
.
$emit
(
events
.
load
,
{})
}
else
{
const
responseData
=
res
.
data
if
(
responseData
.
ret
===
0
)
{
this
.
_interactiveUrl
=
responseData
.
data
.
adp_url
this
.
adData
=
{
imgUrl
:
responseData
.
data
.
icon_url
,
openPath
:
this
.
openPagePath
+
'
?url=
'
+
encodeURIComponent
(
this
.
_interactiveUrl
)
}
this
.
$emit
(
events
.
load
,
this
.
adData
)
}
else
{
const
errMsg
=
{
errCode
:
responseData
.
ret
,
errMsg
:
responseData
.
msg
}
this
.
errorMessage
=
errMsg
this
.
$emit
(
events
.
error
,
errMsg
)
}
},
fail
:
(
err
)
=>
{
this
.
$emit
(
events
.
error
,
{
code
:
responseData
.
ret
,
message
:
responseData
.
m
sg
errCode
:
''
,
errMsg
:
err
.
errM
sg
})
},
complete
:
()
=>
{
this
.
loading
=
false
}
},
fail
:
(
err
)
=>
{
this
.
$emit
(
events
.
error
,
{
code
:
''
,
message
:
err
.
errMsg
})
})
},
onclick
()
{
if
(
this
.
disabled
)
{
return
}
if
(
!
this
.
_interactiveUrl
)
{
return
}
})
},
onclick
()
{
if
(
this
.
openType
!==
OpenTypes
.
Interactive
||
!
this
.
_interactiveUrl
)
{
return
}
uni
.
navigateTo
({
url
:
this
.
adData
.
openUrl
})
uni
.
navigateTo
({
url
:
this
.
adData
.
openPath
})
this
.
_report
()
},
_report
()
{
uni
.
request
({
url
:
AD_REPORT_URL
,
data
:
{
adpid
:
this
.
adpid
,
t
:
'
10019
'
},
timeout
:
5000
,
dataType
:
'
json
'
})
this
.
_report
()
},
_report
()
{
uni
.
request
({
url
:
AD_REPORT_URL
,
data
:
{
adpid
:
this
.
adpid
,
t
:
'
10019
'
},
timeout
:
5000
,
dataType
:
'
json
'
})
}
}
}
}
</
script
>
<
style
>
...
...
packages/vue-cli-plugin-uni/lib/mp/index.js
浏览文件 @
68cffbad
...
...
@@ -26,6 +26,8 @@ function createUniMPPlugin () {
}
const
createWxMpIndependentPlugins
=
require
(
'
@dcloudio/uni-mp-weixin/lib/createIndependentPlugin
'
)
const
UniTips
=
require
(
'
./tips
'
)
function
getProvides
()
{
const
uniPath
=
require
(
'
@dcloudio/uni-cli-shared/lib/platform
'
).
getMPRuntimePath
()
...
...
@@ -190,7 +192,7 @@ module.exports = {
if
((
process
.
env
.
UNI_SUBPACKGE
||
process
.
env
.
UNI_MP_PLUGIN
)
&&
process
.
env
.
UNI_SUBPACKGE
!==
'
main
'
)
{
plugins
.
push
(
new
PreprocessAssetsPlugin
())
}
}
{
const
globalEnv
=
process
.
env
.
UNI_PLATFORM
===
'
mp-alipay
'
?
'
my
'
:
'
wx
'
;
...
...
@@ -228,7 +230,12 @@ ${globalEnv}.__webpack_require_UNI_MP_PLUGIN__ = __webpack_require__;`
}
if
(
process
.
env
.
NODE_ENV
===
'
production
'
||
process
.
env
.
UNI_MINIMIZE
===
'
true
'
)
{
output
.
pathinfo
=
false
}
}
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-weixin
'
&&
process
.
env
.
NODE_ENV
===
'
production
'
)
{
plugins
.
push
(
new
UniTips
())
}
return
{
mode
:
process
.
env
.
NODE_ENV
===
'
production
'
?
'
production
'
:
'
development
'
,
entry
()
{
...
...
packages/vue-cli-plugin-uni/lib/mp/tips.js
0 → 100644
浏览文件 @
68cffbad
const
fs
=
require
(
'
fs
'
)
const
path
=
require
(
'
path
'
)
const
{
isInHBuilderX
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
class
UniTips
{
apply
(
compiler
)
{
compiler
.
hooks
.
emit
.
tap
(
'
PreprocessAssetsPlugin
'
,
compilation
=>
{
const
assets
=
compilation
.
assets
let
hasAd
=
false
try
{
Object
.
keys
(
assets
).
forEach
(
name
=>
{
if
(
hasAd
)
{
return
}
if
(
!
name
.
startsWith
(
'
common
'
)
&&
!
name
.
startsWith
(
'
pages
'
))
{
return
}
const
extname
=
path
.
extname
(
name
)
if
(
extname
!==
'
.js
'
)
{
return
}
if
(
!
hasAd
&&
!
process
.
env
.
USE_UNI_AD
)
{
hasAd
=
assets
[
name
].
_value
.
match
(
/createRewardedVideoAd|createInterstitialAd/
)
}
})
setTimeout
(()
=>
{
if
(
hasAd
)
{
console
.
log
(
'
推荐使用uni-ad微信小程序版广告,无开通门槛、提前结算、插件丰富,助力广告变现。详情: https://uniapp.dcloud.net.cn/component/ad-weixin.html
'
)
}
let
projectRoot
=
''
if
(
isInHBuilderX
)
{
projectRoot
=
process
.
env
.
UNI_INPUT_DIR
}
else
{
projectRoot
=
process
.
env
.
UNI_CLI_CONTEXT
}
const
paths
=
fs
.
readdirSync
(
projectRoot
)
const
useUniCloud
=
paths
.
find
((
name
)
=>
{
return
name
.
includes
(
'
uniCloud-
'
)
})
if
(
!
useUniCloud
&&
assets
[
'
project.config.json
'
])
{
const
pcjString
=
assets
[
'
project.config.json
'
].
source
()
const
pcjJson
=
JSON
.
parse
(
pcjString
)
if
(
typeof
pcjJson
.
cloudfunctionRoot
===
'
string
'
&&
pcjJson
.
cloudfunctionRoot
.
length
>
0
)
{
console
.
log
(
'
欢迎使用uniCloud,价格更便宜、开发更方便、生态更丰富的云开发。详情: https://uniapp.dcloud.net.cn/uniCloud/wx2unicloud.html
'
)
}
}
},
100
)
}
catch
(
e
)
{}
})
}
}
module
.
exports
=
UniTips
packages/vue-cli-plugin-uni/packages/mp-vue/dist/mp.runtime.esm.js
浏览文件 @
68cffbad
此差异已折叠。
点击以展开。
packages/vue-cli-plugin-uni/packages/uni-push/dist/uni-push.es.js
浏览文件 @
68cffbad
...
...
@@ -133,22 +133,6 @@ function initPushNotification() {
},
});
});
plus
.
push
.
addEventListener
(
'
click
'
,
(
result
)
=>
{
// @ts-expect-error
uni
.
invokePushCallback
({
type
:
'
click
'
,
message
:
result
,
});
});
uni
.
onPushMessage
((
res
)
=>
{
if
(
res
.
type
===
'
receive
'
&&
res
.
data
&&
res
.
data
.
force_notification
)
{
// 创建通知栏
uni
.
createPushMessage
(
res
.
data
);
res
.
stopped
=
true
;
}
});
}
}
...
...
@@ -207,4 +191,16 @@ else {
});
},
});
// 仅在 jssdk 中监听
// #ifdef APP
uni
.
onPushMessage
((
res
)
=>
{
if
(
res
.
type
===
'
receive
'
&&
res
.
data
&&
res
.
data
.
force_notification
)
{
// 创建通知栏
uni
.
createPushMessage
(
res
.
data
);
res
.
stopped
=
true
;
}
});
// #endif
}
packages/vue-cli-plugin-uni/packages/uni-push/dist/uni-push.plus.es.js
浏览文件 @
68cffbad
...
...
@@ -31,22 +31,6 @@ function initPushNotification() {
},
});
});
plus
.
push
.
addEventListener
(
'
click
'
,
(
result
)
=>
{
// @ts-expect-error
uni
.
invokePushCallback
({
type
:
'
click
'
,
message
:
result
,
});
});
uni
.
onPushMessage
((
res
)
=>
{
if
(
res
.
type
===
'
receive
'
&&
res
.
data
&&
res
.
data
.
force_notification
)
{
// 创建通知栏
uni
.
createPushMessage
(
res
.
data
);
res
.
stopped
=
true
;
}
});
}
}
...
...
@@ -58,11 +42,4 @@ uni.invokePushCallback({
Promise
.
resolve
().
then
(()
=>
{
initPushNotification
();
plus
.
push
.
setAutoNotification
&&
plus
.
push
.
setAutoNotification
(
false
);
plus
.
push
.
addEventListener
(
'
receive
'
,
(
result
)
=>
{
// @ts-expect-error
uni
.
invokePushCallback
({
type
:
'
pushMsg
'
,
message
:
result
,
});
});
});
src/core/runtime/wrapper/util.js
浏览文件 @
68cffbad
...
...
@@ -87,12 +87,6 @@ function findHooks (vueOptions, hooks = []) {
function
initHook
(
mpOptions
,
hook
,
excludes
)
{
if
(
excludes
.
indexOf
(
hook
)
===
-
1
&&
!
hasOwn
(
mpOptions
,
hook
))
{
mpOptions
[
hook
]
=
function
(
args
)
{
if
(
(
__PLATFORM__
===
'
mp-toutiao
'
||
__PLATFORM__
===
'
mp-lark
'
)
&&
hook
===
'
onError
'
)
{
return
getApp
().
$vm
.
$callHook
(
hook
,
args
)
}
return
this
.
$vm
&&
this
.
$vm
.
__call_hook
(
hook
,
args
)
}
}
...
...
src/core/service/api/plugin/push.js
浏览文件 @
68cffbad
...
...
@@ -23,7 +23,7 @@ export function invokePushCallback (
)
{
if
(
args
.
type
===
'
enabled
'
)
{
enabled
=
true
if
(
__PLATFORM__
===
'
app
'
)
{
if
(
__PLATFORM__
===
'
app
-plus
'
)
{
offline
=
args
.
offline
}
}
else
if
(
args
.
type
===
'
clientId
'
)
{
...
...
@@ -76,7 +76,7 @@ export function getPushClientId (args) {
const
hasComplete
=
isFn
(
complete
)
// App 端且启用离线时,使用 getClientInfoAsync 来调用
if
(
__PLATFORM__
===
'
app
'
&&
offline
)
{
if
(
__PLATFORM__
===
'
app
-plus
'
&&
offline
)
{
plus
.
push
.
getClientInfoAsync
(
(
info
)
=>
{
const
res
=
{
...
...
@@ -126,10 +126,27 @@ export function getPushClientId (args) {
}
const
onPushMessageCallbacks
=
[]
let
listening
=
false
// 不使用 defineOnApi 实现,是因为 defineOnApi 依赖 UniServiceJSBridge ,该对象目前在小程序上未提供,故简单实现
export
const
onPushMessage
=
(
fn
)
=>
{
if
(
onPushMessageCallbacks
.
indexOf
(
fn
)
===
-
1
)
{
onPushMessageCallbacks
.
push
(
fn
)
}
// 不能程序启动时就监听,因为离线事件,仅触发一次,框架监听后,无法转发给还没开始监听的开发者
if
(
__PLATFORM__
===
'
app
'
&&
!
listening
)
{
listening
=
true
plus
.
push
.
addEventListener
(
'
click
'
,
(
result
)
=>
{
invokePushCallback
({
type
:
'
click
'
,
message
:
result
})
})
plus
.
push
.
addEventListener
(
'
receive
'
,
(
result
)
=>
{
invokePushCallback
({
type
:
'
pushMsg
'
,
message
:
result
})
})
}
}
...
...
src/platforms/h5/components/system-routes/choose-location/index.vue
浏览文件 @
68cffbad
...
...
@@ -269,33 +269,22 @@ export default {
const
self
=
this
window
.
AMap
.
plugin
(
'
AMap.PlaceSearch
'
,
function
()
{
var
autoOptions
=
{
const
placeSearch
=
new
window
.
AMap
.
PlaceSearch
(
{
city
:
'
全国
'
,
pageSize
:
10
,
pageIndex
:
self
.
pageIndex
}
var
placeSearch
=
new
window
.
AMap
.
PlaceSearch
(
autoOptions
)
if
(
self
.
searching
)
{
placeSearch
.
searchNearBy
(
self
.
keyword
,
[
self
.
longitude
,
self
.
latitude
],
50000
,
function
(
status
,
result
)
{
if
(
status
===
'
error
'
)
{
console
.
error
(
result
)
}
else
if
(
status
===
'
no_data
'
)
{
self
.
hasNextPage
=
false
}
else
{
self
.
pushData
(
result
.
poiList
.
pois
)
}
})
}
else
{
placeSearch
.
searchNearBy
(
''
,
[
self
.
longitude
,
self
.
latitude
],
5000
,
function
(
status
,
result
)
{
if
(
status
===
'
error
'
)
{
console
.
error
(
result
)
}
else
if
(
status
===
'
no_data
'
)
{
self
.
hasNextPage
=
false
}
else
{
self
.
pushData
(
result
.
poiList
.
pois
)
}
})
}
})
const
keyword
=
self
.
searching
?
self
.
keyword
:
''
const
radius
=
self
.
searching
?
50000
:
5000
placeSearch
.
searchNearBy
(
keyword
,
[
self
.
longitude
,
self
.
latitude
],
radius
,
function
(
status
,
result
)
{
if
(
status
===
'
error
'
)
{
console
.
error
(
result
)
}
else
if
(
status
===
'
no_data
'
)
{
self
.
hasNextPage
=
false
}
else
{
self
.
pushData
(
result
.
poiList
.
pois
)
}
})
self
.
loading
=
false
})
}
...
...
src/platforms/h5/service/api/location/get-location.js
浏览文件 @
68cffbad
...
...
@@ -5,6 +5,7 @@ import {
MapType
,
getMapInfo
}
from
'
../../../helpers/location
'
import
{
loadMaps
}
from
'
../../../view/components/map/maps
'
/**
* 获取定位信息
...
...
@@ -67,44 +68,57 @@ export function getLocation ({
reject
(
new
Error
(
'
network error
'
))
}
})
}
else
if
(
mapInfo
.
type
===
MapType
.
AMAP
)
{
window
.
AMap
.
plugin
(
'
AMap.Geolocation
'
,
function
()
{
var
geolocation
=
new
window
.
AMap
.
Geolocation
({})
geolocation
.
getCurrentPosition
(
function
(
status
,
res
)
{
if
(
status
===
'
complete
'
)
{
resolve
({
latitude
:
res
.
position
.
lat
,
longitude
:
res
.
position
.
lng
,
accuracy
:
res
.
accuracy
})
}
else
{
reject
(
new
Error
((
res
.
message
)
||
JSON
.
stringify
(
res
)))
}
})
})
}
else
{
reject
(
new
Error
(
'
network error
'
))
}
})
}).
then
((
coords
,
skip
)
=>
{
if
(
type
.
toUpperCase
()
===
'
WGS84
'
||
mapInfo
.
type
!==
MapType
.
QQ
||
skip
)
{
const
wgs84Map
=
[
MapType
.
GOOGLE
]
if
(
type
.
toUpperCase
()
===
'
WGS84
'
||
wgs84Map
.
includes
(
mapInfo
.
type
)
||
skip
)
{
return
coords
}
return
new
Promise
((
resolve
,
reject
)
=>
{
getJSONP
(
`https://apis.map.qq.com/jsapi?qt=translate&type=1&points=
${
coords
.
longitude
}
,
${
coords
.
latitude
}
&key=
${
mapInfo
.
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
{
resolve
(
coords
)
}
},
()
=>
resolve
(
coords
))
})
if
(
mapInfo
.
type
===
MapType
.
QQ
)
{
return
new
Promise
((
resolve
)
=>
{
getJSONP
(
`https://apis.map.qq.com/jsapi?qt=translate&type=1&points=
${
coords
.
longitude
}
,
${
coords
.
latitude
}
&key=
${
mapInfo
.
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
{
resolve
(
coords
)
}
},
()
=>
resolve
(
coords
))
})
}
if
(
mapInfo
.
type
===
MapType
.
AMAP
)
{
return
new
Promise
((
resolve
)
=>
{
loadMaps
([],
()
=>
{
window
.
AMap
.
convertFrom
(
[
coords
.
longitude
,
coords
.
latitude
],
'
gps
'
,
(
_
,
res
)
=>
{
if
(
res
.
info
===
'
ok
'
&&
res
.
locations
.
length
)
{
const
{
lat
,
lng
}
=
res
.
locations
[
0
]
resolve
(
Object
.
assign
({},
coords
,
{
longitude
:
lng
,
latitude
:
lat
})
)
}
else
{
resolve
(
coords
)
}
}
)
})
})
}
}).
then
(
coords
=>
{
invoke
(
callbackId
,
Object
.
assign
(
coords
,
{
errMsg
:
'
getLocation:ok
'
,
...
...
src/platforms/h5/view/components/map/index.vue
浏览文件 @
68cffbad
...
...
@@ -234,7 +234,6 @@ export default {
return
}
const
{
pageX
,
pageY
}
=
e
.
changedTouches
[
0
]
this
.
$trigger
(
'
click
'
,
{
x
:
pageX
,
y
:
pageY
},
{})
this
.
$trigger
(
'
tap
'
,
{
x
:
pageX
,
y
:
pageY
},
{})
}
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录