Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lzb_79
uni-app
提交
223a161b
U
uni-app
项目概览
lzb_79
/
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,发现更多精彩内容 >>
提交
223a161b
编写于
10月 15, 2021
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: getLocation add highAccuracyExpireTime、getUniverifyManager
上级
b47092df
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
103 addition
and
26 deletion
+103
-26
lib/apis.js
lib/apis.js
+1
-0
src/platforms/app-plus/service/api/location/get-location.js
src/platforms/app-plus/service/api/location/get-location.js
+4
-2
src/platforms/app-plus/service/api/plugin/oauth.js
src/platforms/app-plus/service/api/plugin/oauth.js
+95
-22
src/platforms/h5/service/api/location/get-location.js
src/platforms/h5/service/api/location/get-location.js
+3
-2
未找到文件。
lib/apis.js
浏览文件 @
223a161b
...
...
@@ -223,6 +223,7 @@ const third = [
'
preLogin
'
,
'
closeAuthView
'
,
'
getCheckBoxState
'
,
'
getUniverifyManager
'
,
'
share
'
,
'
shareWithSystem
'
,
'
showShareMenu
'
,
...
...
src/platforms/app-plus/service/api/location/get-location.js
浏览文件 @
223a161b
...
...
@@ -52,7 +52,8 @@ function getLocationSuccess (type, position, callbackId) {
export
function
getLocation
({
type
=
'
wgs84
'
,
geocode
=
false
,
altitude
=
false
altitude
=
false
,
highAccuracyExpireTime
}
=
{},
callbackId
)
{
const
errorCallback
=
warpPlusErrorCallback
(
callbackId
,
'
getLocation
'
)
plus
.
geolocation
.
getCurrentPosition
(
...
...
@@ -68,7 +69,8 @@ export function getLocation ({
errorCallback
(
e
)
},
{
geocode
:
geocode
,
enableHighAccuracy
:
altitude
enableHighAccuracy
:
altitude
,
timeout
:
highAccuracyExpireTime
}
)
}
src/platforms/app-plus/service/api/plugin/oauth.js
浏览文件 @
223a161b
...
...
@@ -5,7 +5,9 @@ import {
warpPlusSuccessCallback
,
warpPlusErrorCallback
}
from
'
../util
'
import
{
isPlainObject
}
from
'
uni-shared
'
import
{
isPlainObject
,
toRawType
,
callback
}
from
'
uni-shared
'
let
univerifyManager
function
getService
(
provider
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
...
...
@@ -19,20 +21,21 @@ function getService (provider) {
/**
* 微信登录
*/
export
function
login
(
params
,
callbackId
)
{
export
function
login
(
params
,
callbackId
,
plus
=
true
)
{
const
provider
=
params
.
provider
||
'
weixin
'
const
errorCallback
=
warp
PlusErrorCallback
(
callbackId
,
'
login
'
)
const
errorCallback
=
warp
ErrorCallback
(
callbackId
,
'
login
'
,
plus
)
const
authOptions
=
provider
===
'
apple
'
?
{
scope
:
'
email
'
}
:
params
.
univerifyStyle
?
{
univerifyStyle
:
univerifyButtonsClickHandling
(
params
.
univerifyStyle
,
errorCallback
)
}
:
{}
const
_invoke
=
plus
?
invoke
:
callback
.
invoke
getService
(
provider
).
then
(
service
=>
{
function
login
()
{
if
(
params
.
onlyAuthorize
&&
provider
===
'
weixin
'
)
{
service
.
authorize
(({
code
})
=>
{
invoke
(
callbackId
,
{
_
invoke
(
callbackId
,
{
code
,
authResult
:
''
,
errMsg
:
'
login:ok
'
...
...
@@ -42,7 +45,7 @@ export function login (params, callbackId) {
}
service
.
login
(
res
=>
{
const
authResult
=
res
.
target
.
authResult
invoke
(
callbackId
,
{
_
invoke
(
callbackId
,
{
code
:
authResult
.
code
,
authResult
:
authResult
,
errMsg
:
'
login:ok
'
...
...
@@ -137,9 +140,9 @@ export function operateWXData (params, callbackId) {
}
}
export
function
preLogin
(
params
,
callbackId
)
{
const
successCallback
=
warp
PlusSuccessCallback
(
callbackId
,
'
preLogin
'
)
const
errorCallback
=
warp
PlusErrorCallback
(
callbackId
,
'
preLogin
'
)
export
function
preLogin
(
params
,
callbackId
,
plus
)
{
const
successCallback
=
warp
SuccessCallback
(
callbackId
,
'
preLogin
'
,
plus
)
const
errorCallback
=
warp
ErrorCallback
(
callbackId
,
'
preLogin
'
,
plus
)
getService
(
params
.
provider
).
then
(
service
=>
service
.
preLogin
(
successCallback
,
errorCallback
)).
catch
(
errorCallback
)
}
...
...
@@ -147,9 +150,9 @@ export function closeAuthView () {
return
getService
(
'
univerify
'
).
then
(
service
=>
service
.
closeAuthView
())
}
export
function
getCheckBoxState
(
params
,
callbackId
)
{
const
successCallback
=
warp
PlusSuccessCallback
(
callbackId
,
'
getCheckBoxState
'
)
const
errorCallback
=
warp
PlusErrorCallback
(
callbackId
,
'
getCheckBoxState
'
)
export
function
getCheckBoxState
(
params
,
callbackId
,
plus
)
{
const
successCallback
=
warp
SuccessCallback
(
callbackId
,
'
getCheckBoxState
'
,
plus
)
const
errorCallback
=
warp
ErrorCallback
(
callbackId
,
'
getCheckBoxState
'
,
plus
)
try
{
getService
(
'
univerify
'
).
then
(
service
=>
{
const
state
=
service
.
getCheckBoxState
()
...
...
@@ -164,22 +167,92 @@ export function getCheckBoxState (params, callbackId) {
* 一键登录自定义登陆按钮点击处理
*/
function
univerifyButtonsClickHandling
(
univerifyStyle
,
errorCallback
)
{
if
(
univerifyStyle
&&
isPlainObject
(
univerifyStyle
)
&&
univerifyStyle
.
buttons
&&
Object
.
prototype
.
toString
.
call
(
univerifyStyle
.
buttons
.
list
)
===
'
[object Array]
'
&&
univerifyStyle
.
buttons
.
list
.
length
>
0
)
{
if
(
isPlainObject
(
univerifyStyle
)
&&
isPlainObject
(
univerifyStyle
.
buttons
)
&&
toRawType
(
univerifyStyle
.
buttons
.
list
)
===
'
Array
'
)
{
univerifyStyle
.
buttons
.
list
.
forEach
((
button
,
index
)
=>
{
univerifyStyle
.
buttons
.
list
[
index
].
onclick
=
function
()
{
closeAuthView
().
then
(()
=>
{
errorCallback
({
code
:
'
30008
'
,
message
:
'
用户点击了自定义按钮
'
,
index
,
provider
:
button
.
provider
const
res
=
{
code
:
'
30008
'
,
message
:
'
用户点击了自定义按钮
'
,
index
,
provider
:
button
.
provider
}
isPlainObject
(
univerifyManager
)
?
univerifyManager
.
_triggerUniverifyButtonsClick
(
res
)
:
closeAuthView
().
then
(()
=>
{
errorCallback
(
res
)
})
})
}
})
}
return
univerifyStyle
}
class
UniverifyManager
{
constructor
()
{
this
.
provider
=
'
univerify
'
this
.
eventName
=
'
api.univerifyButtonsClick
'
}
close
()
{
closeAuthView
()
}
login
(
options
)
{
this
.
_warp
((
data
,
callbackId
)
=>
login
(
data
,
callbackId
,
false
),
this
.
_getOptions
(
options
))
}
getCheckBoxState
(
options
)
{
this
.
_warp
((
_
,
callbackId
)
=>
getCheckBoxState
(
_
,
callbackId
,
false
),
options
)
}
preLogin
(
options
)
{
this
.
_warp
((
data
,
callbackId
)
=>
preLogin
(
data
,
callbackId
,
false
),
this
.
_getOptions
(
options
))
}
onButtonsClick
(
callback
)
{
UniServiceJSBridge
.
on
(
this
.
eventName
,
callback
)
}
offButtonsClick
(
callback
)
{
UniServiceJSBridge
.
off
(
this
.
eventName
,
callback
)
}
_triggerUniverifyButtonsClick
(
res
)
{
UniServiceJSBridge
.
emit
(
this
.
eventName
,
res
)
}
_warp
(
fn
,
options
)
{
return
callback
.
warp
(
fn
)(
this
.
_getOptions
(
options
))
}
_getOptions
(
options
=
{})
{
return
Object
.
assign
({},
options
,
{
provider
:
this
.
provider
})
}
}
export
function
getUniverifyManager
()
{
return
univerifyManager
||
(
univerifyManager
=
new
UniverifyManager
())
}
function
warpSuccessCallback
(
callbackId
,
name
,
plus
=
true
)
{
return
plus
?
warpPlusSuccessCallback
(
callbackId
,
name
)
:
(
options
)
=>
{
callback
.
invoke
(
callbackId
,
Object
.
assign
({},
options
,
{
errMsg
:
`
${
name
}
:ok`
}))
}
}
function
warpErrorCallback
(
callbackId
,
name
,
plus
=
true
)
{
return
plus
?
warpPlusErrorCallback
(
callbackId
,
name
)
:
(
error
)
=>
{
const
{
code
=
0
,
message
:
errorMessage
}
=
error
callback
.
invoke
(
callbackId
,
{
errMsg
:
`
${
name
}
:fail
${
errorMessage
||
''
}
`
,
errCode
:
code
,
code
})
}
}
src/platforms/h5/service/api/location/get-location.js
浏览文件 @
223a161b
...
...
@@ -13,7 +13,8 @@ import {
*/
export
function
getLocation
({
type
,
altitude
altitude
,
highAccuracyExpireTime
},
callbackId
)
{
const
{
invokeCallbackHandler
:
invoke
...
...
@@ -24,7 +25,7 @@ export function getLocation ({
if
(
navigator
.
geolocation
)
{
navigator
.
geolocation
.
getCurrentPosition
(
res
=>
resolve
(
res
.
coords
),
reject
,
{
enableHighAccuracy
:
altitude
,
timeout
:
1000
*
100
timeout
:
highAccuracyExpireTime
||
1000
*
100
})
}
else
{
reject
(
new
Error
(
'
device nonsupport geolocation
'
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录