Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Velpro187
uni-app
提交
723195de
U
uni-app
项目概览
Velpro187
/
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,发现更多精彩内容 >>
提交
723195de
编写于
8月 12, 2021
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 兼容 支付宝在开发者工具中没有tempFiles属性
上级
d4437d35
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
443 addition
and
424 deletion
+443
-424
packages/uni-mp-alipay/dist/index.js
packages/uni-mp-alipay/dist/index.js
+430
-421
src/platforms/mp-alipay/runtime/api/protocols.js
src/platforms/mp-alipay/runtime/api/protocols.js
+13
-3
未找到文件。
packages/uni-mp-alipay/dist/index.js
浏览文件 @
723195de
import
Vue
from
'
vue
'
;
function
b64DecodeUnicode
(
str
)
{
return
decodeURIComponent
(
atob
(
str
).
split
(
''
).
map
(
function
(
c
)
{
return
'
%
'
+
(
'
00
'
+
c
.
charCodeAt
(
0
).
toString
(
16
)).
slice
(
-
2
)
}).
join
(
''
))
}
function
getCurrentUserInfo
()
{
const
token
=
(
my
).
getStorageSync
(
'
uni_id_token
'
)
||
''
;
const
tokenArr
=
token
.
split
(
'
.
'
);
if
(
!
token
||
tokenArr
.
length
!==
3
)
{
return
{
uid
:
null
,
role
:
[],
permission
:
[],
tokenExpired
:
0
}
}
let
userInfo
;
try
{
userInfo
=
JSON
.
parse
(
b64DecodeUnicode
(
tokenArr
[
1
]));
}
catch
(
error
)
{
throw
new
Error
(
'
获取当前用户信息出错,详细错误信息为:
'
+
error
.
message
)
}
userInfo
.
tokenExpired
=
userInfo
.
exp
*
1000
;
delete
userInfo
.
exp
;
delete
userInfo
.
iat
;
return
userInfo
}
function
uniIdMixin
(
Vue
)
{
Vue
.
prototype
.
uniIDHasRole
=
function
(
roleId
)
{
const
{
role
}
=
getCurrentUserInfo
();
return
role
.
indexOf
(
roleId
)
>
-
1
};
Vue
.
prototype
.
uniIDHasPermission
=
function
(
permissionId
)
{
const
{
permission
}
=
getCurrentUserInfo
();
return
this
.
uniIDHasRole
(
'
admin
'
)
||
permission
.
indexOf
(
permissionId
)
>
-
1
};
Vue
.
prototype
.
uniIDTokenValid
=
function
()
{
const
{
tokenExpired
}
=
getCurrentUserInfo
();
return
tokenExpired
>
Date
.
now
()
};
}
import
Vue
from
'
vue
'
;
function
b64DecodeUnicode
(
str
)
{
return
decodeURIComponent
(
atob
(
str
).
split
(
''
).
map
(
function
(
c
)
{
return
'
%
'
+
(
'
00
'
+
c
.
charCodeAt
(
0
).
toString
(
16
)).
slice
(
-
2
)
}).
join
(
''
))
}
function
getCurrentUserInfo
()
{
const
token
=
(
my
).
getStorageSync
(
'
uni_id_token
'
)
||
''
;
const
tokenArr
=
token
.
split
(
'
.
'
);
if
(
!
token
||
tokenArr
.
length
!==
3
)
{
return
{
uid
:
null
,
role
:
[],
permission
:
[],
tokenExpired
:
0
}
}
let
userInfo
;
try
{
userInfo
=
JSON
.
parse
(
b64DecodeUnicode
(
tokenArr
[
1
]));
}
catch
(
error
)
{
throw
new
Error
(
'
获取当前用户信息出错,详细错误信息为:
'
+
error
.
message
)
}
userInfo
.
tokenExpired
=
userInfo
.
exp
*
1000
;
delete
userInfo
.
exp
;
delete
userInfo
.
iat
;
return
userInfo
}
function
uniIdMixin
(
Vue
)
{
Vue
.
prototype
.
uniIDHasRole
=
function
(
roleId
)
{
const
{
role
}
=
getCurrentUserInfo
();
return
role
.
indexOf
(
roleId
)
>
-
1
};
Vue
.
prototype
.
uniIDHasPermission
=
function
(
permissionId
)
{
const
{
permission
}
=
getCurrentUserInfo
();
return
this
.
uniIDHasRole
(
'
admin
'
)
||
permission
.
indexOf
(
permissionId
)
>
-
1
};
Vue
.
prototype
.
uniIDTokenValid
=
function
()
{
const
{
tokenExpired
}
=
getCurrentUserInfo
();
return
tokenExpired
>
Date
.
now
()
};
}
const
_toString
=
Object
.
prototype
.
toString
;
const
hasOwnProperty
=
Object
.
prototype
.
hasOwnProperty
;
...
...
@@ -88,8 +88,8 @@ function cached (fn) {
const
camelizeRE
=
/-
(\w)
/g
;
const
camelize
=
cached
((
str
)
=>
{
return
str
.
replace
(
camelizeRE
,
(
_
,
c
)
=>
c
?
c
.
toUpperCase
()
:
''
)
});
});
const
HOOKS
=
[
'
invoke
'
,
'
success
'
,
...
...
@@ -240,15 +240,15 @@ function getApiInterceptorHooks (method) {
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
globalInterceptors
[
hook
].
slice
();
}
});
const
scopedInterceptor
=
scopedInterceptors
[
method
];
if
(
scopedInterceptor
)
{
Object
.
keys
(
scopedInterceptor
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
(
interceptor
[
hook
]
||
[]).
concat
(
scopedInterceptor
[
hook
]);
}
});
}
});
const
scopedInterceptor
=
scopedInterceptors
[
method
];
if
(
scopedInterceptor
)
{
Object
.
keys
(
scopedInterceptor
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
(
interceptor
[
hook
]
||
[]).
concat
(
scopedInterceptor
[
hook
]);
}
});
}
return
interceptor
}
...
...
@@ -278,8 +278,8 @@ const promiseInterceptor = {
return
res
[
0
]
})
}
};
};
const
SYNC_API_RE
=
/^
\$
|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
...
...
@@ -350,8 +350,8 @@ function promisify (name, api) {
}),
...
params
);
})))
}
}
}
const
EPS
=
1
e
-
4
;
const
BASE_DEVICE_WIDTH
=
750
;
let
isIOS
=
false
;
...
...
@@ -392,20 +392,20 @@ function upx2px (number, newDeviceWidth) {
}
}
return
number
<
0
?
-
result
:
result
}
}
const
interceptors
=
{
promiseInterceptor
};
var
baseApi
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
upx2px
:
upx2px
,
addInterceptor
:
addInterceptor
,
removeInterceptor
:
removeInterceptor
,
interceptors
:
interceptors
});
};
var
baseApi
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
upx2px
:
upx2px
,
addInterceptor
:
addInterceptor
,
removeInterceptor
:
removeInterceptor
,
interceptors
:
interceptors
});
class
EventChannel
{
constructor
(
id
,
events
)
{
this
.
id
=
id
;
...
...
@@ -472,8 +472,8 @@ class EventChannel {
type
});
}
}
}
const
eventChannels
=
{};
const
eventChannelStack
=
[];
...
...
@@ -509,8 +509,8 @@ var navigateTo = {
returnValue
(
fromRes
,
toRes
)
{
fromRes
.
eventChannel
=
getEventChannel
();
}
};
};
function
findExistsPageIndex
(
url
)
{
const
pages
=
getCurrentPages
();
let
len
=
pages
.
length
;
...
...
@@ -521,8 +521,8 @@ function findExistsPageIndex (url) {
}
}
return
-
1
}
}
var
redirectTo
=
{
name
(
fromArgs
)
{
if
(
fromArgs
.
exists
===
'
back
'
&&
fromArgs
.
delta
)
{
...
...
@@ -541,69 +541,69 @@ var redirectTo = {
}
}
}
};
function
setStorageSync
(
key
,
data
)
{
return
my
.
setStorageSync
({
key
,
data
})
}
function
getStorageSync
(
key
)
{
const
result
=
my
.
getStorageSync
({
key
});
// 支付宝平台会返回一个 success 值,但是目前测试的结果这个始终是 true。当没有存储数据的时候,其它平台会返回空字符串。
return
result
.
data
!==
null
?
result
.
data
:
''
}
function
removeStorageSync
(
key
)
{
return
my
.
removeStorageSync
({
key
})
}
const
UUID_KEY
=
'
__DC_STAT_UUID
'
;
let
deviceId
;
function
addUuid
(
result
)
{
deviceId
=
deviceId
||
getStorageSync
(
UUID_KEY
);
if
(
!
deviceId
)
{
deviceId
=
Date
.
now
()
+
''
+
Math
.
floor
(
Math
.
random
()
*
1
e7
);
my
.
setStorage
({
key
:
UUID_KEY
,
data
:
deviceId
});
}
result
.
deviceId
=
deviceId
;
}
function
addSafeAreaInsets
(
result
)
{
if
(
result
.
safeArea
)
{
const
safeArea
=
result
.
safeArea
;
result
.
safeAreaInsets
=
{
top
:
safeArea
.
top
,
left
:
safeArea
.
left
,
right
:
result
.
windowWidth
-
safeArea
.
right
,
bottom
:
result
.
windowHeight
-
safeArea
.
bottom
};
}
}
function
normalizePlatform
(
result
)
{
let
platform
=
result
.
platform
?
result
.
platform
.
toLowerCase
()
:
'
devtools
'
;
if
(
!~
[
'
android
'
,
'
ios
'
].
indexOf
(
platform
))
{
platform
=
'
devtools
'
;
}
result
.
platform
=
platform
;
}
var
getSystemInfo
=
{
returnValue
:
function
(
result
)
{
addUuid
(
result
);
addSafeAreaInsets
(
result
);
normalizePlatform
(
result
);
}
};
};
function
setStorageSync
(
key
,
data
)
{
return
my
.
setStorageSync
({
key
,
data
})
}
function
getStorageSync
(
key
)
{
const
result
=
my
.
getStorageSync
({
key
});
// 支付宝平台会返回一个 success 值,但是目前测试的结果这个始终是 true。当没有存储数据的时候,其它平台会返回空字符串。
return
result
.
data
!==
null
?
result
.
data
:
''
}
function
removeStorageSync
(
key
)
{
return
my
.
removeStorageSync
({
key
})
}
const
UUID_KEY
=
'
__DC_STAT_UUID
'
;
let
deviceId
;
function
addUuid
(
result
)
{
deviceId
=
deviceId
||
getStorageSync
(
UUID_KEY
);
if
(
!
deviceId
)
{
deviceId
=
Date
.
now
()
+
''
+
Math
.
floor
(
Math
.
random
()
*
1
e7
);
my
.
setStorage
({
key
:
UUID_KEY
,
data
:
deviceId
});
}
result
.
deviceId
=
deviceId
;
}
function
addSafeAreaInsets
(
result
)
{
if
(
result
.
safeArea
)
{
const
safeArea
=
result
.
safeArea
;
result
.
safeAreaInsets
=
{
top
:
safeArea
.
top
,
left
:
safeArea
.
left
,
right
:
result
.
windowWidth
-
safeArea
.
right
,
bottom
:
result
.
windowHeight
-
safeArea
.
bottom
};
}
}
function
normalizePlatform
(
result
)
{
let
platform
=
result
.
platform
?
result
.
platform
.
toLowerCase
()
:
'
devtools
'
;
if
(
!~
[
'
android
'
,
'
ios
'
].
indexOf
(
platform
))
{
platform
=
'
devtools
'
;
}
result
.
platform
=
platform
;
}
var
getSystemInfo
=
{
returnValue
:
function
(
result
)
{
addUuid
(
result
);
addSafeAreaInsets
(
result
);
normalizePlatform
(
result
);
}
};
// 不支持的 API 列表
const
todos
=
[
'
preloadPage
'
,
...
...
@@ -850,8 +850,17 @@ const protocols = { // 需要做转换的 API 列表
// TODO 有没有返回值还需要测试下
},
chooseImage
:
{
returnValue
:
{
apFilePaths
:
'
tempFilePaths
'
returnValue
(
result
)
{
const
hasTempFilePaths
=
hasOwn
(
result
,
'
tempFilePaths
'
)
&&
result
.
tempFilePaths
if
(
hasOwn
(
result
,
'
apFilePaths
'
)
&&
!
hasTempFilePaths
)
{
result
.
tempFilePaths
=
result
.
apFilePaths
delete
result
.
apFilePaths
}
if
(
!
hasOwn
(
result
,
'
tempFiles
'
)
&&
hasTempFilePaths
)
{
result
.
tempFiles
=
[]
result
.
tempFilePaths
.
forEach
(
tempFilePath
=>
result
.
tempFiles
.
push
({
path
:
tempFilePath
}))
}
return
{}
}
},
previewImage
:
{
...
...
@@ -1079,8 +1088,8 @@ const protocols = { // 需要做转换的 API 列表
result
.
errMsg
=
result
.
resultStatus
;
}
}
};
};
const
CALLBACKS
=
[
'
success
'
,
'
fail
'
,
'
cancel
'
,
'
complete
'
];
function
processCallback
(
methodName
,
method
,
returnValue
)
{
...
...
@@ -1165,8 +1174,8 @@ function wrapper (methodName, method) {
}
}
return
method
}
}
const
todoApis
=
Object
.
create
(
null
);
const
TODOS
=
[
...
...
@@ -1193,15 +1202,15 @@ function createTodoApi (name) {
TODOS
.
forEach
(
function
(
name
)
{
todoApis
[
name
]
=
createTodoApi
(
name
);
});
});
var
providers
=
{
oauth
:
[
'
alipay
'
],
share
:
[
'
alipay
'
],
payment
:
[
'
alipay
'
],
push
:
[
'
alipay
'
]
};
};
function
getProvider
({
service
,
success
,
...
...
@@ -1223,18 +1232,18 @@ function getProvider ({
isFn
(
fail
)
&&
fail
(
res
);
}
isFn
(
complete
)
&&
complete
(
res
);
}
var
extraApi
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
getProvider
:
getProvider
});
}
var
extraApi
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
getProvider
:
getProvider
});
const
getEmitter
=
(
function
()
{
let
Emitter
;
return
function
getUniEmitter
()
{
if
(
!
Emitter
)
{
Emitter
=
new
Vue
();
return
function
getUniEmitter
()
{
if
(
!
Emitter
)
{
Emitter
=
new
Vue
();
}
return
Emitter
}
...
...
@@ -1255,202 +1264,202 @@ function $once () {
}
function
$emit
()
{
return
apply
(
getEmitter
(),
'
$emit
'
,
[...
arguments
])
}
var
eventApi
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
$on
:
$on
,
$off
:
$off
,
$once
:
$once
,
$emit
:
$emit
});
function
createMediaQueryObserver
()
{
const
mediaQueryObserver
=
{};
const
{
windowWidth
,
windowHeight
}
=
my
.
getSystemInfoSync
();
const
orientation
=
windowWidth
<
windowHeight
?
'
portrait
'
:
'
landscape
'
;
mediaQueryObserver
.
observe
=
(
options
,
callback
)
=>
{
let
matches
=
true
;
for
(
const
item
in
options
)
{
const
itemValue
=
item
===
'
orientation
'
?
options
[
item
]
:
Number
(
options
[
item
]);
if
(
options
[
item
]
!==
''
)
{
if
(
item
===
'
width
'
)
{
if
(
itemValue
===
windowWidth
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
minWidth
'
)
{
if
(
windowWidth
>=
itemValue
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
maxWidth
'
)
{
if
(
windowWidth
<=
itemValue
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
height
'
)
{
if
(
itemValue
===
windowHeight
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
minHeight
'
)
{
if
(
windowHeight
>=
itemValue
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
maxHeight
'
)
{
if
(
windowHeight
<=
itemValue
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
orientation
'
)
{
if
(
options
[
item
]
===
orientation
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
}
}
callback
(
matches
);
return
matches
};
mediaQueryObserver
.
disconnect
=
()
=>
{
};
return
mediaQueryObserver
}
function
startGyroscope
(
params
)
{
if
(
hasOwn
(
params
,
'
interval
'
))
{
console
.
warn
(
'
支付宝小程序 startGyroscope暂不支持interval
'
);
}
params
.
success
&&
params
.
success
({
errMsg
:
'
startGyroscope:ok
'
});
params
.
complete
&&
params
.
complete
({
errMsg
:
'
startGyroscope:ok
'
});
}
function
createExecCallback
(
execCallback
)
{
return
function
wrapperExecCallback
(
res
)
{
this
.
actions
.
forEach
((
action
,
index
)
=>
{
(
action
.
_$callbacks
||
[]).
forEach
(
callback
=>
{
callback
(
res
[
index
]);
});
});
if
(
isFn
(
execCallback
))
{
execCallback
(
res
);
}
}
}
function
addCallback
(
callback
)
{
if
(
isFn
(
callback
))
{
const
action
=
this
.
actions
[
this
.
actions
.
length
-
1
];
if
(
action
)
{
(
action
.
_$callbacks
||
(
action
.
_$callbacks
=
[])).
push
(
callback
);
}
}
}
function
createSelectorQuery
()
{
const
query
=
my
.
createSelectorQuery
();
const
oldExec
=
query
.
exec
;
const
oldScrollOffset
=
query
.
scrollOffset
;
const
oldBoundingClientRect
=
query
.
boundingClientRect
;
query
.
exec
=
function
exec
(
callback
)
{
return
oldExec
.
call
(
this
,
createExecCallback
(
callback
).
bind
(
this
))
};
query
.
scrollOffset
=
function
scrollOffset
(
callback
)
{
const
ret
=
oldScrollOffset
.
call
(
this
);
addCallback
.
call
(
this
,
callback
);
return
ret
};
query
.
boundingClientRect
=
function
boundingClientRect
(
callback
)
{
const
ret
=
oldBoundingClientRect
.
call
(
this
);
addCallback
.
call
(
this
,
callback
);
return
ret
};
if
(
!
query
.
fields
)
{
query
.
fields
=
function
({
rect
,
size
,
scrollOffset
}
=
{},
callback
)
{
if
(
rect
||
size
)
{
this
.
boundingClientRect
();
}
if
(
scrollOffset
)
{
this
.
scrollOffset
();
}
addCallback
.
call
(
this
,
callback
);
return
this
};
}
if
(
!
query
.
in
)
{
query
.
in
=
function
()
{
return
this
};
}
return
query
}
function
createIntersectionObserver
(
component
,
options
)
{
if
(
options
&&
options
.
observeAll
)
{
options
.
selectAll
=
options
.
observeAll
;
delete
options
.
observeAll
;
}
return
my
.
createIntersectionObserver
(
options
)
}
var
api
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
startGyroscope
:
startGyroscope
,
createSelectorQuery
:
createSelectorQuery
,
createIntersectionObserver
:
createIntersectionObserver
,
createMediaQueryObserver
:
createMediaQueryObserver
,
setStorageSync
:
setStorageSync
,
getStorageSync
:
getStorageSync
,
removeStorageSync
:
removeStorageSync
});
}
var
eventApi
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
$on
:
$on
,
$off
:
$off
,
$once
:
$once
,
$emit
:
$emit
});
function
createMediaQueryObserver
()
{
const
mediaQueryObserver
=
{};
const
{
windowWidth
,
windowHeight
}
=
my
.
getSystemInfoSync
();
const
orientation
=
windowWidth
<
windowHeight
?
'
portrait
'
:
'
landscape
'
;
mediaQueryObserver
.
observe
=
(
options
,
callback
)
=>
{
let
matches
=
true
;
for
(
const
item
in
options
)
{
const
itemValue
=
item
===
'
orientation
'
?
options
[
item
]
:
Number
(
options
[
item
]);
if
(
options
[
item
]
!==
''
)
{
if
(
item
===
'
width
'
)
{
if
(
itemValue
===
windowWidth
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
minWidth
'
)
{
if
(
windowWidth
>=
itemValue
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
maxWidth
'
)
{
if
(
windowWidth
<=
itemValue
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
height
'
)
{
if
(
itemValue
===
windowHeight
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
minHeight
'
)
{
if
(
windowHeight
>=
itemValue
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
maxHeight
'
)
{
if
(
windowHeight
<=
itemValue
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
if
(
item
===
'
orientation
'
)
{
if
(
options
[
item
]
===
orientation
)
{
matches
=
true
;
}
else
{
matches
=
false
;
callback
(
matches
);
return
matches
}
}
}
}
callback
(
matches
);
return
matches
};
mediaQueryObserver
.
disconnect
=
()
=>
{
};
return
mediaQueryObserver
}
function
startGyroscope
(
params
)
{
if
(
hasOwn
(
params
,
'
interval
'
))
{
console
.
warn
(
'
支付宝小程序 startGyroscope暂不支持interval
'
);
}
params
.
success
&&
params
.
success
({
errMsg
:
'
startGyroscope:ok
'
});
params
.
complete
&&
params
.
complete
({
errMsg
:
'
startGyroscope:ok
'
});
}
function
createExecCallback
(
execCallback
)
{
return
function
wrapperExecCallback
(
res
)
{
this
.
actions
.
forEach
((
action
,
index
)
=>
{
(
action
.
_$callbacks
||
[]).
forEach
(
callback
=>
{
callback
(
res
[
index
]);
});
});
if
(
isFn
(
execCallback
))
{
execCallback
(
res
);
}
}
}
function
addCallback
(
callback
)
{
if
(
isFn
(
callback
))
{
const
action
=
this
.
actions
[
this
.
actions
.
length
-
1
];
if
(
action
)
{
(
action
.
_$callbacks
||
(
action
.
_$callbacks
=
[])).
push
(
callback
);
}
}
}
function
createSelectorQuery
()
{
const
query
=
my
.
createSelectorQuery
();
const
oldExec
=
query
.
exec
;
const
oldScrollOffset
=
query
.
scrollOffset
;
const
oldBoundingClientRect
=
query
.
boundingClientRect
;
query
.
exec
=
function
exec
(
callback
)
{
return
oldExec
.
call
(
this
,
createExecCallback
(
callback
).
bind
(
this
))
};
query
.
scrollOffset
=
function
scrollOffset
(
callback
)
{
const
ret
=
oldScrollOffset
.
call
(
this
);
addCallback
.
call
(
this
,
callback
);
return
ret
};
query
.
boundingClientRect
=
function
boundingClientRect
(
callback
)
{
const
ret
=
oldBoundingClientRect
.
call
(
this
);
addCallback
.
call
(
this
,
callback
);
return
ret
};
if
(
!
query
.
fields
)
{
query
.
fields
=
function
({
rect
,
size
,
scrollOffset
}
=
{},
callback
)
{
if
(
rect
||
size
)
{
this
.
boundingClientRect
();
}
if
(
scrollOffset
)
{
this
.
scrollOffset
();
}
addCallback
.
call
(
this
,
callback
);
return
this
};
}
if
(
!
query
.
in
)
{
query
.
in
=
function
()
{
return
this
};
}
return
query
}
function
createIntersectionObserver
(
component
,
options
)
{
if
(
options
&&
options
.
observeAll
)
{
options
.
selectAll
=
options
.
observeAll
;
delete
options
.
observeAll
;
}
return
my
.
createIntersectionObserver
(
options
)
}
var
api
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
startGyroscope
:
startGyroscope
,
createSelectorQuery
:
createSelectorQuery
,
createIntersectionObserver
:
createIntersectionObserver
,
createMediaQueryObserver
:
createMediaQueryObserver
,
setStorageSync
:
setStorageSync
,
getStorageSync
:
getStorageSync
,
removeStorageSync
:
removeStorageSync
});
const
PAGE_EVENT_HOOKS
=
[
'
onPullDownRefresh
'
,
'
onReachBottom
'
,
...
...
@@ -1966,8 +1975,8 @@ function handleEvent (event) {
)
{
return
ret
[
0
]
}
}
}
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
...
...
@@ -2127,8 +2136,8 @@ function parseBaseApp (vm, {
initHooks
(
appOptions
,
hooks
);
return
appOptions
}
}
function
findVmByVueId
(
vm
,
vuePid
)
{
const
$children
=
vm
.
$children
;
// 优先查找直属(反向查找:https://github.com/dcloudio/uni-app/issues/1200)
...
...
@@ -2165,8 +2174,8 @@ function handleLink (event) {
}
vueOptions
.
parent
=
parentVm
;
}
}
const
isArray
=
Array
.
isArray
;
const
keyList
=
Object
.
keys
;
...
...
@@ -2214,8 +2223,8 @@ function equal (a, b) {
}
return
false
}
}
const
customizeRE
=
/:/g
;
const
customize
=
cached
((
str
)
=>
{
...
...
@@ -2409,8 +2418,8 @@ const handleLink$1 = (function () {
// 支付宝通过 didMount 来实现,先子后父,故等父 ready 之后,统一初始化
(
this
.
_$childVues
||
(
this
.
_$childVues
=
[])).
unshift
(
detail
);
}
})();
})();
function
parseApp
(
vm
)
{
Object
.
defineProperty
(
Vue
.
prototype
,
'
$slots
'
,
{
get
()
{
...
...
@@ -2460,13 +2469,13 @@ function parseApp (vm) {
mocks
,
initRefs
})
}
}
function
createApp
(
vm
)
{
App
(
parseApp
(
vm
));
return
vm
}
}
const
encodeReserveRE
=
/
[
!'()*
]
/g
;
const
encodeReserveReplacer
=
c
=>
'
%
'
+
c
.
charCodeAt
(
0
).
toString
(
16
);
const
commaRE
=
/%2C/g
;
...
...
@@ -2508,8 +2517,8 @@ function stringifyQuery (obj, encodeStr = encode) {
return
encodeStr
(
key
)
+
'
=
'
+
encodeStr
(
val
)
}).
filter
(
x
=>
x
.
length
>
0
).
join
(
'
&
'
)
:
null
;
return
res
?
`?
${
res
}
`
:
''
}
}
const
hooks$1
=
[
'
onShow
'
,
'
onHide
'
,
...
...
@@ -2589,14 +2598,14 @@ function parsePage (vuePageOptions) {
}
return
pageOptions
}
}
function
createPage
(
vuePageOptions
)
{
{
return
Page
(
parsePage
(
vuePageOptions
))
}
}
}
function
initVm
(
VueComponent
)
{
if
(
this
.
$vm
)
{
return
...
...
@@ -2702,25 +2711,25 @@ function parseComponent (vueComponentOptions) {
componentOptions
.
deriveDataFromProps
=
createObserver$1
();
}
else
{
componentOptions
.
didUpdate
=
createObserver$1
(
true
);
}
if
(
Array
.
isArray
(
vueOptions
.
wxsCallMethods
))
{
vueOptions
.
wxsCallMethods
.
forEach
(
callMethod
=>
{
componentOptions
.
methods
[
callMethod
]
=
function
(
args
)
{
return
this
.
$vm
[
callMethod
](
args
)
};
});
}
if
(
Array
.
isArray
(
vueOptions
.
wxsCallMethods
))
{
vueOptions
.
wxsCallMethods
.
forEach
(
callMethod
=>
{
componentOptions
.
methods
[
callMethod
]
=
function
(
args
)
{
return
this
.
$vm
[
callMethod
](
args
)
};
});
}
return
componentOptions
}
}
function
createComponent
(
vueOptions
)
{
{
return
my
.
defineComponent
(
parseComponent
(
vueOptions
))
}
}
}
function
createSubpackageApp
(
vm
)
{
const
appOptions
=
parseApp
(
vm
);
const
app
=
getApp
({
...
...
@@ -2755,27 +2764,27 @@ function createSubpackageApp (vm) {
vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
return
vm
}
function
createPlugin
(
vm
)
{
const
appOptions
=
parseApp
(
vm
);
if
(
isFn
(
appOptions
.
onShow
)
&&
my
.
onAppShow
)
{
my
.
onAppShow
((...
args
)
=>
{
appOptions
.
onShow
.
apply
(
vm
,
args
);
});
}
if
(
isFn
(
appOptions
.
onHide
)
&&
my
.
onAppHide
)
{
my
.
onAppHide
((...
args
)
=>
{
appOptions
.
onHide
.
apply
(
vm
,
args
);
});
}
if
(
isFn
(
appOptions
.
onLaunch
))
{
const
args
=
my
.
getLaunchOptionsSync
&&
my
.
getLaunchOptionsSync
();
appOptions
.
onLaunch
.
call
(
vm
,
args
);
}
return
vm
}
}
function
createPlugin
(
vm
)
{
const
appOptions
=
parseApp
(
vm
);
if
(
isFn
(
appOptions
.
onShow
)
&&
my
.
onAppShow
)
{
my
.
onAppShow
((...
args
)
=>
{
appOptions
.
onShow
.
apply
(
vm
,
args
);
});
}
if
(
isFn
(
appOptions
.
onHide
)
&&
my
.
onAppHide
)
{
my
.
onAppHide
((...
args
)
=>
{
appOptions
.
onHide
.
apply
(
vm
,
args
);
});
}
if
(
isFn
(
appOptions
.
onLaunch
))
{
const
args
=
my
.
getLaunchOptionsSync
&&
my
.
getLaunchOptionsSync
();
appOptions
.
onLaunch
.
call
(
vm
,
args
);
}
return
vm
}
todos
.
forEach
(
todoApi
=>
{
protocols
[
todoApi
]
=
false
;
});
...
...
@@ -2858,7 +2867,7 @@ my.createComponent = createComponent;
my
.
createSubpackageApp
=
createSubpackageApp
;
my
.
createPlugin
=
createPlugin
;
var
uni$1
=
uni
;
export
default
uni$1
;
export
{
createApp
,
createComponent
,
createPage
,
createPlugin
,
createSubpackageApp
};
var
uni$1
=
uni
;
export
default
uni$1
;
export
{
createApp
,
createComponent
,
createPage
,
createPlugin
,
createSubpackageApp
};
src/platforms/mp-alipay/runtime/api/protocols.js
浏览文件 @
723195de
import
{
isPlainObject
isPlainObject
,
hasOwn
}
from
'
uni-shared
'
import
navigateTo
from
'
uni-helpers/navigate-to
'
import
redirectTo
from
'
../../../mp-weixin/helpers/redirect-to
'
...
...
@@ -251,8 +252,17 @@ const protocols = { // 需要做转换的 API 列表
// TODO 有没有返回值还需要测试下
},
chooseImage
:
{
returnValue
:
{
apFilePaths
:
'
tempFilePaths
'
returnValue
(
result
)
{
const
hasTempFilePaths
=
hasOwn
(
result
,
'
tempFilePaths
'
)
&&
result
.
tempFilePaths
if
(
hasOwn
(
result
,
'
apFilePaths
'
)
&&
!
hasTempFilePaths
)
{
result
.
tempFilePaths
=
result
.
apFilePaths
delete
result
.
apFilePaths
}
if
(
!
hasOwn
(
result
,
'
tempFiles
'
)
&&
hasTempFilePaths
)
{
result
.
tempFiles
=
[]
result
.
tempFilePaths
.
forEach
(
tempFilePath
=>
result
.
tempFiles
.
push
({
path
:
tempFilePath
}))
}
return
{}
}
},
previewImage
:
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录