Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
tomleePHP
uni-app
提交
5617c587
U
uni-app
项目概览
tomleePHP
/
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,发现更多精彩内容 >>
提交
5617c587
编写于
8月 28, 2019
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(mp-alipay): getPhoneNumber
上级
0677225f
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
143 addition
and
46 deletion
+143
-46
packages/uni-mp-alipay/dist/index.js
packages/uni-mp-alipay/dist/index.js
+28
-1
packages/uni-mp-baidu/dist/index.js
packages/uni-mp-baidu/dist/index.js
+2
-1
packages/uni-mp-qq/dist/index.js
packages/uni-mp-qq/dist/index.js
+2
-1
packages/uni-mp-toutiao/dist/index.js
packages/uni-mp-toutiao/dist/index.js
+2
-1
packages/uni-mp-weixin/dist/index.js
packages/uni-mp-weixin/dist/index.js
+3
-1
packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js
...ni-template-compiler/__tests__/compiler-mp-alipay.spec.js
+45
-38
packages/uni-template-compiler/__tests__/demo.js
packages/uni-template-compiler/__tests__/demo.js
+1
-2
packages/uni-template-compiler/lib/index.js
packages/uni-template-compiler/lib/index.js
+6
-0
packages/uni-template-compiler/lib/module-alipay.js
packages/uni-template-compiler/lib/module-alipay.js
+26
-0
src/platforms/mp-alipay/runtime/wrapper/app-parser.js
src/platforms/mp-alipay/runtime/wrapper/app-parser.js
+28
-1
未找到文件。
packages/uni-mp-alipay/dist/index.js
浏览文件 @
5617c587
...
@@ -1829,6 +1829,33 @@ function parseApp (vm) {
...
@@ -1829,6 +1829,33 @@ function parseApp (vm) {
}
}
});
});
Vue
.
prototype
.
$onAliGetAuthorize
=
function
onAliGetAuthorize
(
method
,
$event
)
{
my
.
getPhoneNumber
({
success
:
(
res
)
=>
{
$event
.
type
=
'
getphonenumber
'
;
const
response
=
JSON
.
parse
(
res
.
response
).
response
;
if
(
response
.
code
===
'
10000
'
)
{
// success
$event
.
detail
.
errMsg
=
'
getPhoneNumber:ok
'
;
$event
.
detail
.
encryptedData
=
res
.
response
;
}
else
{
$event
.
detail
.
errMsg
=
'
getPhoneNumber:fail Error:
'
+
res
.
response
;
}
this
[
method
](
$event
);
},
fail
:
(
res
)
=>
{
$event
.
type
=
'
getphonenumber
'
;
$event
.
detail
.
errMsg
=
'
getPhoneNumber:fail
'
;
this
[
method
](
$event
);
}
});
};
Vue
.
prototype
.
$onAliAuthError
=
function
$onAliAuthError
(
method
,
$event
)
{
$event
.
type
=
'
getphonenumber
'
;
$event
.
detail
.
errMsg
=
'
getPhoneNumber:fail Error:
'
+
$event
.
detail
.
errorMessage
;
this
[
method
](
$event
);
};
return
parseBaseApp
(
vm
,
{
return
parseBaseApp
(
vm
,
{
mocks
,
mocks
,
initRefs
initRefs
...
...
packages/uni-mp-baidu/dist/index.js
浏览文件 @
5617c587
...
@@ -415,7 +415,8 @@ const todos = [
...
@@ -415,7 +415,8 @@ const todos = [
'
stopBeaconDiscovery
'
,
'
stopBeaconDiscovery
'
,
'
hideShareMenu
'
,
'
hideShareMenu
'
,
'
onWindowResize
'
,
'
onWindowResize
'
,
'
offWindowResize
'
'
offWindowResize
'
,
'
vibrate
'
];
];
// 存在兼容性的 API 列表
// 存在兼容性的 API 列表
...
...
packages/uni-mp-qq/dist/index.js
浏览文件 @
5617c587
...
@@ -428,7 +428,8 @@ const todos = [
...
@@ -428,7 +428,8 @@ const todos = [
'
checkIsSoterEnrolledInDevice
'
,
'
checkIsSoterEnrolledInDevice
'
,
'
reportMonitor
'
,
'
reportMonitor
'
,
'
getLogManager
'
,
'
getLogManager
'
,
'
reportAnalytics
'
'
reportAnalytics
'
,
'
vibrate
'
];
];
const
canIUses
=
[
const
canIUses
=
[
'
scanCode
'
,
'
scanCode
'
,
...
...
packages/uni-mp-toutiao/dist/index.js
浏览文件 @
5617c587
...
@@ -451,7 +451,8 @@ const todos = [
...
@@ -451,7 +451,8 @@ const todos = [
'
onWindowResize
'
,
'
onWindowResize
'
,
'
offWindowResize
'
,
'
offWindowResize
'
,
'
compressImage
'
,
'
compressImage
'
,
'
createOffscreenCanvas
'
'
createOffscreenCanvas
'
,
'
vibrate
'
];
];
// 存在兼容性的 API 列表
// 存在兼容性的 API 列表
...
...
packages/uni-mp-weixin/dist/index.js
浏览文件 @
5617c587
...
@@ -387,7 +387,9 @@ var previewImage = {
...
@@ -387,7 +387,9 @@ var previewImage = {
const
protocols
=
{
const
protocols
=
{
previewImage
previewImage
};
};
const
todos
=
[];
const
todos
=
[
'
vibrate
'
];
const
canIUses
=
[];
const
canIUses
=
[];
const
CALLBACKS
=
[
'
success
'
,
'
fail
'
,
'
cancel
'
,
'
complete
'
];
const
CALLBACKS
=
[
'
success
'
,
'
fail
'
,
'
cancel
'
,
'
complete
'
];
...
...
packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js
浏览文件 @
5617c587
...
@@ -104,6 +104,13 @@ describe('mp:compiler-mp-alipay', () => {
...
@@ -104,6 +104,13 @@ describe('mp:compiler-mp-alipay', () => {
)
)
})
})
it
(
'
generate getPhoneNumber
'
,
()
=>
{
assertCodegen
(
'
<button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">获取手机号</button>
'
,
`<button open-type="getAuthorize" scope="phoneNumber" data-event-opts="{{[['getAuthorize',[['$onAliGetAuthorize',['getPhoneNumber','$event']]]],['error',[['$onAliAuthError',['getPhoneNumber','$event']]]]]}}" onGetAuthorize="__e" onError="__e">获取手机号</button>`
)
})
it
(
'
generate events with v-on directive
'
,
()
=>
{
it
(
'
generate events with v-on directive
'
,
()
=>
{
assertCodegen
(
assertCodegen
(
`<uni-list-item title="标题文字" note="描述信息" show-extra-icon="true" :extra-icon="{color: '#4cd964',size: '22',type: 'spinner'}"></uni-list-item>`
,
`<uni-list-item title="标题文字" note="描述信息" show-extra-icon="true" :extra-icon="{color: '#4cd964',size: '22',type: 'spinner'}"></uni-list-item>`
,
...
...
packages/uni-template-compiler/__tests__/demo.js
浏览文件 @
5617c587
const
compiler
=
require
(
'
../lib
'
)
const
compiler
=
require
(
'
../lib
'
)
const
res
=
compiler
.
compile
(
const
res
=
compiler
.
compile
(
`
`
<
view @/
>
<
button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">获取手机号</button
>
`
,
{
`
,
{
resourcePath
:
'
/User/fxy/Documents/test.wxml
'
,
resourcePath
:
'
/User/fxy/Documents/test.wxml
'
,
mp
:
{
mp
:
{
...
...
packages/uni-template-compiler/lib/index.js
浏览文件 @
5617c587
...
@@ -18,6 +18,8 @@ const generateTemplate = require('./template/generate')
...
@@ -18,6 +18,8 @@ const generateTemplate = require('./template/generate')
const
compilerModule
=
require
(
'
./module
'
)
const
compilerModule
=
require
(
'
./module
'
)
const
compilerAlipayModule
=
require
(
'
./module-alipay
'
)
const
generateCodeFrame
=
require
(
'
./codeframe
'
)
const
generateCodeFrame
=
require
(
'
./codeframe
'
)
module
.
exports
=
{
module
.
exports
=
{
...
@@ -28,6 +30,10 @@ module.exports = {
...
@@ -28,6 +30,10 @@ module.exports = {
(
options
.
modules
||
(
options
.
modules
=
[])).
push
(
compilerModule
)
(
options
.
modules
||
(
options
.
modules
=
[])).
push
(
compilerModule
)
if
(
options
.
mp
.
platform
===
'
mp-alipay
'
)
{
options
.
modules
.
push
(
compilerAlipayModule
)
}
const
res
=
compile
(
source
,
Object
.
assign
(
options
,
{
const
res
=
compile
(
source
,
Object
.
assign
(
options
,
{
optimize
:
false
optimize
:
false
}))
}))
...
...
packages/uni-template-compiler/lib/module-alipay.js
0 → 100644
浏览文件 @
5617c587
module
.
exports
=
{
postTransformNode
(
el
)
{
const
attrsMap
=
el
.
attrsMap
if
(
attrsMap
[
'
open-type
'
]
!==
'
getPhoneNumber
'
)
{
return
}
const
getPhoneNumberValue
=
attrsMap
[
'
@getphonenumber
'
]
||
attrsMap
[
'
v-on:getphonenumber
'
]
if
(
!
getPhoneNumberValue
)
{
return
}
el
.
attrs
.
find
(
attr
=>
attr
.
name
===
'
open-type
'
).
value
=
'
"getAuthorize"
'
el
.
attrs
.
push
({
name
:
'
scope
'
,
value
:
'
"phoneNumber"
'
})
delete
el
.
events
[
'
getphonenumber
'
]
el
.
events
[
'
getAuthorize
'
]
=
{
value
:
'
$onAliGetAuthorize(
\'
'
+
getPhoneNumberValue
+
'
\'
,$event)
'
}
el
.
events
[
'
error
'
]
=
{
value
:
'
$onAliAuthError(
\'
'
+
getPhoneNumberValue
+
'
\'
,$event)
'
}
}
}
src/platforms/mp-alipay/runtime/wrapper/app-parser.js
浏览文件 @
5617c587
...
@@ -25,6 +25,33 @@ export default function parseApp (vm) {
...
@@ -25,6 +25,33 @@ export default function parseApp (vm) {
}
}
})
})
Vue
.
prototype
.
$onAliGetAuthorize
=
function
onAliGetAuthorize
(
method
,
$event
)
{
my
.
getPhoneNumber
({
success
:
(
res
)
=>
{
$event
.
type
=
'
getphonenumber
'
const
response
=
JSON
.
parse
(
res
.
response
).
response
if
(
response
.
code
===
'
10000
'
)
{
// success
$event
.
detail
.
errMsg
=
'
getPhoneNumber:ok
'
$event
.
detail
.
encryptedData
=
res
.
response
}
else
{
$event
.
detail
.
errMsg
=
'
getPhoneNumber:fail Error:
'
+
res
.
response
}
this
[
method
](
$event
)
},
fail
:
(
res
)
=>
{
$event
.
type
=
'
getphonenumber
'
$event
.
detail
.
errMsg
=
'
getPhoneNumber:fail
'
this
[
method
](
$event
)
}
})
}
Vue
.
prototype
.
$onAliAuthError
=
function
$onAliAuthError
(
method
,
$event
)
{
$event
.
type
=
'
getphonenumber
'
$event
.
detail
.
errMsg
=
'
getPhoneNumber:fail Error:
'
+
$event
.
detail
.
errorMessage
this
[
method
](
$event
)
}
return
parseBaseApp
(
vm
,
{
return
parseBaseApp
(
vm
,
{
mocks
,
mocks
,
initRefs
initRefs
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录