Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
genary
uni-app
提交
8cd5493e
U
uni-app
项目概览
genary
/
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,发现更多精彩内容 >>
提交
8cd5493e
编写于
12月 07, 2020
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(App): 修复部分 API 缺失详细错误信息的问题
上级
0dfd05e3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
82 addition
and
119 deletion
+82
-119
src/platforms/app-plus/service/api/plugin/get-provider.js
src/platforms/app-plus/service/api/plugin/get-provider.js
+2
-2
src/platforms/app-plus/service/api/plugin/oauth.js
src/platforms/app-plus/service/api/plugin/oauth.js
+4
-12
src/platforms/app-plus/service/api/plugin/payment.js
src/platforms/app-plus/service/api/plugin/payment.js
+9
-11
src/platforms/app-plus/service/api/plugin/share.js
src/platforms/app-plus/service/api/plugin/share.js
+64
-93
src/platforms/app-plus/service/api/util.js
src/platforms/app-plus/service/api/util.js
+3
-1
未找到文件。
src/platforms/app-plus/service/api/plugin/get-provider.js
浏览文件 @
8cd5493e
...
...
@@ -58,7 +58,7 @@ export function getProvider ({
providers
[
service
]((
err
,
provider
)
=>
{
if
(
err
)
{
invoke
(
callbackId
,
{
errMsg
:
'
getProvider:fail
:
'
+
err
.
message
errMsg
:
'
getProvider:fail
'
+
err
.
message
})
}
else
{
invoke
(
callbackId
,
{
...
...
@@ -70,7 +70,7 @@ export function getProvider ({
})
}
else
{
invoke
(
callbackId
,
{
errMsg
:
'
getProvider:fail
:
服务[
'
+
service
+
'
]不支持
'
errMsg
:
'
getProvider:fail
服务[
'
+
service
+
'
]不支持
'
})
}
}
src/platforms/app-plus/service/api/plugin/oauth.js
浏览文件 @
8cd5493e
...
...
@@ -20,6 +20,8 @@ function getService (provider) {
*/
export
function
login
(
params
,
callbackId
)
{
const
provider
=
params
.
provider
||
'
weixin
'
const
errorCallback
=
warpPlusErrorCallback
(
callbackId
,
'
login
'
)
getService
(
provider
).
then
(
service
=>
{
function
login
()
{
service
.
login
(
res
=>
{
...
...
@@ -29,12 +31,7 @@ export function login (params, callbackId) {
authResult
:
authResult
,
errMsg
:
'
login:ok
'
})
},
err
=>
{
invoke
(
callbackId
,
{
code
:
err
.
code
,
errMsg
:
'
login:fail:
'
+
err
.
message
})
},
provider
===
'
apple
'
?
{
scope
:
'
email
'
}
:
params
.
univerifyStyle
||
{})
},
errorCallback
,
provider
===
'
apple
'
?
{
scope
:
'
email
'
}
:
params
.
univerifyStyle
||
{})
}
// 先注销再登录
// apple登录logout之后无法重新触发获取email,fullname;一键登录无logout
...
...
@@ -43,12 +40,7 @@ export function login (params, callbackId) {
}
else
{
service
.
logout
(
login
,
login
)
}
}).
catch
(
err
=>
{
invoke
(
callbackId
,
{
code
:
err
.
code
||
''
,
errMsg
:
'
login:fail:
'
+
err
.
message
})
})
}).
catch
(
errorCallback
)
}
export
function
getUserInfo
(
params
,
callbackId
)
{
...
...
src/platforms/app-plus/service/api/plugin/payment.js
浏览文件 @
8cd5493e
...
...
@@ -2,29 +2,27 @@ import {
invoke
}
from
'
../../bridge
'
import
{
warpPlusErrorCallback
}
from
'
../util
'
export
function
requestPayment
(
params
,
callbackId
)
{
const
provider
=
params
.
provider
const
errorCallback
=
warpPlusErrorCallback
(
callbackId
,
'
requestPayment
'
)
plus
.
payment
.
getChannels
(
services
=>
{
const
service
=
services
.
find
(({
id
})
=>
id
===
provider
)
if
(
!
service
)
{
invoke
(
callbackId
,
{
errMsg
:
'
requestPayment:fail
:
支付服务[
'
+
provider
+
'
]不存在
'
errMsg
:
'
requestPayment:fail
支付服务[
'
+
provider
+
'
]不存在
'
})
}
else
{
plus
.
payment
.
request
(
service
,
params
.
orderInfo
,
res
=>
{
res
.
errMsg
=
'
requestPayment:ok
'
invoke
(
callbackId
,
res
)
},
err
=>
{
invoke
(
callbackId
,
{
errMsg
:
'
requestPayment:fail:
'
+
err
.
message
})
})
},
errorCallback
)
}
},
err
=>
{
invoke
(
callbackId
,
{
errMsg
:
'
requestPayment:fail:
'
+
err
.
message
})
})
},
errorCallback
)
}
src/platforms/app-plus/service/api/plugin/share.js
浏览文件 @
8cd5493e
...
...
@@ -3,7 +3,8 @@ import {
}
from
'
../constants
'
import
{
getRealPath
getRealPath
,
warpPlusErrorCallback
}
from
'
../util
'
import
{
...
...
@@ -82,19 +83,13 @@ const parseParams = (args, callbackId, method) => {
}
const
sendShareMsg
=
function
(
service
,
params
,
callbackId
,
method
=
'
share
'
)
{
service
.
send
(
params
,
()
=>
{
invoke
(
callbackId
,
{
errMsg
:
method
+
'
:ok
'
})
},
err
=>
{
invoke
(
callbackId
,
{
errMsg
:
method
+
'
:fail:
'
+
err
.
message
})
}
)
const
errorCallback
=
warpPlusErrorCallback
(
callbackId
,
method
)
service
.
send
(
params
,
()
=>
{
invoke
(
callbackId
,
{
errMsg
:
method
+
'
:ok
'
})
},
errorCallback
)
}
export
function
shareAppMessageDirectly
({
...
...
@@ -117,37 +112,24 @@ export function shareAppMessageDirectly ({
'
shareAppMessageDirectly
'
)
}
const
errorCallback
=
warpPlusErrorCallback
(
callbackId
,
'
shareAppMessageDirectly
'
)
if
(
useDefaultSnapshot
)
{
const
pages
=
getCurrentPages
()
const
webview
=
plus
.
webview
.
getWebviewById
(
pages
[
pages
.
length
-
1
].
__wxWebviewId__
+
''
)
if
(
webview
)
{
const
bitmap
=
new
plus
.
nativeObj
.
Bitmap
()
webview
.
draw
(
bitmap
,
()
=>
{
const
fileName
=
TEMP_PATH
+
'
/share/snapshot.jpg
'
bitmap
.
save
(
fileName
,
{
overwrite
:
true
,
format
:
'
jpg
'
},
()
=>
{
imageUrl
=
fileName
goShare
()
},
err
=>
{
invoke
(
callbackId
,
{
errMsg
:
'
shareAppMessageDirectly:fail:
'
+
err
.
message
})
}
)
},
err
=>
{
invoke
(
callbackId
,
{
errMsg
:
'
shareAppMessageDirectly:fail:
'
+
err
.
message
})
}
)
webview
.
draw
(
bitmap
,
()
=>
{
const
fileName
=
TEMP_PATH
+
'
/share/snapshot.jpg
'
bitmap
.
save
(
fileName
,
{
overwrite
:
true
,
format
:
'
jpg
'
},
()
=>
{
imageUrl
=
fileName
goShare
()
},
errorCallback
)
},
errorCallback
)
}
else
{
goShare
()
}
...
...
@@ -158,73 +140,62 @@ export function shareAppMessageDirectly ({
export
function
share
(
params
,
callbackId
,
method
=
'
share
'
)
{
params
=
parseParams
(
params
,
callbackId
,
method
)
const
errorCallback
=
warpPlusErrorCallback
(
callbackId
,
method
)
if
(
typeof
params
===
'
string
'
)
{
return
invoke
(
callbackId
,
{
errMsg
:
method
+
'
:fail
:
'
+
params
errMsg
:
method
+
'
:fail
'
+
params
})
}
const
provider
=
params
.
provider
plus
.
share
.
getServices
(
services
=>
{
const
service
=
services
.
find
(({
id
})
=>
id
===
provider
)
if
(
!
service
)
{
invoke
(
callbackId
,
{
errMsg
:
method
+
'
:fail:分享服务[
'
+
provider
+
'
]不存在
'
})
}
else
{
if
(
service
.
authenticated
)
{
sendShareMsg
(
service
,
params
,
callbackId
)
}
else
{
service
.
authorize
(
()
=>
sendShareMsg
(
service
,
params
,
callbackId
),
err
=>
{
invoke
(
callbackId
,
{
errMsg
:
method
+
'
:fail:
'
+
err
.
message
})
}
)
}
}
},
err
=>
{
plus
.
share
.
getServices
(
services
=>
{
const
service
=
services
.
find
(({
id
})
=>
id
===
provider
)
if
(
!
service
)
{
invoke
(
callbackId
,
{
errMsg
:
method
+
'
:fail
:
'
+
err
.
message
errMsg
:
method
+
'
:fail
分享服务[
'
+
provider
+
'
]不存在
'
})
}
else
{
if
(
service
.
authenticated
)
{
sendShareMsg
(
service
,
params
,
callbackId
)
}
else
{
service
.
authorize
(
()
=>
sendShareMsg
(
service
,
params
,
callbackId
),
errorCallback
)
}
}
)
},
errorCallback
)
}
export
function
shareWithSystem
(
params
,
callbackId
,
method
=
'
shareWithSystem
'
)
{
let
{
type
,
imageUrl
,
summary
:
content
,
href
export
function
shareWithSystem
(
params
,
callbackId
,
method
=
'
shareWithSystem
'
)
{
let
{
type
,
imageUrl
,
summary
:
content
,
href
}
=
params
type
=
type
||
'
text
'
const
allowedTypes
=
[
'
text
'
,
'
image
'
]
if
(
allowedTypes
.
indexOf
(
type
)
<
0
)
{
invoke
(
callbackId
,
{
errMsg
:
method
+
'
:fail:分享参数 type 不正确
'
})
}
if
(
typeof
imageUrl
===
'
string
'
&&
imageUrl
)
{
imageUrl
=
getRealPath
(
imageUrl
)
const
allowedTypes
=
[
'
text
'
,
'
image
'
]
const
errorCallback
=
warpPlusErrorCallback
(
callbackId
,
method
)
if
(
allowedTypes
.
indexOf
(
type
)
<
0
)
{
invoke
(
callbackId
,
{
errMsg
:
method
+
'
:fail 分享参数 type 不正确
'
})
}
if
(
typeof
imageUrl
===
'
string
'
&&
imageUrl
)
{
imageUrl
=
getRealPath
(
imageUrl
)
}
plus
.
share
.
sendWithSystem
({
type
,
pictures
:
imageUrl
&&
[
imageUrl
],
content
,
href
plus
.
share
.
sendWithSystem
({
type
,
pictures
:
imageUrl
&&
[
imageUrl
],
content
,
href
},
function
(
res
)
{
invoke
(
callbackId
,
{
errMsg
:
method
+
'
:ok
'
})
},
function
(
err
)
{
invoke
(
callbackId
,
{
errMsg
:
method
+
'
:fail:
'
+
err
.
message
})
})
}
},
errorCallback
)
}
src/platforms/app-plus/service/api/util.js
浏览文件 @
8cd5493e
...
...
@@ -190,9 +190,11 @@ export function warpPlusSuccessCallback (callbackId, neme) {
export
function
warpPlusErrorCallback
(
callbackId
,
neme
,
errMsg
)
{
return
function
errorCallback
(
error
)
{
error
=
error
||
{}
const
code
=
error
.
code
||
0
invoke
(
callbackId
,
{
errMsg
:
`
${
neme
}
:fail
${
error
.
message
||
errMsg
||
''
}
`
,
errCode
:
error
.
code
||
0
errCode
:
code
,
code
})
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录