Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
r15132706585
uni-app
提交
1adeedc4
U
uni-app
项目概览
r15132706585
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
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,发现更多精彩内容 >>
提交
1adeedc4
编写于
12月 23, 2018
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
uni-mp-alipay 0.0.5
uni-mp-weixin 0.0.3
上级
564480d9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
62 addition
and
28 deletion
+62
-28
packages/uni-mp-alipay/dist/index.js
packages/uni-mp-alipay/dist/index.js
+23
-2
packages/uni-mp-alipay/package.json
packages/uni-mp-alipay/package.json
+1
-1
packages/uni-mp-weixin/dist/index.js
packages/uni-mp-weixin/dist/index.js
+37
-24
packages/uni-mp-weixin/package.json
packages/uni-mp-weixin/package.json
+1
-1
未找到文件。
packages/uni-mp-alipay/dist/index.js
浏览文件 @
1adeedc4
...
...
@@ -163,8 +163,8 @@ const protocols = { // 需要做转换的 API 列表
res
.
errMsg
=
`
${
methodName
}
:fail
${
res
.
errorMessage
||
res
.
error
}
`
;
delete
res
.
error
;
delete
res
.
errorMessage
;
}
else
{
res
.
errMsg
=
`
${
methodName
}
:ok`
;
}
else
{
res
.
errMsg
=
`
${
methodName
}
:ok`
;
}
return
res
},
...
...
@@ -385,6 +385,27 @@ const protocols = { // 需要做转换的 API 列表
args
:
{
duration
:
false
}
},
login
:
{
name
:
'
getAuthCode
'
,
returnValue
(
result
)
{
result
.
code
=
result
.
authCode
;
}
},
getUserInfo
:
{
name
:
'
getAuthUserInfo
'
,
returnValue
(
result
)
{
result
.
userInfo
=
{
nickName
:
result
.
nickName
,
avatarUrl
:
result
.
avatar
};
}
},
requestPayment
:
{
name
:
'
tradePay
'
,
args
:
{
orderInfo
:
'
orderStr
'
}
}
};
...
...
packages/uni-mp-alipay/package.json
浏览文件 @
1adeedc4
{
"name"
:
"@dcloudio/uni-mp-alipay"
,
"version"
:
"0.0.
4
"
,
"version"
:
"0.0.
5
"
,
"description"
:
"uni-app mp-alipay"
,
"main"
:
"dist/index.js"
,
"scripts"
:
{
...
...
packages/uni-mp-weixin/dist/index.js
浏览文件 @
1adeedc4
...
...
@@ -19,8 +19,13 @@ function hasOwn (obj, key) {
const
SYNC_API_RE
=
/hideKeyboard|upx2px|canIUse|^create|Sync$|Manager$/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
const
CALLBACK_API_RE
=
/^on/
;
function
isContextApi
(
name
)
{
return
CONTEXT_API_RE
.
test
(
name
)
}
function
isSyncApi
(
name
)
{
return
SYNC_API_RE
.
test
(
name
)
}
...
...
@@ -116,64 +121,72 @@ var protocols = {};
const
CALLBACKS
=
[
'
success
'
,
'
fail
'
,
'
cancel
'
,
'
complete
'
];
function
processCallback
(
method
,
returnValue
)
{
function
processCallback
(
method
Name
,
method
,
returnValue
)
{
return
function
(
res
)
{
return
method
(
processReturnValue
(
res
,
returnValue
))
return
method
(
processReturnValue
(
methodName
,
res
,
returnValue
))
}
}
function
processArgs
(
fromArgs
,
argsOption
=
{},
returnValue
=
{}
)
{
function
processArgs
(
methodName
,
fromArgs
,
argsOption
=
{},
returnValue
=
{},
keepFromArgs
=
false
)
{
if
(
isPlainObject
(
fromArgs
))
{
// 一般 api 的参数解析
const
toArgs
=
{};
Object
.
keys
(
fromArgs
).
forEach
(
key
=>
{
const
toArgs
=
keepFromArgs
===
true
?
fromArgs
:
{};
// returnValue 为 false 时,说明是格式化返回值,直接在返回值对象上修改赋值
if
(
isFn
(
argsOption
))
{
argsOption
=
argsOption
(
fromArgs
,
toArgs
)
||
{};
}
for
(
let
key
in
fromArgs
)
{
if
(
hasOwn
(
argsOption
,
key
))
{
let
keyOption
=
argsOption
[
key
];
if
(
isFn
(
keyOption
))
{
keyOption
=
keyOption
(
fromArgs
[
key
],
fromArgs
);
keyOption
=
keyOption
(
fromArgs
[
key
],
fromArgs
,
toArgs
);
}
if
(
!
keyOption
)
{
// 不支持的参数
console
.
warn
(
`
${
微信小程序
}
${
n
ame
}
暂不支持
${
key
}
`
);
console
.
warn
(
`
微信小程序
${
methodN
ame
}
暂不支持
${
key
}
`
);
}
else
if
(
isStr
(
keyOption
))
{
// 重写参数 key
toArgs
[
keyOption
]
=
fromArgs
[
key
];
}
else
if
(
isPlainObject
(
keyOption
))
{
// {name:newName,value:value}可重新指定参数 key:value
toArgs
[
keyOption
.
name
?
keyOption
.
name
:
key
]
=
keyOption
.
value
;
}
}
else
if
(
CALLBACKS
.
includes
(
key
))
{
toArgs
[
key
]
=
processCallback
(
fromArgs
[
key
],
returnValue
);
toArgs
[
key
]
=
processCallback
(
methodName
,
fromArgs
[
key
],
returnValue
);
}
else
{
toArgs
[
key
]
=
fromArgs
[
key
];
if
(
!
keepFromArgs
)
{
toArgs
[
key
]
=
fromArgs
[
key
];
}
}
}
);
}
return
toArgs
}
else
if
(
isFn
(
fromArgs
))
{
fromArgs
=
processCallback
(
fromArgs
,
returnValue
);
fromArgs
=
processCallback
(
methodName
,
fromArgs
,
returnValue
);
}
return
fromArgs
}
function
processReturnValue
(
res
,
returnValue
)
{
return
processArgs
(
res
,
returnValue
)
function
processReturnValue
(
methodName
,
res
,
returnValue
,
keepReturnValue
=
false
)
{
if
(
isFn
(
protocols
.
returnValue
))
{
// 处理通用 returnValue
res
=
protocols
.
returnValue
(
methodName
,
res
);
}
return
processArgs
(
methodName
,
res
,
returnValue
,
{},
keepReturnValue
)
}
function
wrapper
(
n
ame
,
method
)
{
if
(
hasOwn
(
protocols
,
n
ame
))
{
const
protocol
=
protocols
[
n
ame
];
function
wrapper
(
methodN
ame
,
method
)
{
if
(
hasOwn
(
protocols
,
methodN
ame
))
{
const
protocol
=
protocols
[
methodN
ame
];
if
(
!
protocol
)
{
// 暂不支持的 api
return
function
()
{
throw
new
Error
(
`
${
微信小程序
}
暂不支持
${
name
}
`
)
console
.
error
(
`微信小程序 暂不支持
${
methodName
}
`
);
}
}
return
function
(
arg1
,
arg2
)
{
// 目前 api 最多两个参数
return
function
(
arg1
,
arg2
)
{
// 目前 api 最多两个参数
let
options
=
protocol
;
if
(
isFn
(
protocol
))
{
options
=
protocol
(
arg1
);
}
arg1
=
processArgs
(
arg1
,
options
.
args
,
options
.
returnValue
);
arg1
=
processArgs
(
methodName
,
arg1
,
options
.
args
,
options
.
returnValue
);
const
returnValue
=
wx
[
options
.
name
||
n
ame
](
arg1
,
arg2
);
if
(
isSyncApi
(
n
ame
))
{
// 同步 api
return
processReturnValue
(
returnValue
,
options
.
returnValue
)
const
returnValue
=
wx
[
options
.
name
||
methodN
ame
](
arg1
,
arg2
);
if
(
isSyncApi
(
methodN
ame
))
{
// 同步 api
return
processReturnValue
(
methodName
,
returnValue
,
options
.
returnValue
,
isContextApi
(
methodName
)
)
}
return
returnValue
}
...
...
@@ -265,7 +278,7 @@ if (typeof Proxy !== 'undefined') {
if
(
todoApis
[
name
])
{
return
promisify
(
name
,
todoApis
[
name
])
}
if
(
!
wx
.
hasOwnProperty
(
name
))
{
if
(
!
hasOwn
(
wx
,
name
)
&&
!
hasOwn
(
protocols
,
name
))
{
return
}
return
promisify
(
name
,
wrapper
(
name
,
wx
[
name
]))
...
...
@@ -287,7 +300,7 @@ if (typeof Proxy !== 'undefined') {
});
Object
.
keys
(
wx
).
forEach
(
name
=>
{
if
(
wx
.
hasOwnProperty
(
name
))
{
if
(
hasOwn
(
wx
,
name
)
||
hasOwn
(
protocols
,
name
))
{
uni$1
[
name
]
=
promisify
(
name
,
wrapper
(
name
,
wx
[
name
]));
}
});
...
...
packages/uni-mp-weixin/package.json
浏览文件 @
1adeedc4
{
"name"
:
"@dcloudio/uni-mp-weixin"
,
"version"
:
"0.0.
2
"
,
"version"
:
"0.0.
3
"
,
"description"
:
"uni-app mp-weixin"
,
"main"
:
"dist/index.js"
,
"scripts"
:
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录