Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
anyefeiyu
uni-app
提交
29d27d3b
U
uni-app
项目概览
anyefeiyu
/
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,发现更多精彩内容 >>
提交
29d27d3b
编写于
7月 20, 2019
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix invoke
上级
adea1aeb
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
1871 addition
and
1489 deletion
+1871
-1489
packages/uni-app-plus-nvue/dist/uni.js
packages/uni-app-plus-nvue/dist/uni.js
+1662
-1470
src/core/service/api.js
src/core/service/api.js
+13
-0
src/platforms/app-plus/service/api.js
src/platforms/app-plus/service/api.js
+13
-0
src/platforms/app-plus/service/api/popup.js
src/platforms/app-plus/service/api/popup.js
+172
-0
src/platforms/app-plus/service/polyfill.js
src/platforms/app-plus/service/polyfill.js
+0
-0
src/platforms/app-plus/service/uni.js
src/platforms/app-plus/service/uni.js
+11
-19
未找到文件。
packages/uni-app-plus-nvue/dist/uni.js
浏览文件 @
29d27d3b
export
function
createUniInstance
(
weex
,
plus
,
__uniConfig
,
__uniRoutes
,
__registerPage
,
UniServiceJSBridge
,
getApp
,
getCurrentPages
){
var
localStorage
=
plus
.
storage
const
ANI_DURATION
=
300
;
const
ANI_SHOW
=
'
pop-in
'
;
function
showWebview
(
webview
,
animationType
,
animationDuration
)
{
setTimeout
(()
=>
{
webview
.
show
(
animationType
||
ANI_SHOW
,
animationDuration
||
ANI_DURATION
,
()
=>
{
console
.
log
(
'
show.callback
'
);
}
);
},
50
);
}
var
require_context_module_0_5
=
/*#__PURE__*/
Object
.
freeze
({
ANI_DURATION
:
ANI_DURATION
,
showWebview
:
showWebview
});
let
firstBackTime
=
0
;
function
navigateBack
({
delta
,
animationType
,
animationDuration
})
{
const
pages
=
getCurrentPages
();
const
len
=
pages
.
length
-
1
;
const
page
=
pages
[
len
];
if
(
page
.
$page
.
meta
.
isQuit
)
{
if
(
!
firstBackTime
)
{
firstBackTime
=
Date
.
now
();
plus
.
nativeUI
.
toast
(
'
再按一次退出应用
'
);
setTimeout
(()
=>
{
firstBackTime
=
null
;
},
2000
);
}
else
if
(
Date
.
now
()
-
firstBackTime
<
2000
)
{
plus
.
runtime
.
quit
();
}
}
else
{
pages
.
splice
(
len
,
1
);
if
(
animationType
)
{
page
.
$getAppWebview
().
close
(
animationType
,
animationDuration
||
ANI_DURATION
);
}
else
{
page
.
$getAppWebview
().
close
(
'
auto
'
);
}
UniServiceJSBridge
.
emit
(
'
onAppRoute
'
,
{
type
:
'
navigateBack
'
});
}
}
var
require_context_module_0_0
=
/*#__PURE__*/
Object
.
freeze
({
navigateBack
:
navigateBack
});
function
navigateTo
({
url
,
animationType
,
animationDuration
})
{
const
path
=
url
.
split
(
'
?
'
)[
0
];
UniServiceJSBridge
.
emit
(
'
onAppRoute
'
,
{
type
:
'
navigateTo
'
,
path
});
showWebview
(
__registerPage
({
path
}),
animationType
,
animationDuration
);
}
var
require_context_module_0_1
=
/*#__PURE__*/
Object
.
freeze
({
navigateTo
:
navigateTo
});
function
reLaunch
({
path
})
{}
var
require_context_module_0_2
=
/*#__PURE__*/
Object
.
freeze
({
reLaunch
:
reLaunch
});
function
redirectTo
({
path
})
{}
var
require_context_module_0_3
=
/*#__PURE__*/
Object
.
freeze
({
redirectTo
:
redirectTo
});
function
switchTab
({
path
})
{}
var
require_context_module_0_4
=
/*#__PURE__*/
Object
.
freeze
({
switchTab
:
switchTab
});
function
createCommonjsModule
(
fn
,
module
)
{
return
module
=
{
exports
:
{}
},
fn
(
module
,
module
.
exports
),
module
.
exports
;
}
var
base64Arraybuffer
=
createCommonjsModule
(
function
(
module
,
exports
)
{
/*
* base64-arraybuffer
* https://github.com/niklasvh/base64-arraybuffer
*
* Copyright (c) 2012 Niklas von Hertzen
* Licensed under the MIT license.
*/
(
function
(){
var
chars
=
"
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
"
;
// Use a lookup table to find the index.
var
lookup
=
new
Uint8Array
(
256
);
for
(
var
i
=
0
;
i
<
chars
.
length
;
i
++
)
{
lookup
[
chars
.
charCodeAt
(
i
)]
=
i
;
}
exports
.
encode
=
function
(
arraybuffer
)
{
var
bytes
=
new
Uint8Array
(
arraybuffer
),
i
,
len
=
bytes
.
length
,
base64
=
""
;
for
(
i
=
0
;
i
<
len
;
i
+=
3
)
{
base64
+=
chars
[
bytes
[
i
]
>>
2
];
base64
+=
chars
[((
bytes
[
i
]
&
3
)
<<
4
)
|
(
bytes
[
i
+
1
]
>>
4
)];
base64
+=
chars
[((
bytes
[
i
+
1
]
&
15
)
<<
2
)
|
(
bytes
[
i
+
2
]
>>
6
)];
base64
+=
chars
[
bytes
[
i
+
2
]
&
63
];
}
if
((
len
%
3
)
===
2
)
{
base64
=
base64
.
substring
(
0
,
base64
.
length
-
1
)
+
"
=
"
;
}
else
if
(
len
%
3
===
1
)
{
base64
=
base64
.
substring
(
0
,
base64
.
length
-
2
)
+
"
==
"
;
}
return
base64
;
};
exports
.
decode
=
function
(
base64
)
{
var
bufferLength
=
base64
.
length
*
0.75
,
len
=
base64
.
length
,
i
,
p
=
0
,
encoded1
,
encoded2
,
encoded3
,
encoded4
;
if
(
base64
[
base64
.
length
-
1
]
===
"
=
"
)
{
bufferLength
--
;
if
(
base64
[
base64
.
length
-
2
]
===
"
=
"
)
{
bufferLength
--
;
}
}
var
arraybuffer
=
new
ArrayBuffer
(
bufferLength
),
bytes
=
new
Uint8Array
(
arraybuffer
);
for
(
i
=
0
;
i
<
len
;
i
+=
4
)
{
encoded1
=
lookup
[
base64
.
charCodeAt
(
i
)];
encoded2
=
lookup
[
base64
.
charCodeAt
(
i
+
1
)];
encoded3
=
lookup
[
base64
.
charCodeAt
(
i
+
2
)];
encoded4
=
lookup
[
base64
.
charCodeAt
(
i
+
3
)];
bytes
[
p
++
]
=
(
encoded1
<<
2
)
|
(
encoded2
>>
4
);
bytes
[
p
++
]
=
((
encoded2
&
15
)
<<
4
)
|
(
encoded3
>>
2
);
bytes
[
p
++
]
=
((
encoded3
&
3
)
<<
6
)
|
(
encoded4
&
63
);
}
return
arraybuffer
;
};
})();
});
var
base64Arraybuffer_1
=
base64Arraybuffer
.
encode
;
var
base64Arraybuffer_2
=
base64Arraybuffer
.
decode
;
const
base64ToArrayBuffer
=
base64Arraybuffer_2
;
const
arrayBufferToBase64
=
base64Arraybuffer_1
;
var
require_context_module_1_0
=
/*#__PURE__*/
Object
.
freeze
({
base64ToArrayBuffer
:
base64ToArrayBuffer
,
arrayBufferToBase64
:
arrayBufferToBase64
});
const
_toString
=
Object
.
prototype
.
toString
;
const
hasOwnProperty
=
Object
.
prototype
.
hasOwnProperty
;
...
...
@@ -214,21 +25,33 @@ function getLen (str = '') {
return
(
''
+
str
).
replace
(
/
[^\x
00-
\x
ff
]
/g
,
'
**
'
).
length
}
var
platformSchema
=
{};
// TODO 待处理其他 API 的检测
function
canIUse
(
schema
)
{
if
(
hasOwn
(
platformSchema
,
schema
))
{
return
platformSchema
[
schema
]
/**
* 框架内 try-catch
*/
function
tryCatchFramework
(
fn
)
{
return
function
()
{
try
{
return
fn
.
apply
(
fn
,
arguments
)
}
catch
(
e
)
{
// TODO
console
.
error
(
e
);
}
}
}
/**
* 开发者 try-catch
*/
function
tryCatch
(
fn
)
{
return
function
()
{
try
{
return
fn
.
apply
(
fn
,
arguments
)
}
catch
(
e
)
{
// TODO
console
.
error
(
e
);
}
}
return
true
}
var
require_context_module_1_1
=
/*#__PURE__*/
Object
.
freeze
({
canIUse
:
canIUse
});
const
HOOKS
=
[
'
invoke
'
,
'
success
'
,
...
...
@@ -419,559 +242,102 @@ const promiseInterceptor = {
}
};
const
interceptors
=
{
promiseInterceptor
};
var
require_context_module_1_2
=
/*#__PURE__*/
Object
.
freeze
({
interceptors
:
interceptors
,
addInterceptor
:
addInterceptor
,
removeInterceptor
:
removeInterceptor
});
function
pageScrollTo
(
args
)
{
const
pages
=
getCurrentPages
();
if
(
pages
.
length
)
{
UniServiceJSBridge
.
publishHandler
(
'
pageScrollTo
'
,
args
,
pages
[
pages
.
length
-
1
].
$page
.
id
);
}
return
{}
}
const
SYNC_API_RE
=
/^
\$
|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
let
pageId
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
function
setPullDownRefreshPageId
(
pullDownRefreshPageId
)
{
pageId
=
pullDownRefreshPageId
;
const
TASK_APIS
=
[
'
request
'
,
'
downloadFile
'
,
'
uploadFile
'
,
'
connectSocket
'
];
const
CALLBACK_API_RE
=
/^on/
;
function
isContextApi
(
name
)
{
return
CONTEXT_API_RE
.
test
(
name
)
}
function
isSyncApi
(
name
)
{
return
SYNC_API_RE
.
test
(
name
)
}
function
startPullDownRefresh
()
{
if
(
pageId
)
{
UniServiceJSBridge
.
emit
(
pageId
+
'
.stopPullDownRefresh
'
,
{},
pageId
);
}
const
pages
=
getCurrentPages
();
if
(
pages
.
length
)
{
pageId
=
pages
[
pages
.
length
-
1
].
$page
.
id
;
UniServiceJSBridge
.
emit
(
pageId
+
'
.startPullDownRefresh
'
,
{},
pageId
);
}
return
{}
function
isCallbackApi
(
name
)
{
return
CALLBACK_API_RE
.
test
(
name
)
}
function
stopPullDownRefresh
()
{
if
(
pageId
)
{
UniServiceJSBridge
.
emit
(
pageId
+
'
.stopPullDownRefresh
'
,
{},
pageId
);
pageId
=
null
;
}
else
{
const
pages
=
getCurrentPages
();
if
(
pages
.
length
)
{
pageId
=
pages
[
pages
.
length
-
1
].
$page
.
id
;
UniServiceJSBridge
.
emit
(
pageId
+
'
.stopPullDownRefresh
'
,
{},
pageId
);
}
}
return
{}
}
var
require_context_module_1_3
=
/*#__PURE__*/
Object
.
freeze
({
pageScrollTo
:
pageScrollTo
,
setPullDownRefreshPageId
:
setPullDownRefreshPageId
,
startPullDownRefresh
:
startPullDownRefresh
,
stopPullDownRefresh
:
stopPullDownRefresh
});
function
setStorage
({
key
,
data
}
=
{})
{
const
value
=
{
type
:
typeof
data
===
'
object
'
?
'
object
'
:
'
string
'
,
data
:
data
};
localStorage
.
setItem
(
key
,
JSON
.
stringify
(
value
));
const
keyList
=
localStorage
.
getItem
(
'
uni-storage-keys
'
);
if
(
!
keyList
)
{
localStorage
.
setItem
(
'
uni-storage-keys
'
,
JSON
.
stringify
([
key
]));
}
else
{
const
keys
=
JSON
.
parse
(
keyList
);
if
(
keys
.
indexOf
(
key
)
<
0
)
{
keys
.
push
(
key
);
localStorage
.
setItem
(
'
uni-storage-keys
'
,
JSON
.
stringify
(
keys
));
}
}
return
{
errMsg
:
'
setStorage:ok
'
}
}
function
setStorageSync
(
key
,
data
)
{
setStorage
({
key
,
data
});
}
function
getStorage
({
key
}
=
{})
{
const
data
=
localStorage
.
getItem
(
key
);
return
data
?
{
data
:
JSON
.
parse
(
data
).
data
,
errMsg
:
'
getStorage:ok
'
}
:
{
data
:
''
,
errMsg
:
'
getStorage:fail
'
}
function
isTaskApi
(
name
)
{
return
TASK_APIS
.
indexOf
(
name
)
!==
-
1
}
function
getStorageSync
(
key
)
{
const
res
=
getStorage
(
{
key
})
;
return
res
.
data
function
handlePromise
(
promise
)
{
return
promise
.
then
(
data
=>
{
return
[
null
,
data
]
})
.
catch
(
err
=>
[
err
])
}
function
removeStorage
({
key
}
=
{})
{
const
keyList
=
localStorage
.
getItem
(
'
uni-storage-keys
'
);
if
(
keyList
)
{
const
keys
=
JSON
.
parse
(
keyList
);
const
index
=
keys
.
indexOf
(
key
);
keys
.
splice
(
index
,
1
);
localStorage
.
setItem
(
'
uni-storage-keys
'
,
JSON
.
stringify
(
keys
));
}
localStorage
.
removeItem
(
key
);
return
{
errMsg
:
'
removeStorage:ok
'
function
shouldPromise
(
name
)
{
if
(
isContextApi
(
name
)
||
isSyncApi
(
name
)
||
isCallbackApi
(
name
)
)
{
return
false
}
return
true
}
function
removeStorageSync
(
key
)
{
removeStorage
({
key
});
}
function
clearStorage
()
{
localStorage
.
clear
();
return
{
errMsg
:
'
clearStorage:ok
'
function
promisify
(
name
,
api
)
{
if
(
!
shouldPromise
(
name
))
{
return
api
}
}
function
clearStorageSync
()
{
clearStorage
();
}
function
getStorageInfo
()
{
// TODO 暂时先不做大小的转换
const
keyList
=
localStorage
.
getItem
(
'
uni-storage-keys
'
);
return
keyList
?
{
keys
:
JSON
.
parse
(
keyList
),
currentSize
:
0
,
limitSize
:
0
,
errMsg
:
'
getStorageInfo:ok
'
}
:
{
keys
:
''
,
currentSize
:
0
,
limitSize
:
0
,
errMsg
:
'
getStorageInfo:fail
'
return
function
promiseApi
(
options
=
{},
...
params
)
{
if
(
isFn
(
options
.
success
)
||
isFn
(
options
.
fail
)
||
isFn
(
options
.
complete
))
{
return
wrapperReturnValue
(
name
,
invokeApi
(
name
,
api
,
options
,
...
params
))
}
return
wrapperReturnValue
(
name
,
handlePromise
(
new
Promise
((
resolve
,
reject
)
=>
{
invokeApi
(
name
,
api
,
Object
.
assign
({},
options
,
{
success
:
resolve
,
fail
:
reject
}),
...
params
);
/* eslint-disable no-extend-native */
if
(
!
Promise
.
prototype
.
finally
)
{
Promise
.
prototype
.
finally
=
function
(
callback
)
{
const
promise
=
this
.
constructor
;
return
this
.
then
(
value
=>
promise
.
resolve
(
callback
()).
then
(()
=>
value
),
reason
=>
promise
.
resolve
(
callback
()).
then
(()
=>
{
throw
reason
})
)
};
}
})))
}
}
function
getStorageInfoSync
()
{
const
res
=
getStorageInfo
();
delete
res
.
errMsg
;
return
res
}
var
require_context_module_1_4
=
/*#__PURE__*/
Object
.
freeze
({
setStorage
:
setStorage
,
setStorageSync
:
setStorageSync
,
getStorage
:
getStorage
,
getStorageSync
:
getStorageSync
,
removeStorage
:
removeStorage
,
removeStorageSync
:
removeStorageSync
,
clearStorage
:
clearStorage
,
clearStorageSync
:
clearStorageSync
,
getStorageInfo
:
getStorageInfo
,
getStorageInfoSync
:
getStorageInfoSync
const
canIUse
=
[{
name
:
'
schema
'
,
type
:
String
,
required
:
true
}];
var
require_context_module_2_0
=
/*#__PURE__*/
Object
.
freeze
({
canIUse
:
canIUse
});
const
EPS
=
1
e
-
4
;
const
BASE_DEVICE_WIDTH
=
750
;
let
isIOS
=
false
;
let
deviceWidth
=
0
;
let
deviceDPR
=
0
;
function
checkDeviceWidth
()
{
const
{
platform
,
pixelRatio
,
windowWidth
}
=
uni
.
getSystemInfoSync
();
deviceWidth
=
windowWidth
;
deviceDPR
=
pixelRatio
;
isIOS
=
platform
===
'
ios
'
;
}
function
upx2px
(
number
,
newDeviceWidth
)
{
if
(
deviceWidth
===
0
)
{
checkDeviceWidth
();
}
number
=
Number
(
number
);
if
(
number
===
0
)
{
return
0
}
let
result
=
(
number
/
BASE_DEVICE_WIDTH
)
*
(
newDeviceWidth
||
deviceWidth
);
if
(
result
<
0
)
{
result
=
-
result
;
}
result
=
Math
.
floor
(
result
+
EPS
);
if
(
result
===
0
)
{
if
(
deviceDPR
===
1
||
!
isIOS
)
{
return
1
}
else
{
return
0.5
}
}
return
number
<
0
?
-
result
:
result
}
const
base64ToArrayBuffer
=
[{
name
:
'
base64
'
,
type
:
String
,
required
:
true
}];
var
require_context_module_1_5
=
/*#__PURE__*/
Object
.
freeze
({
upx2px
:
upx2px
});
const
base
=
[
'
base64ToArrayBuffer
'
,
'
arrayBufferToBase64
'
];
const
network
=
[
'
request
'
,
'
uploadFile
'
,
'
downloadFile
'
,
'
connectSocket
'
,
'
onSocketOpen
'
,
'
onSocketError
'
,
'
sendSocketMessage
'
,
'
onSocketMessage
'
,
'
closeSocket
'
,
'
onSocketClose
'
];
const
route
=
[
'
navigateTo
'
,
'
redirectTo
'
,
'
reLaunch
'
,
'
switchTab
'
,
'
navigateBack
'
];
const
storage
=
[
'
setStorage
'
,
'
setStorageSync
'
,
'
getStorage
'
,
'
getStorageSync
'
,
'
getStorageInfo
'
,
'
getStorageInfoSync
'
,
'
removeStorage
'
,
'
removeStorageSync
'
,
'
clearStorage
'
,
'
clearStorageSync
'
];
const
location
=
[
'
getLocation
'
,
'
chooseLocation
'
,
'
openLocation
'
,
'
createMapContext
'
];
const
media
=
[
'
chooseImage
'
,
'
previewImage
'
,
'
getImageInfo
'
,
'
saveImageToPhotosAlbum
'
,
'
compressImage
'
,
'
chooseMessageFile
'
,
'
getRecorderManager
'
,
'
getBackgroundAudioManager
'
,
'
createInnerAudioContext
'
,
'
chooseVideo
'
,
'
saveVideoToPhotosAlbum
'
,
'
createVideoContext
'
,
'
createCameraContext
'
,
'
createLivePlayerContext
'
];
const
device
=
[
'
getSystemInfo
'
,
'
getSystemInfoSync
'
,
'
canIUse
'
,
'
onMemoryWarning
'
,
'
getNetworkType
'
,
'
onNetworkStatusChange
'
,
'
onAccelerometerChange
'
,
'
startAccelerometer
'
,
'
stopAccelerometer
'
,
'
onCompassChange
'
,
'
startCompass
'
,
'
stopCompass
'
,
'
onGyroscopeChange
'
,
'
startGyroscope
'
,
'
stopGyroscope
'
,
'
makePhoneCall
'
,
'
scanCode
'
,
'
setClipboardData
'
,
'
getClipboardData
'
,
'
setScreenBrightness
'
,
'
getScreenBrightness
'
,
'
setKeepScreenOn
'
,
'
onUserCaptureScreen
'
,
'
vibrateLong
'
,
'
vibrateShort
'
,
'
addPhoneContact
'
,
'
openBluetoothAdapter
'
,
'
startBluetoothDevicesDiscovery
'
,
'
onBluetoothDeviceFound
'
,
'
stopBluetoothDevicesDiscovery
'
,
'
onBluetoothAdapterStateChange
'
,
'
getConnectedBluetoothDevices
'
,
'
getBluetoothDevices
'
,
'
getBluetoothAdapterState
'
,
'
closeBluetoothAdapter
'
,
'
writeBLECharacteristicValue
'
,
'
readBLECharacteristicValue
'
,
'
onBLEConnectionStateChange
'
,
'
onBLECharacteristicValueChange
'
,
'
notifyBLECharacteristicValueChange
'
,
'
getBLEDeviceServices
'
,
'
getBLEDeviceCharacteristics
'
,
'
createBLEConnection
'
,
'
closeBLEConnection
'
,
'
onBeaconServiceChange
'
,
'
onBeaconUpdate
'
,
'
getBeacons
'
,
'
startBeaconDiscovery
'
,
'
stopBeaconDiscovery
'
];
const
keyboard
=
[
'
hideKeyboard
'
];
const
ui
=
[
'
showToast
'
,
'
hideToast
'
,
'
showLoading
'
,
'
hideLoading
'
,
'
showModal
'
,
'
showActionSheet
'
,
'
setNavigationBarTitle
'
,
'
setNavigationBarColor
'
,
'
showNavigationBarLoading
'
,
'
hideNavigationBarLoading
'
,
'
setTabBarItem
'
,
'
setTabBarStyle
'
,
'
hideTabBar
'
,
'
showTabBar
'
,
'
setTabBarBadge
'
,
'
removeTabBarBadge
'
,
'
showTabBarRedDot
'
,
'
hideTabBarRedDot
'
,
'
setBackgroundColor
'
,
'
setBackgroundTextStyle
'
,
'
createAnimation
'
,
'
pageScrollTo
'
,
'
onWindowResize
'
,
'
offWindowResize
'
,
'
loadFontFace
'
,
'
startPullDownRefresh
'
,
'
stopPullDownRefresh
'
,
'
createSelectorQuery
'
,
'
createIntersectionObserver
'
];
const
event
=
[
'
$emit
'
,
'
$on
'
,
'
$once
'
,
'
$off
'
];
const
file
=
[
'
saveFile
'
,
'
getSavedFileList
'
,
'
getSavedFileInfo
'
,
'
removeSavedFile
'
,
'
getFileInfo
'
,
'
openDocument
'
,
'
getFileSystemManager
'
];
const
canvas
=
[
'
createOffscreenCanvas
'
,
'
createCanvasContext
'
,
'
canvasToTempFilePath
'
,
'
canvasPutImageData
'
,
'
canvasGetImageData
'
];
const
third
=
[
'
getProvider
'
,
'
login
'
,
'
checkSession
'
,
'
getUserInfo
'
,
'
share
'
,
'
showShareMenu
'
,
'
hideShareMenu
'
,
'
requestPayment
'
,
'
subscribePush
'
,
'
unsubscribePush
'
,
'
onPush
'
,
'
offPush
'
,
'
requireNativePlugin
'
,
'
upx2px
'
];
const
apis
=
[
...
base
,
...
network
,
...
route
,
...
storage
,
...
location
,
...
media
,
...
device
,
...
keyboard
,
...
ui
,
...
event
,
...
file
,
...
canvas
,
...
third
];
/**
* 框架内 try-catch
*/
function
tryCatchFramework
(
fn
)
{
return
function
()
{
try
{
return
fn
.
apply
(
fn
,
arguments
)
}
catch
(
e
)
{
// TODO
console
.
error
(
e
);
}
}
}
/**
* 开发者 try-catch
*/
function
tryCatch
(
fn
)
{
return
function
()
{
try
{
return
fn
.
apply
(
fn
,
arguments
)
}
catch
(
e
)
{
// TODO
console
.
error
(
e
);
}
}
}
const
SYNC_API_RE
=
/^
\$
|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
const
TASK_APIS
=
[
'
request
'
,
'
downloadFile
'
,
'
uploadFile
'
,
'
connectSocket
'
];
const
CALLBACK_API_RE
=
/^on/
;
function
isContextApi
(
name
)
{
return
CONTEXT_API_RE
.
test
(
name
)
}
function
isSyncApi
(
name
)
{
return
SYNC_API_RE
.
test
(
name
)
}
function
isCallbackApi
(
name
)
{
return
CALLBACK_API_RE
.
test
(
name
)
}
function
isTaskApi
(
name
)
{
return
TASK_APIS
.
indexOf
(
name
)
!==
-
1
}
function
handlePromise
(
promise
)
{
return
promise
.
then
(
data
=>
{
return
[
null
,
data
]
})
.
catch
(
err
=>
[
err
])
}
function
shouldPromise
(
name
)
{
if
(
isContextApi
(
name
)
||
isSyncApi
(
name
)
||
isCallbackApi
(
name
)
)
{
return
false
}
return
true
}
function
promisify
(
name
,
api
)
{
if
(
!
shouldPromise
(
name
))
{
return
api
}
return
function
promiseApi
(
options
=
{},
...
params
)
{
if
(
isFn
(
options
.
success
)
||
isFn
(
options
.
fail
)
||
isFn
(
options
.
complete
))
{
return
wrapperReturnValue
(
name
,
invokeApi
(
name
,
api
,
options
,
...
params
))
}
return
wrapperReturnValue
(
name
,
handlePromise
(
new
Promise
((
resolve
,
reject
)
=>
{
invokeApi
(
name
,
api
,
Object
.
assign
({},
options
,
{
success
:
resolve
,
fail
:
reject
}),
...
params
);
/* eslint-disable no-extend-native */
if
(
!
Promise
.
prototype
.
finally
)
{
Promise
.
prototype
.
finally
=
function
(
callback
)
{
const
promise
=
this
.
constructor
;
return
this
.
then
(
value
=>
promise
.
resolve
(
callback
()).
then
(()
=>
value
),
reason
=>
promise
.
resolve
(
callback
()).
then
(()
=>
{
throw
reason
})
)
};
}
})))
}
}
const
canIUse$1
=
[{
name
:
'
schema
'
,
type
:
String
,
required
:
true
}];
var
require_context_module_2_0
=
/*#__PURE__*/
Object
.
freeze
({
canIUse
:
canIUse$1
});
const
base64ToArrayBuffer$1
=
[{
name
:
'
base64
'
,
type
:
String
,
required
:
true
}];
const
arrayBufferToBase64$1
=
[{
name
:
'
arrayBuffer
'
,
type
:
[
ArrayBuffer
,
Uint8Array
],
required
:
true
}];
var
require_context_module_2_1
=
/*#__PURE__*/
Object
.
freeze
({
base64ToArrayBuffer
:
base64ToArrayBuffer$1
,
arrayBufferToBase64
:
arrayBufferToBase64$1
const
arrayBufferToBase64
=
[{
name
:
'
arrayBuffer
'
,
type
:
[
ArrayBuffer
,
Uint8Array
],
required
:
true
}];
var
require_context_module_2_1
=
/*#__PURE__*/
Object
.
freeze
({
base64ToArrayBuffer
:
base64ToArrayBuffer
,
arrayBufferToBase64
:
arrayBufferToBase64
});
function
getInt
(
method
)
{
...
...
@@ -1619,888 +985,1417 @@ var require_context_module_2_15 = /*#__PURE__*/Object.freeze({
uploadFile
:
uploadFile
});
const
pageScrollTo$1
=
{
scrollTop
:
{
const
pageScrollTo
=
{
scrollTop
:
{
type
:
Number
,
required
:
true
},
duration
:
{
type
:
Number
,
default
:
300
,
validator
(
duration
,
params
)
{
params
.
duration
=
Math
.
max
(
0
,
duration
);
}
}
};
var
require_context_module_2_16
=
/*#__PURE__*/
Object
.
freeze
({
pageScrollTo
:
pageScrollTo
});
const
service
=
{
OAUTH
:
'
OAUTH
'
,
SHARE
:
'
SHARE
'
,
PAYMENT
:
'
PAYMENT
'
,
PUSH
:
'
PUSH
'
};
const
getProvider
=
{
service
:
{
type
:
String
,
required
:
true
,
validator
(
value
,
params
)
{
value
=
(
value
||
''
).
toUpperCase
();
if
(
value
&&
Object
.
values
(
service
).
indexOf
(
value
)
<
0
)
{
return
'
service error
'
}
}
}
};
var
require_context_module_2_17
=
/*#__PURE__*/
Object
.
freeze
({
getProvider
:
getProvider
});
const
showModal
=
{
title
:
{
type
:
String
,
default
:
''
},
content
:
{
type
:
String
,
default
:
''
},
showCancel
:
{
type
:
Boolean
,
default
:
true
},
cancelText
:
{
type
:
String
,
default
:
'
取消
'
},
cancelColor
:
{
type
:
String
,
default
:
'
#000000
'
},
confirmText
:
{
type
:
String
,
default
:
'
确定
'
},
confirmColor
:
{
type
:
String
,
default
:
'
#007aff
'
},
visible
:
{
type
:
Boolean
,
default
:
true
}
};
const
showToast
=
{
title
:
{
type
:
String
,
default
:
''
},
icon
:
{
default
:
'
success
'
,
validator
(
icon
,
params
)
{
if
([
'
success
'
,
'
loading
'
,
'
none
'
].
indexOf
(
icon
)
===
-
1
)
{
params
.
icon
=
'
success
'
;
}
}
},
image
:
{
type
:
String
,
default
:
''
,
validator
(
image
,
params
)
{
if
(
image
)
{
params
.
image
=
getRealPath
(
image
);
}
}
},
duration
:
{
type
:
Number
,
required
:
true
default
:
1500
},
mask
:
{
type
:
Boolean
,
default
:
false
},
visible
:
{
type
:
Boolean
,
default
:
true
}
};
const
showLoading
=
{
title
:
{
type
:
String
,
default
:
''
},
icon
:
{
type
:
String
,
default
:
'
loading
'
},
duration
:
{
type
:
Number
,
default
:
300
,
validator
(
duration
,
params
)
{
params
.
duration
=
Math
.
max
(
0
,
duration
);
default
:
100000000
// 简单处理 showLoading,直接设置个大值
},
mask
:
{
type
:
Boolean
,
default
:
false
},
visible
:
{
type
:
Boolean
,
default
:
true
}
};
const
showActionSheet
=
{
itemList
:
{
type
:
Array
,
required
:
true
,
validator
(
itemList
,
params
)
{
if
(
!
itemList
.
length
)
{
return
'
parameter.itemList should have at least 1 item
'
}
}
},
itemColor
:
{
type
:
String
,
default
:
'
#000000
'
},
visible
:
{
type
:
Boolean
,
default
:
true
}
};
var
require_context_module_2_16
=
/*#__PURE__*/
Object
.
freeze
({
pageScrollTo
:
pageScrollTo$1
var
require_context_module_2_18
=
/*#__PURE__*/
Object
.
freeze
({
showModal
:
showModal
,
showToast
:
showToast
,
showLoading
:
showLoading
,
showActionSheet
:
showActionSheet
});
function
encodeQueryString
(
url
)
{
if
(
typeof
url
!==
'
string
'
)
{
return
url
}
const
index
=
url
.
indexOf
(
'
?
'
);
if
(
index
===
-
1
)
{
return
url
}
const
query
=
url
.
substr
(
index
+
1
).
trim
().
replace
(
/^
(\?
|#|&
)
/
,
''
);
if
(
!
query
)
{
return
url
}
url
=
url
.
substr
(
0
,
index
);
const
params
=
[];
query
.
split
(
'
&
'
).
forEach
(
param
=>
{
const
parts
=
param
.
replace
(
/
\+
/g
,
'
'
).
split
(
'
=
'
);
const
key
=
parts
.
shift
();
const
val
=
parts
.
length
>
0
?
parts
.
join
(
'
=
'
)
:
''
;
params
.
push
(
key
+
'
=
'
+
encodeURIComponent
(
val
));
});
return
params
.
length
?
url
+
'
?
'
+
params
.
join
(
'
&
'
)
:
url
}
function
createValidator
(
type
)
{
return
function
validator
(
url
,
params
)
{
// 格式化为绝对路径路由
url
=
getRealRoute
(
url
);
const
pagePath
=
url
.
split
(
'
?
'
)[
0
];
// 匹配路由是否存在
const
routeOptions
=
__uniRoutes
.
find
(({
path
,
alias
})
=>
path
===
pagePath
||
alias
===
pagePath
);
if
(
!
routeOptions
)
{
return
'
page `
'
+
url
+
'
` is not found
'
}
// 检测不同类型跳转
if
(
type
===
'
navigateTo
'
||
type
===
'
redirectTo
'
)
{
if
(
routeOptions
.
meta
.
isTabBar
)
{
return
`can not
${
type
}
a tabbar page`
}
}
else
if
(
type
===
'
switchTab
'
)
{
if
(
!
routeOptions
.
meta
.
isTabBar
)
{
return
'
can not switch to no-tabBar page
'
}
}
// tabBar不允许传递参数
if
(
routeOptions
.
meta
.
isTabBar
)
{
url
=
pagePath
;
}
// 首页自动格式化为`/`
if
(
routeOptions
.
meta
.
isEntry
)
{
url
=
url
.
replace
(
routeOptions
.
alias
,
'
/
'
);
}
// 参数格式化
params
.
url
=
encodeQueryString
(
url
);
}
}
function
createProtocol
(
type
,
extras
=
{})
{
return
Object
.
assign
({
url
:
{
type
:
String
,
required
:
true
,
validator
:
createValidator
(
type
)
}
},
extras
)
}
function
createAnimationProtocol
(
animationTypes
)
{
return
{
animationType
:
{
type
:
String
,
validator
(
type
)
{
if
(
type
&&
animationTypes
.
indexOf
(
type
)
===
-
1
)
{
return
'
`
'
+
type
+
'
` is not supported for `animationType` (supported values are: `
'
+
animationTypes
.
join
(
'
`|`
'
)
+
'
`)
'
}
}
},
animationDuration
:
{
type
:
Number
}
}
}
const
redirectTo
=
createProtocol
(
'
redirectTo
'
);
const
reLaunch
=
createProtocol
(
'
reLaunch
'
);
const
navigateTo
=
createProtocol
(
'
navigateTo
'
,
createAnimationProtocol
(
[
'
slide-in-right
'
,
'
slide-in-left
'
,
'
slide-in-top
'
,
'
slide-in-bottom
'
,
'
fade-in
'
,
'
zoom-out
'
,
'
zoom-fade-out
'
,
'
pop-in
'
,
'
none
'
]
));
const
switchTab
=
createProtocol
(
'
switchTab
'
);
const
navigateBack
=
Object
.
assign
({
delta
:
{
type
:
Number
,
validator
(
delta
,
params
)
{
delta
=
parseInt
(
delta
)
||
1
;
params
.
delta
=
Math
.
min
(
getCurrentPages
().
length
-
1
,
delta
);
}
}
},
createAnimationProtocol
(
[
'
slide-out-right
'
,
'
slide-out-left
'
,
'
slide-out-top
'
,
'
slide-out-bottom
'
,
'
fade-out
'
,
'
zoom-in
'
,
'
zoom-fade-in
'
,
'
pop-out
'
,
'
none
'
]
));
var
require_context_module_2_19
=
/*#__PURE__*/
Object
.
freeze
({
redirectTo
:
redirectTo
,
reLaunch
:
reLaunch
,
navigateTo
:
navigateTo
,
switchTab
:
switchTab
,
navigateBack
:
navigateBack
});
const
service
=
{
OAUTH
:
'
OAUTH
'
,
SHARE
:
'
SHARE
'
,
PAYMENT
:
'
PAYMENT
'
,
PUSH
:
'
PUSH
'
};
const
getProvider
=
{
service
:
{
type
:
String
,
required
:
true
,
validator
(
value
,
params
)
{
value
=
(
value
||
''
).
toUpperCase
();
if
(
value
&&
Object
.
values
(
service
).
indexOf
(
value
)
<
0
)
{
return
'
service error
'
}
}
}
};
const
setStorage
=
{
'
key
'
:
{
type
:
String
,
required
:
true
},
'
data
'
:
{
required
:
true
}
};
const
setStorageSync
=
[{
name
:
'
key
'
,
type
:
String
,
required
:
true
},
{
name
:
'
data
'
,
required
:
true
}];
var
require_context_module_2_17
=
/*#__PURE__*/
Object
.
freeze
({
getProvider
:
getProvider
var
require_context_module_2_20
=
/*#__PURE__*/
Object
.
freeze
({
setStorage
:
setStorage
,
setStorageSync
:
setStorageSync
});
const
showModal
=
{
title
:
{
type
:
String
,
default
:
''
},
content
:
{
type
:
String
,
default
:
''
},
showCancel
:
{
type
:
Boolean
,
default
:
true
},
cancelText
:
{
type
:
String
,
default
:
'
取消
'
},
cancelColor
:
{
type
:
String
,
default
:
'
#000000
'
},
confirmText
:
{
type
:
String
,
default
:
'
确定
'
const
indexValidator
=
{
type
:
Number
,
required
:
true
};
const
setTabBarItem
=
{
index
:
indexValidator
,
text
:
{
type
:
String
},
confirmColor
:
{
type
:
String
,
default
:
'
#007aff
'
iconPath
:
{
type
:
String
},
visible
:
{
type
:
Boolean
,
default
:
true
selectedIconPath
:
{
type
:
String
}
};
const
showToast
=
{
title
:
{
type
:
String
,
default
:
''
const
setTabBarStyle
=
{
color
:
{
type
:
String
},
icon
:
{
default
:
'
success
'
,
validator
(
icon
,
params
)
{
if
([
'
success
'
,
'
loading
'
,
'
none
'
].
indexOf
(
icon
)
===
-
1
)
{
params
.
icon
=
'
success
'
;
}
}
selectedColor
:
{
type
:
String
},
image
:
{
backgroundColor
:
{
type
:
String
},
borderStyle
:
{
type
:
String
,
default
:
''
,
validator
(
image
,
params
)
{
if
(
image
)
{
params
.
image
=
getRealPath
(
image
);
validator
(
borderStyle
,
params
)
{
if
(
borderStyle
)
{
params
.
borderStyle
=
borderStyle
===
'
black
'
?
'
black
'
:
'
white
'
;
}
}
},
duration
:
{
type
:
Number
,
default
:
1500
},
mask
:
{
}
};
const
hideTabBar
=
{
animation
:
{
type
:
Boolean
,
default
:
false
},
visible
:
{
type
:
Boolean
,
default
:
true
}
};
const
showLoading
=
{
title
:
{
type
:
String
,
default
:
''
},
icon
:
{
type
:
String
,
default
:
'
loading
'
},
duration
:
{
type
:
Number
,
default
:
100000000
// 简单处理 showLoading,直接设置个大值
},
mask
:
{
const
showTabBar
=
{
animation
:
{
type
:
Boolean
,
default
:
false
},
visible
:
{
type
:
Boolean
,
default
:
true
}
};
const
showActionSheet
=
{
itemList
:
{
type
:
Array
,
const
hideTabBarRedDot
=
{
index
:
indexValidator
};
const
showTabBarRedDot
=
{
index
:
indexValidator
};
const
removeTabBarBadge
=
{
index
:
indexValidator
};
const
setTabBarBadge
=
{
index
:
indexValidator
,
text
:
{
type
:
String
,
required
:
true
,
validator
(
itemLis
t
,
params
)
{
if
(
!
itemList
.
length
)
{
return
'
parameter.itemList should have at least 1 item
'
validator
(
tex
t
,
params
)
{
if
(
getLen
(
text
)
>=
4
)
{
params
.
text
=
'
...
'
;
}
}
},
itemColor
:
{
type
:
String
,
default
:
'
#000000
'
},
visible
:
{
type
:
Boolean
,
default
:
true
}
};
var
require_context_module_2_18
=
/*#__PURE__*/
Object
.
freeze
({
showModal
:
showModal
,
showToast
:
showToast
,
showLoading
:
showLoading
,
showActionSheet
:
showActionSheet
var
require_context_module_2_21
=
/*#__PURE__*/
Object
.
freeze
({
setTabBarItem
:
setTabBarItem
,
setTabBarStyle
:
setTabBarStyle
,
hideTabBar
:
hideTabBar
,
showTabBar
:
showTabBar
,
hideTabBarRedDot
:
hideTabBarRedDot
,
showTabBarRedDot
:
showTabBarRedDot
,
removeTabBarBadge
:
removeTabBarBadge
,
setTabBarBadge
:
setTabBarBadge
});
function
encodeQueryString
(
url
)
{
if
(
typeof
url
!==
'
string
'
)
{
return
url
}
const
index
=
url
.
indexOf
(
'
?
'
);
const
protocol
=
Object
.
create
(
null
);
const
modules
=
(
function
()
{
var
map
=
{
'
./base.js
'
:
require_context_module_2_0
,
'
./base64.js
'
:
require_context_module_2_1
,
'
./canvas.js
'
:
require_context_module_2_2
,
'
./context.js
'
:
require_context_module_2_3
,
'
./device/make-phone-call.js
'
:
require_context_module_2_4
,
'
./file/open-document.js
'
:
require_context_module_2_5
,
'
./location.js
'
:
require_context_module_2_6
,
'
./media/choose-image.js
'
:
require_context_module_2_7
,
'
./media/choose-video.js
'
:
require_context_module_2_8
,
'
./media/get-image-info.js
'
:
require_context_module_2_9
,
'
./media/preview-image.js
'
:
require_context_module_2_10
,
'
./navigation-bar.js
'
:
require_context_module_2_11
,
'
./network/download-file.js
'
:
require_context_module_2_12
,
'
./network/request.js
'
:
require_context_module_2_13
,
'
./network/socket.js
'
:
require_context_module_2_14
,
'
./network/upload-file.js
'
:
require_context_module_2_15
,
'
./page-scroll-to.js
'
:
require_context_module_2_16
,
'
./plugins.js
'
:
require_context_module_2_17
,
'
./popup.js
'
:
require_context_module_2_18
,
'
./route.js
'
:
require_context_module_2_19
,
'
./storage.js
'
:
require_context_module_2_20
,
'
./tab-bar.js
'
:
require_context_module_2_21
,
};
var
req
=
function
req
(
key
)
{
return
map
[
key
]
||
(
function
()
{
throw
new
Error
(
"
Cannot find module '
"
+
key
+
"
'.
"
)
}());
};
req
.
keys
=
function
()
{
return
Object
.
keys
(
map
);
};
return
req
;
})();
if
(
index
===
-
1
)
{
return
url
modules
.
keys
().
forEach
(
function
(
key
)
{
Object
.
assign
(
protocol
,
modules
(
key
));
});
function
validateParam
(
key
,
paramTypes
,
paramsData
)
{
const
paramOptions
=
paramTypes
[
key
];
const
absent
=
!
hasOwn
(
paramsData
,
key
);
let
value
=
paramsData
[
key
];
const
booleanIndex
=
getTypeIndex
(
Boolean
,
paramOptions
.
type
);
if
(
booleanIndex
>
-
1
)
{
if
(
absent
&&
!
hasOwn
(
paramOptions
,
'
default
'
))
{
value
=
false
;
}
}
if
(
value
===
undefined
)
{
if
(
hasOwn
(
paramOptions
,
'
default
'
))
{
const
paramDefault
=
paramOptions
[
'
default
'
];
value
=
isFn
(
paramDefault
)
?
paramDefault
()
:
paramDefault
;
paramsData
[
key
]
=
value
;
// 默认值
}
}
const
query
=
url
.
substr
(
index
+
1
).
trim
().
replace
(
/^
(\?
|#|&
)
/
,
''
);
return
assertParam
(
paramOptions
,
key
,
value
,
absent
,
paramsData
)
}
if
(
!
query
)
{
return
url
function
assertParam
(
paramOptions
,
name
,
value
,
absent
,
paramsData
)
{
if
(
paramOptions
.
required
&&
absent
)
{
return
`Missing required parameter
\`
${
name
}
\`
`
}
url
=
url
.
substr
(
0
,
index
);
const
params
=
[];
query
.
split
(
'
&
'
).
forEach
(
param
=>
{
const
parts
=
param
.
replace
(
/
\+
/g
,
'
'
).
split
(
'
=
'
);
const
key
=
parts
.
shift
();
const
val
=
parts
.
length
>
0
?
parts
.
join
(
'
=
'
)
:
''
;
if
(
value
==
null
&&
!
paramOptions
.
required
)
{
const
validator
=
paramOptions
.
validator
;
if
(
validator
)
{
return
validator
(
value
,
paramsData
)
}
return
}
let
type
=
paramOptions
.
type
;
let
valid
=
!
type
||
type
===
true
;
const
expectedTypes
=
[];
if
(
type
)
{
if
(
!
Array
.
isArray
(
type
))
{
type
=
[
type
];
}
for
(
let
i
=
0
;
i
<
type
.
length
&&
!
valid
;
i
++
)
{
const
assertedType
=
assertType
(
value
,
type
[
i
]);
expectedTypes
.
push
(
assertedType
.
expectedType
||
''
);
valid
=
assertedType
.
valid
;
}
}
params
.
push
(
key
+
'
=
'
+
encodeURIComponent
(
val
));
});
if
(
!
valid
)
{
return
getInvalidTypeMessage
(
name
,
value
,
expectedTypes
)
}
return
params
.
length
?
url
+
'
?
'
+
params
.
join
(
'
&
'
)
:
url
const
validator
=
paramOptions
.
validator
;
if
(
validator
)
{
return
validator
(
value
,
paramsData
)
}
}
function
createValidator
(
type
)
{
return
function
validator
(
url
,
params
)
{
// 格式化为绝对路径路由
url
=
getRealRoute
(
url
);
const
pagePath
=
url
.
split
(
'
?
'
)[
0
];
// 匹配路由是否存在
const
routeOptions
=
__uniRoutes
.
find
(({
path
,
alias
})
=>
path
===
pagePath
||
alias
===
pagePath
);
const
simpleCheckRE
=
/^
(
String|Number|Boolean|Function|Symbol
)
$/
;
if
(
!
routeOptions
)
{
return
'
page `
'
+
url
+
'
` is not found
'
function
assertType
(
value
,
type
)
{
let
valid
;
const
expectedType
=
getType
(
type
);
if
(
simpleCheckRE
.
test
(
expectedType
))
{
const
t
=
typeof
value
;
valid
=
t
===
expectedType
.
toLowerCase
();
if
(
!
valid
&&
t
===
'
object
'
)
{
valid
=
value
instanceof
type
;
}
}
else
if
(
expectedType
===
'
Object
'
)
{
valid
=
isPlainObject
(
value
);
}
else
if
(
expectedType
===
'
Array
'
)
{
valid
=
Array
.
isArray
(
value
);
}
else
{
valid
=
value
instanceof
type
;
}
return
{
valid
,
expectedType
}
}
// 检测不同类型跳转
if
(
type
===
'
navigateTo
'
||
type
===
'
redirectTo
'
)
{
if
(
routeOptions
.
meta
.
isTabBar
)
{
return
`can not
${
type
}
a tabbar page`
}
}
else
if
(
type
===
'
switchTab
'
)
{
if
(
!
routeOptions
.
meta
.
isTabBar
)
{
return
'
can not switch to no-tabBar page
'
}
}
function
getType
(
fn
)
{
const
match
=
fn
&&
fn
.
toString
().
match
(
/^
\s
*function
(\w
+
)
/
);
return
match
?
match
[
1
]
:
''
}
// tabBar不允许传递参数
if
(
routeOptions
.
meta
.
isTabBar
)
{
url
=
pagePath
;
}
function
isSameType
(
a
,
b
)
{
return
getType
(
a
)
===
getType
(
b
)
}
// 首页自动格式化为`/`
if
(
routeOptions
.
meta
.
isEntry
)
{
url
=
url
.
replace
(
routeOptions
.
alias
,
'
/
'
);
function
getTypeIndex
(
type
,
expectedTypes
)
{
if
(
!
Array
.
isArray
(
expectedTypes
))
{
return
isSameType
(
expectedTypes
,
type
)
?
0
:
-
1
}
for
(
let
i
=
0
,
len
=
expectedTypes
.
length
;
i
<
len
;
i
++
)
{
if
(
isSameType
(
expectedTypes
[
i
],
type
))
{
return
i
}
// 参数格式化
params
.
url
=
encodeQueryString
(
url
);
}
return
-
1
}
function
createProtocol
(
type
,
extras
=
{})
{
return
Object
.
assign
({
url
:
{
type
:
String
,
required
:
true
,
validator
:
createValidator
(
type
)
}
},
extras
)
function
getInvalidTypeMessage
(
name
,
value
,
expectedTypes
)
{
let
message
=
`parameter
\`
${
name
}
\`
.`
+
` Expected
${
expectedTypes
.
join
(
'
,
'
)}
`
;
const
expectedType
=
expectedTypes
[
0
];
const
receivedType
=
toRawType
(
value
);
const
expectedValue
=
styleValue
(
value
,
expectedType
);
const
receivedValue
=
styleValue
(
value
,
receivedType
);
if
(
expectedTypes
.
length
===
1
&&
isExplicable
(
expectedType
)
&&
!
isBoolean
(
expectedType
,
receivedType
))
{
message
+=
` with value
${
expectedValue
}
`
;
}
message
+=
`, got
${
receivedType
}
`
;
if
(
isExplicable
(
receivedType
))
{
message
+=
`with value
${
receivedValue
}
.`
;
}
return
message
}
function
createAnimationProtocol
(
animationTypes
)
{
return
{
animationType
:
{
type
:
String
,
validator
(
type
)
{
if
(
type
&&
animationTypes
.
indexOf
(
type
)
===
-
1
)
{
return
'
`
'
+
type
+
'
` is not supported for `animationType` (supported values are: `
'
+
animationTypes
.
join
(
'
`|`
'
)
+
'
`)
'
}
}
},
animationDuration
:
{
type
:
Number
}
function
styleValue
(
value
,
type
)
{
if
(
type
===
'
String
'
)
{
return
`"
${
value
}
"`
}
else
if
(
type
===
'
Number
'
)
{
return
`
${
Number
(
value
)}
`
}
else
{
return
`
${
value
}
`
}
}
const
redirectTo$1
=
createProtocol
(
'
redirectTo
'
);
const
reLaunch$1
=
createProtocol
(
'
reLaunch
'
);
const
navigateTo$1
=
createProtocol
(
'
navigateTo
'
,
createAnimationProtocol
(
[
'
slide-in-right
'
,
'
slide-in-left
'
,
'
slide-in-top
'
,
'
slide-in-bottom
'
,
'
fade-in
'
,
'
zoom-out
'
,
'
zoom-fade-out
'
,
'
pop-in
'
,
'
none
'
]
));
const
explicitTypes
=
[
'
string
'
,
'
number
'
,
'
boolean
'
];
const
switchTab$1
=
createProtocol
(
'
switchTab
'
);
function
isExplicable
(
value
)
{
return
explicitTypes
.
some
(
elem
=>
value
.
toLowerCase
()
===
elem
)
}
const
navigateBack$1
=
Object
.
assign
({
delta
:
{
type
:
Number
,
validator
(
delta
,
params
)
{
delta
=
parseInt
(
delta
)
||
1
;
params
.
delta
=
Math
.
min
(
getCurrentPages
().
length
-
1
,
delta
);
}
}
},
createAnimationProtocol
(
[
'
slide-out-right
'
,
'
slide-out-left
'
,
'
slide-out-top
'
,
'
slide-out-bottom
'
,
'
fade-out
'
,
'
zoom-in
'
,
'
zoom-fade-in
'
,
'
pop-out
'
,
'
none
'
]
));
var
require_context_module_2_19
=
/*#__PURE__*/
Object
.
freeze
({
redirectTo
:
redirectTo$1
,
reLaunch
:
reLaunch$1
,
navigateTo
:
navigateTo$1
,
switchTab
:
switchTab$1
,
navigateBack
:
navigateBack$1
});
function
isBoolean
(...
args
)
{
return
args
.
some
(
elem
=>
elem
.
toLowerCase
()
===
'
boolean
'
)
}
const
setStorage$1
=
{
'
key
'
:
{
type
:
String
,
required
:
true
},
'
data
'
:
{
required
:
true
function
invokeCallbackHandlerFail
(
err
,
apiName
,
callbackId
)
{
const
errMsg
=
`
${
apiName
}
:fail
${
err
}
`
;
console
.
error
(
errMsg
);
if
(
callbackId
===
-
1
)
{
throw
new
Error
(
errMsg
)
}
};
if
(
typeof
callbackId
===
'
number
'
)
{
invokeCallbackHandler
(
callbackId
,
{
errMsg
});
}
return
false
}
const
setStorageSync$1
=
[{
name
:
'
key
'
,
type
:
String
,
required
:
true
},
{
name
:
'
data
'
,
required
:
true
}];
var
require_context_module_2_20
=
/*#__PURE__*/
Object
.
freeze
({
setStorage
:
setStorage$1
,
setStorageSync
:
setStorageSync$1
});
const
indexValidator
=
{
type
:
Number
,
const
callbackApiParamTypes
=
[{
name
:
'
callback
'
,
type
:
Function
,
required
:
true
};
}
]
;
const
setTabBarItem
=
{
index
:
indexValidator
,
text
:
{
type
:
String
},
iconPath
:
{
type
:
String
},
selectedIconPath
:
{
type
:
String
function
validateParams
(
apiName
,
paramsData
,
callbackId
)
{
let
paramTypes
=
protocol
[
apiName
];
if
(
!
paramTypes
&&
isCallbackApi
(
apiName
))
{
paramTypes
=
callbackApiParamTypes
;
}
};
if
(
paramTypes
)
{
if
(
Array
.
isArray
(
paramTypes
)
&&
Array
.
isArray
(
paramsData
))
{
const
paramTypeObj
=
Object
.
create
(
null
);
const
paramsDataObj
=
Object
.
create
(
null
);
const
paramsDataLength
=
paramsData
.
length
;
paramTypes
.
forEach
((
paramType
,
index
)
=>
{
paramTypeObj
[
paramType
.
name
]
=
paramType
;
if
(
paramsDataLength
>
index
)
{
paramsDataObj
[
paramType
.
name
]
=
paramsData
[
index
];
}
});
paramTypes
=
paramTypeObj
;
paramsData
=
paramsDataObj
;
}
const
setTabBarStyle
=
{
color
:
{
type
:
String
},
selectedColor
:
{
type
:
String
},
backgroundColor
:
{
type
:
String
},
borderStyle
:
{
type
:
String
,
validator
(
borderStyle
,
params
)
{
if
(
borderStyle
)
{
params
.
borderStyle
=
borderStyle
===
'
black
'
?
'
black
'
:
'
white
'
;
if
(
isFn
(
paramTypes
.
beforeValidate
))
{
const
err
=
paramTypes
.
beforeValidate
(
paramsData
);
if
(
err
)
{
return
invokeCallbackHandlerFail
(
err
,
apiName
,
callbackId
)
}
}
}
};
const
hideTabBar
=
{
animation
:
{
type
:
Boolean
,
default
:
false
const
keys
=
Object
.
keys
(
paramTypes
);
for
(
let
i
=
0
;
i
<
keys
.
length
;
i
++
)
{
if
(
keys
[
i
]
===
'
beforeValidate
'
)
{
continue
}
const
err
=
validateParam
(
keys
[
i
],
paramTypes
,
paramsData
);
if
(
err
)
{
return
invokeCallbackHandlerFail
(
err
,
apiName
,
callbackId
)
}
}
}
};
return
true
}
const
showTabBar
=
{
animation
:
{
type
:
Boolean
,
default
:
false
}
};
let
invokeCallbackId
=
1
;
const
hideTabBarRedDot
=
{
index
:
indexValidator
};
const
invokeCallbacks
=
{};
const
showTabBarRedDot
=
{
index
:
indexValidator
}
;
function
createKeepAliveApiCallback
(
apiName
,
callback
)
{
const
callbackId
=
invokeCallbackId
++
;
const
invokeCallbackName
=
'
api.
'
+
apiName
+
'
.
'
+
callbackId
;
const
removeTabBarBadge
=
{
index
:
indexValidator
};
const
invokeCallback
=
function
(
res
)
{
callback
(
res
);
};
const
setTabBarBadge
=
{
index
:
indexValidator
,
text
:
{
type
:
String
,
required
:
true
,
validator
(
text
,
params
)
{
if
(
getLen
(
text
)
>=
4
)
{
params
.
text
=
'
...
'
;
}
invokeCallbacks
[
callbackId
]
=
{
name
:
invokeCallbackName
,
keepAlive
:
true
,
callback
:
invokeCallback
};
return
callbackId
}
function
createApiCallback
(
apiName
,
params
=
{},
extras
=
{})
{
if
(
!
isPlainObject
(
params
))
{
return
{
params
}
}
};
var
require_context_module_2_21
=
/*#__PURE__*/
Object
.
freeze
({
setTabBarItem
:
setTabBarItem
,
setTabBarStyle
:
setTabBarStyle
,
hideTabBar
:
hideTabBar
,
showTabBar
:
showTabBar
,
hideTabBarRedDot
:
hideTabBarRedDot
,
showTabBarRedDot
:
showTabBarRedDot
,
removeTabBarBadge
:
removeTabBarBadge
,
setTabBarBadge
:
setTabBarBadge
});
const
protocol
=
Object
.
create
(
null
);
const
modules
=
(
function
()
{
var
map
=
{
'
./base.js
'
:
require_context_module_2_0
,
'
./base64.js
'
:
require_context_module_2_1
,
'
./canvas.js
'
:
require_context_module_2_2
,
'
./context.js
'
:
require_context_module_2_3
,
'
./device/make-phone-call.js
'
:
require_context_module_2_4
,
'
./file/open-document.js
'
:
require_context_module_2_5
,
'
./location.js
'
:
require_context_module_2_6
,
'
./media/choose-image.js
'
:
require_context_module_2_7
,
'
./media/choose-video.js
'
:
require_context_module_2_8
,
'
./media/get-image-info.js
'
:
require_context_module_2_9
,
'
./media/preview-image.js
'
:
require_context_module_2_10
,
'
./navigation-bar.js
'
:
require_context_module_2_11
,
'
./network/download-file.js
'
:
require_context_module_2_12
,
'
./network/request.js
'
:
require_context_module_2_13
,
'
./network/socket.js
'
:
require_context_module_2_14
,
'
./network/upload-file.js
'
:
require_context_module_2_15
,
'
./page-scroll-to.js
'
:
require_context_module_2_16
,
'
./plugins.js
'
:
require_context_module_2_17
,
'
./popup.js
'
:
require_context_module_2_18
,
'
./route.js
'
:
require_context_module_2_19
,
'
./storage.js
'
:
require_context_module_2_20
,
'
./tab-bar.js
'
:
require_context_module_2_21
,
};
var
req
=
function
req
(
key
)
{
return
map
[
key
]
||
(
function
()
{
throw
new
Error
(
"
Cannot find module '
"
+
key
+
"
'.
"
)
}());
};
req
.
keys
=
function
()
{
return
Object
.
keys
(
map
);
};
return
req
;
})();
params
=
Object
.
assign
({},
params
);
modules
.
keys
().
forEach
(
function
(
key
)
{
Object
.
assign
(
protocol
,
modules
(
key
));
});
function
validateParam
(
key
,
paramTypes
,
paramsData
)
{
const
paramOptions
=
paramTypes
[
key
];
const
absent
=
!
hasOwn
(
paramsData
,
key
);
let
value
=
paramsData
[
key
];
const
apiCallbacks
=
{};
for
(
let
name
in
params
)
{
const
param
=
params
[
name
];
if
(
isFn
(
param
))
{
apiCallbacks
[
name
]
=
tryCatch
(
param
);
delete
params
[
name
];
}
}
const
booleanIndex
=
getTypeIndex
(
Boolean
,
paramOptions
.
type
);
if
(
booleanIndex
>
-
1
)
{
if
(
absent
&&
!
hasOwn
(
paramOptions
,
'
default
'
))
{
value
=
false
;
const
{
success
,
fail
,
cancel
,
complete
}
=
apiCallbacks
;
const
hasSuccess
=
isFn
(
success
);
const
hasFail
=
isFn
(
fail
);
const
hasCancel
=
isFn
(
cancel
);
const
hasComplete
=
isFn
(
complete
);
if
(
!
hasSuccess
&&
!
hasFail
&&
!
hasCancel
&&
!
hasComplete
)
{
// 无回调
return
{
params
}
}
if
(
value
===
undefined
)
{
if
(
hasOwn
(
paramOptions
,
'
default
'
))
{
const
paramDefault
=
paramOptions
[
'
default
'
];
value
=
isFn
(
paramDefault
)
?
paramDefault
()
:
paramDefault
;
paramsData
[
key
]
=
value
;
// 默认值
const
wrapperCallbacks
=
{};
for
(
let
name
in
extras
)
{
const
extra
=
extras
[
name
];
if
(
isFn
(
extra
))
{
wrapperCallbacks
[
name
]
=
tryCatchFramework
(
extra
);
delete
extras
[
name
];
}
}
return
assertParam
(
paramOptions
,
key
,
value
,
absent
,
paramsData
)
}
const
{
beforeSuccess
,
afterSuccess
,
beforeFail
,
afterFail
,
beforeCancel
,
afterCancel
,
afterAll
}
=
wrapperCallbacks
;
function
assertParam
(
paramOptions
,
name
,
value
,
absent
,
paramsData
)
{
if
(
paramOptions
.
required
&&
absent
)
{
return
`Missing required parameter
\`
${
name
}
\`
`
}
const
callbackId
=
invokeCallbackId
++
;
const
invokeCallbackName
=
'
api.
'
+
apiName
+
'
.
'
+
callbackId
;
const
invokeCallback
=
function
(
res
)
{
res
.
errMsg
=
res
.
errMsg
||
apiName
+
'
:ok
'
;
const
errMsg
=
res
.
errMsg
;
if
(
errMsg
.
indexOf
(
apiName
+
'
:ok
'
)
===
0
)
{
isFn
(
beforeSuccess
)
&&
beforeSuccess
(
res
);
hasSuccess
&&
success
(
res
);
isFn
(
afterSuccess
)
&&
afterSuccess
(
res
);
}
else
if
(
errMsg
.
indexOf
(
apiName
+
'
:cancel
'
)
===
0
)
{
res
.
errMsg
=
res
.
errMsg
.
replace
(
apiName
+
'
:cancel
'
,
apiName
+
'
:fail cancel
'
);
hasFail
&&
fail
(
res
);
isFn
(
beforeCancel
)
&&
beforeCancel
(
res
);
hasCancel
&&
cancel
(
res
);
isFn
(
afterCancel
)
&&
afterCancel
(
res
);
}
else
if
(
errMsg
.
indexOf
(
apiName
+
'
:fail
'
)
===
0
)
{
isFn
(
beforeFail
)
&&
beforeFail
(
res
);
if
(
value
==
null
&&
!
paramOptions
.
required
)
{
const
validator
=
paramOptions
.
validator
;
if
(
validator
)
{
return
validator
(
value
,
paramsData
)
}
return
}
let
type
=
paramOptions
.
type
;
let
valid
=
!
type
||
type
===
true
;
const
expectedTypes
=
[];
if
(
type
)
{
if
(
!
Array
.
isArray
(
type
))
{
type
=
[
type
];
}
for
(
let
i
=
0
;
i
<
type
.
length
&&
!
valid
;
i
++
)
{
const
assertedType
=
assertType
(
value
,
type
[
i
]);
expectedTypes
.
push
(
assertedType
.
expectedType
||
''
);
valid
=
assertedType
.
valid
;
hasFail
&&
fail
(
res
);
isFn
(
afterFail
)
&&
afterFail
(
res
);
}
}
if
(
!
valid
)
{
return
getInvalidTypeMessage
(
name
,
value
,
expectedTypes
)
}
hasComplete
&&
complete
(
res
);
const
validator
=
paramOptions
.
validator
;
if
(
validator
)
{
return
validator
(
value
,
paramsData
)
isFn
(
afterAll
)
&&
afterAll
(
res
);
};
invokeCallbacks
[
callbackId
]
=
{
name
:
invokeCallbackName
,
callback
:
invokeCallback
};
return
{
params
,
callbackId
}
}
const
simpleCheckRE
=
/^
(
String|Number|Boolean|Function|Symbol
)
$/
;
function
createInvokeCallback
(
apiName
,
params
=
{},
extras
=
{})
{
const
{
params
:
args
,
callbackId
}
=
createApiCallback
(
apiName
,
params
,
extras
);
function
assertType
(
value
,
type
)
{
let
valid
;
const
expectedType
=
getType
(
type
);
if
(
simpleCheckRE
.
test
(
expectedType
))
{
const
t
=
typeof
value
;
valid
=
t
===
expectedType
.
toLowerCase
();
if
(
!
valid
&&
t
===
'
object
'
)
{
valid
=
value
instanceof
type
;
if
(
isPlainObject
(
args
)
&&
!
validateParams
(
apiName
,
args
,
callbackId
))
{
return
{
params
:
args
,
callbackId
:
false
}
}
else
if
(
expectedType
===
'
Object
'
)
{
valid
=
isPlainObject
(
value
);
}
else
if
(
expectedType
===
'
Array
'
)
{
valid
=
Array
.
isArray
(
value
);
}
else
{
valid
=
value
instanceof
type
;
}
return
{
valid
,
expectedType
params
:
args
,
callbackId
}
}
function
getType
(
fn
)
{
const
match
=
fn
&&
fn
.
toString
().
match
(
/^
\s
*function
(\w
+
)
/
);
return
match
?
match
[
1
]
:
''
function
invokeCallbackHandler
(
invokeCallbackId
,
res
)
{
if
(
typeof
invokeCallbackId
===
'
number
'
)
{
const
invokeCallback
=
invokeCallbacks
[
invokeCallbackId
];
if
(
invokeCallback
)
{
if
(
!
invokeCallback
.
keepAlive
)
{
delete
invokeCallbacks
[
invokeCallbackId
];
}
return
invokeCallback
.
callback
(
res
)
}
}
return
res
}
function
isSameType
(
a
,
b
)
{
return
getType
(
a
)
===
getType
(
b
)
function
wrapperUnimplemented
(
name
)
{
return
function
(
args
)
{
console
.
error
(
'
API `
'
+
name
+
'
` is not yet implemented
'
);
}
}
function
getTypeIndex
(
type
,
expectedType
s
)
{
if
(
!
Array
.
isArray
(
expectedTypes
))
{
return
i
sSameType
(
expectedTypes
,
type
)
?
0
:
-
1
function
wrapper
(
name
,
invokeMethod
,
extra
s
)
{
if
(
!
isFn
(
invokeMethod
))
{
return
i
nvokeMethod
}
for
(
let
i
=
0
,
len
=
expectedTypes
.
length
;
i
<
len
;
i
++
)
{
if
(
isSameType
(
expectedTypes
[
i
],
type
))
{
return
i
return
function
(...
args
)
{
if
(
isSyncApi
(
name
))
{
if
(
validateParams
(
name
,
args
,
-
1
))
{
return
invokeMethod
.
apply
(
null
,
args
)
}
}
else
if
(
isCallbackApi
(
name
))
{
if
(
validateParams
(
name
,
args
,
-
1
))
{
return
invokeMethod
(
createKeepAliveApiCallback
(
name
,
args
[
0
]))
}
}
else
{
let
argsObj
=
{};
if
(
args
.
length
)
{
argsObj
=
args
[
0
];
}
const
{
params
,
callbackId
}
=
createInvokeCallback
(
name
,
argsObj
,
extras
);
if
(
callbackId
!==
false
)
{
let
res
;
if
(
isFn
(
params
))
{
res
=
invokeMethod
(
callbackId
);
}
else
{
res
=
invokeMethod
(
params
,
callbackId
);
}
if
(
res
&&
!
isTaskApi
(
name
))
{
res
=
invokeCallbackHandler
(
callbackId
,
res
);
if
(
isPlainObject
(
res
))
{
res
.
errMsg
=
res
.
errMsg
||
name
+
'
:ok
'
;
}
}
return
res
}
}
}
return
-
1
}
}
UniServiceJSBridge
.
publishHandler
=
UniServiceJSBridge
.
emit
;
UniServiceJSBridge
.
invokeCallbackHandler
=
invokeCallbackHandler
;
const
base
=
[
'
base64ToArrayBuffer
'
,
'
arrayBufferToBase64
'
];
function
getInvalidTypeMessage
(
name
,
value
,
expectedTypes
)
{
let
message
=
`parameter
\`
${
name
}
\`
.`
+
` Expected
${
expectedTypes
.
join
(
'
,
'
)}
`
;
const
expectedType
=
expectedTypes
[
0
];
const
receivedType
=
toRawType
(
value
);
const
expectedValue
=
styleValue
(
value
,
expectedType
);
const
receivedValue
=
styleValue
(
value
,
receivedType
);
if
(
expectedTypes
.
length
===
1
&&
isExplicable
(
expectedType
)
&&
!
isBoolean
(
expectedType
,
receivedType
))
{
message
+=
` with value
${
expectedValue
}
`
;
}
message
+=
`, got
${
receivedType
}
`
;
if
(
isExplicable
(
receivedType
))
{
message
+=
`with value
${
receivedValue
}
.`
;
}
return
message
}
const
network
=
[
'
request
'
,
'
uploadFile
'
,
'
downloadFile
'
,
'
connectSocket
'
,
'
onSocketOpen
'
,
'
onSocketError
'
,
'
sendSocketMessage
'
,
'
onSocketMessage
'
,
'
closeSocket
'
,
'
onSocketClose
'
];
const
route
=
[
'
navigateTo
'
,
'
redirectTo
'
,
'
reLaunch
'
,
'
switchTab
'
,
'
navigateBack
'
];
const
storage
=
[
'
setStorage
'
,
'
setStorageSync
'
,
'
getStorage
'
,
'
getStorageSync
'
,
'
getStorageInfo
'
,
'
getStorageInfoSync
'
,
'
removeStorage
'
,
'
removeStorageSync
'
,
'
clearStorage
'
,
'
clearStorageSync
'
];
const
location
=
[
'
getLocation
'
,
'
chooseLocation
'
,
'
openLocation
'
,
'
createMapContext
'
];
const
media
=
[
'
chooseImage
'
,
'
previewImage
'
,
'
getImageInfo
'
,
'
saveImageToPhotosAlbum
'
,
'
compressImage
'
,
'
chooseMessageFile
'
,
'
getRecorderManager
'
,
'
getBackgroundAudioManager
'
,
'
createInnerAudioContext
'
,
'
chooseVideo
'
,
'
saveVideoToPhotosAlbum
'
,
'
createVideoContext
'
,
'
createCameraContext
'
,
'
createLivePlayerContext
'
];
const
device
=
[
'
getSystemInfo
'
,
'
getSystemInfoSync
'
,
'
canIUse
'
,
'
onMemoryWarning
'
,
'
getNetworkType
'
,
'
onNetworkStatusChange
'
,
'
onAccelerometerChange
'
,
'
startAccelerometer
'
,
'
stopAccelerometer
'
,
'
onCompassChange
'
,
'
startCompass
'
,
'
stopCompass
'
,
'
onGyroscopeChange
'
,
'
startGyroscope
'
,
'
stopGyroscope
'
,
'
makePhoneCall
'
,
'
scanCode
'
,
'
setClipboardData
'
,
'
getClipboardData
'
,
'
setScreenBrightness
'
,
'
getScreenBrightness
'
,
'
setKeepScreenOn
'
,
'
onUserCaptureScreen
'
,
'
vibrateLong
'
,
'
vibrateShort
'
,
'
addPhoneContact
'
,
'
openBluetoothAdapter
'
,
'
startBluetoothDevicesDiscovery
'
,
'
onBluetoothDeviceFound
'
,
'
stopBluetoothDevicesDiscovery
'
,
'
onBluetoothAdapterStateChange
'
,
'
getConnectedBluetoothDevices
'
,
'
getBluetoothDevices
'
,
'
getBluetoothAdapterState
'
,
'
closeBluetoothAdapter
'
,
'
writeBLECharacteristicValue
'
,
'
readBLECharacteristicValue
'
,
'
onBLEConnectionStateChange
'
,
'
onBLECharacteristicValueChange
'
,
'
notifyBLECharacteristicValueChange
'
,
'
getBLEDeviceServices
'
,
'
getBLEDeviceCharacteristics
'
,
'
createBLEConnection
'
,
'
closeBLEConnection
'
,
'
onBeaconServiceChange
'
,
'
onBeaconUpdate
'
,
'
getBeacons
'
,
'
startBeaconDiscovery
'
,
'
stopBeaconDiscovery
'
];
function
styleValue
(
value
,
type
)
{
if
(
type
===
'
String
'
)
{
return
`"
${
value
}
"`
}
else
if
(
type
===
'
Number
'
)
{
return
`
${
Number
(
value
)}
`
}
else
{
return
`
${
value
}
`
}
}
const
keyboard
=
[
'
hideKeyboard
'
];
const
explicitTypes
=
[
'
string
'
,
'
number
'
,
'
boolean
'
];
const
ui
=
[
'
showToast
'
,
'
hideToast
'
,
'
showLoading
'
,
'
hideLoading
'
,
'
showModal
'
,
'
showActionSheet
'
,
'
setNavigationBarTitle
'
,
'
setNavigationBarColor
'
,
'
showNavigationBarLoading
'
,
'
hideNavigationBarLoading
'
,
'
setTabBarItem
'
,
'
setTabBarStyle
'
,
'
hideTabBar
'
,
'
showTabBar
'
,
'
setTabBarBadge
'
,
'
removeTabBarBadge
'
,
'
showTabBarRedDot
'
,
'
hideTabBarRedDot
'
,
'
setBackgroundColor
'
,
'
setBackgroundTextStyle
'
,
'
createAnimation
'
,
'
pageScrollTo
'
,
'
onWindowResize
'
,
'
offWindowResize
'
,
'
loadFontFace
'
,
'
startPullDownRefresh
'
,
'
stopPullDownRefresh
'
,
'
createSelectorQuery
'
,
'
createIntersectionObserver
'
];
function
isExplicable
(
value
)
{
return
explicitTypes
.
some
(
elem
=>
value
.
toLowerCase
()
===
elem
)
}
const
event
=
[
'
$emit
'
,
'
$on
'
,
'
$once
'
,
'
$off
'
];
function
isBoolean
(...
args
)
{
return
args
.
some
(
elem
=>
elem
.
toLowerCase
()
===
'
boolean
'
)
}
function
invokeCallbackHandlerFail
(
err
,
apiName
,
callbackId
)
{
const
errMsg
=
`
${
apiName
}
:fail
${
err
}
`
;
console
.
error
(
errMsg
);
if
(
callbackId
===
-
1
)
{
throw
new
Error
(
errMsg
)
}
if
(
typeof
callbackId
===
'
number
'
)
{
invokeCallbackHandler
(
callbackId
,
{
errMsg
});
}
return
false
}
const
file
=
[
'
saveFile
'
,
'
getSavedFileList
'
,
'
getSavedFileInfo
'
,
'
removeSavedFile
'
,
'
getFileInfo
'
,
'
openDocument
'
,
'
getFileSystemManager
'
];
const
callbackApiParamTypes
=
[{
name
:
'
callback
'
,
type
:
Function
,
required
:
true
}];
const
canvas
=
[
'
createOffscreenCanvas
'
,
'
createCanvasContext
'
,
'
canvasToTempFilePath
'
,
'
canvasPutImageData
'
,
'
canvasGetImageData
'
];
function
validateParams
(
apiName
,
paramsData
,
callbackId
)
{
let
paramTypes
=
protocol
[
apiName
];
if
(
!
paramTypes
&&
isCallbackApi
(
apiName
))
{
paramTypes
=
callbackApiParamTypes
;
}
if
(
paramTypes
)
{
if
(
Array
.
isArray
(
paramTypes
)
&&
Array
.
isArray
(
paramsData
))
{
const
paramTypeObj
=
Object
.
create
(
null
);
const
paramsDataObj
=
Object
.
create
(
null
);
const
paramsDataLength
=
paramsData
.
length
;
paramTypes
.
forEach
((
paramType
,
index
)
=>
{
paramTypeObj
[
paramType
.
name
]
=
paramType
;
if
(
paramsDataLength
>
index
)
{
paramsDataObj
[
paramType
.
name
]
=
paramsData
[
index
];
}
});
paramTypes
=
paramTypeObj
;
paramsData
=
paramsDataObj
;
}
const
third
=
[
'
getProvider
'
,
'
login
'
,
'
checkSession
'
,
'
getUserInfo
'
,
'
share
'
,
'
showShareMenu
'
,
'
hideShareMenu
'
,
'
requestPayment
'
,
'
subscribePush
'
,
'
unsubscribePush
'
,
'
onPush
'
,
'
offPush
'
,
'
requireNativePlugin
'
,
'
upx2px
'
];
if
(
isFn
(
paramTypes
.
beforeValidate
))
{
const
err
=
paramTypes
.
beforeValidate
(
paramsData
);
if
(
err
)
{
return
invokeCallbackHandlerFail
(
err
,
apiName
,
callbackId
)
}
}
const
apis
=
[
...
base
,
...
network
,
...
route
,
...
storage
,
...
location
,
...
media
,
...
device
,
...
keyboard
,
...
ui
,
...
event
,
...
file
,
...
canvas
,
...
third
];
function
createCommonjsModule
(
fn
,
module
)
{
return
module
=
{
exports
:
{}
},
fn
(
module
,
module
.
exports
),
module
.
exports
;
}
var
base64Arraybuffer
=
createCommonjsModule
(
function
(
module
,
exports
)
{
/*
* base64-arraybuffer
* https://github.com/niklasvh/base64-arraybuffer
*
* Copyright (c) 2012 Niklas von Hertzen
* Licensed under the MIT license.
*/
(
function
(){
var
chars
=
"
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
"
;
// Use a lookup table to find the index.
var
lookup
=
new
Uint8Array
(
256
);
for
(
var
i
=
0
;
i
<
chars
.
length
;
i
++
)
{
lookup
[
chars
.
charCodeAt
(
i
)]
=
i
;
}
exports
.
encode
=
function
(
arraybuffer
)
{
var
bytes
=
new
Uint8Array
(
arraybuffer
),
i
,
len
=
bytes
.
length
,
base64
=
""
;
for
(
i
=
0
;
i
<
len
;
i
+=
3
)
{
base64
+=
chars
[
bytes
[
i
]
>>
2
];
base64
+=
chars
[((
bytes
[
i
]
&
3
)
<<
4
)
|
(
bytes
[
i
+
1
]
>>
4
)];
base64
+=
chars
[((
bytes
[
i
+
1
]
&
15
)
<<
2
)
|
(
bytes
[
i
+
2
]
>>
6
)];
base64
+=
chars
[
bytes
[
i
+
2
]
&
63
];
}
if
((
len
%
3
)
===
2
)
{
base64
=
base64
.
substring
(
0
,
base64
.
length
-
1
)
+
"
=
"
;
}
else
if
(
len
%
3
===
1
)
{
base64
=
base64
.
substring
(
0
,
base64
.
length
-
2
)
+
"
==
"
;
}
return
base64
;
};
exports
.
decode
=
function
(
base64
)
{
var
bufferLength
=
base64
.
length
*
0.75
,
len
=
base64
.
length
,
i
,
p
=
0
,
encoded1
,
encoded2
,
encoded3
,
encoded4
;
if
(
base64
[
base64
.
length
-
1
]
===
"
=
"
)
{
bufferLength
--
;
if
(
base64
[
base64
.
length
-
2
]
===
"
=
"
)
{
bufferLength
--
;
}
}
var
arraybuffer
=
new
ArrayBuffer
(
bufferLength
),
bytes
=
new
Uint8Array
(
arraybuffer
);
for
(
i
=
0
;
i
<
len
;
i
+=
4
)
{
encoded1
=
lookup
[
base64
.
charCodeAt
(
i
)];
encoded2
=
lookup
[
base64
.
charCodeAt
(
i
+
1
)];
encoded3
=
lookup
[
base64
.
charCodeAt
(
i
+
2
)];
encoded4
=
lookup
[
base64
.
charCodeAt
(
i
+
3
)];
bytes
[
p
++
]
=
(
encoded1
<<
2
)
|
(
encoded2
>>
4
);
bytes
[
p
++
]
=
((
encoded2
&
15
)
<<
4
)
|
(
encoded3
>>
2
);
bytes
[
p
++
]
=
((
encoded3
&
3
)
<<
6
)
|
(
encoded4
&
63
);
}
return
arraybuffer
;
};
})();
});
var
base64Arraybuffer_1
=
base64Arraybuffer
.
encode
;
var
base64Arraybuffer_2
=
base64Arraybuffer
.
decode
;
const
base64ToArrayBuffer$1
=
base64Arraybuffer_2
;
const
arrayBufferToBase64$1
=
base64Arraybuffer_1
;
var
require_context_module_1_0
=
/*#__PURE__*/
Object
.
freeze
({
base64ToArrayBuffer
:
base64ToArrayBuffer$1
,
arrayBufferToBase64
:
arrayBufferToBase64$1
});
var
platformSchema
=
{};
// TODO 待处理其他 API 的检测
const
keys
=
Object
.
keys
(
paramTypes
);
for
(
let
i
=
0
;
i
<
keys
.
length
;
i
++
)
{
if
(
keys
[
i
]
===
'
beforeValidate
'
)
{
continue
}
const
err
=
validateParam
(
keys
[
i
],
paramTypes
,
paramsData
);
if
(
err
)
{
return
invokeCallbackHandlerFail
(
err
,
apiName
,
callbackId
)
}
}
function
canIUse$1
(
schema
)
{
if
(
hasOwn
(
platformSchema
,
schema
))
{
return
platformSchema
[
schema
]
}
return
true
}
var
require_context_module_1_1
=
/*#__PURE__*/
Object
.
freeze
({
canIUse
:
canIUse$1
});
const
interceptors
=
{
promiseInterceptor
};
var
require_context_module_1_2
=
/*#__PURE__*/
Object
.
freeze
({
interceptors
:
interceptors
,
addInterceptor
:
addInterceptor
,
removeInterceptor
:
removeInterceptor
});
function
pageScrollTo$1
(
args
)
{
const
pages
=
getCurrentPages
();
if
(
pages
.
length
)
{
UniServiceJSBridge
.
publishHandler
(
'
pageScrollTo
'
,
args
,
pages
[
pages
.
length
-
1
].
$page
.
id
);
}
return
{}
}
let
invokeCallbackId
=
1
;
const
invokeCallbacks
=
{};
function
createKeepAliveApiCallback
(
apiName
,
callback
)
{
const
callbackId
=
invokeCallbackId
++
;
const
invokeCallbackName
=
'
api.
'
+
apiName
+
'
.
'
+
callbackId
;
const
invokeCallback
=
function
(
res
)
{
callback
(
res
);
};
let
pageId
;
invokeCallbacks
[
callbackId
]
=
{
name
:
invokeCallbackName
,
keepAlive
:
true
,
callback
:
invokeCallback
};
return
callbackId
function
setPullDownRefreshPageId
(
pullDownRefreshPageId
)
{
pageId
=
pullDownRefreshPageId
;
}
function
createApiCallback
(
apiName
,
params
=
{},
extras
=
{})
{
if
(
!
isPlainObject
(
params
))
{
return
{
params
}
function
startPullDownRefresh
()
{
if
(
pageId
)
{
UniServiceJSBridge
.
emit
(
pageId
+
'
.stopPullDownRefresh
'
,
{},
pageId
);
}
params
=
Object
.
assign
({},
params
);
const
apiCallbacks
=
{};
for
(
let
name
in
params
)
{
const
param
=
params
[
name
];
if
(
isFn
(
param
))
{
apiCallbacks
[
name
]
=
tryCatch
(
param
);
delete
params
[
name
];
}
const
pages
=
getCurrentPages
();
if
(
pages
.
length
)
{
pageId
=
pages
[
pages
.
length
-
1
].
$page
.
id
;
UniServiceJSBridge
.
emit
(
pageId
+
'
.startPullDownRefresh
'
,
{},
pageId
);
}
return
{}
}
const
{
success
,
fail
,
cancel
,
complete
}
=
apiCallbacks
;
const
hasSuccess
=
isFn
(
success
);
const
hasFail
=
isFn
(
fail
);
const
hasCancel
=
isFn
(
cancel
);
const
hasComplete
=
isFn
(
complete
);
if
(
!
hasSuccess
&&
!
hasFail
&&
!
hasCancel
&&
!
hasComplete
)
{
// 无回调
return
{
params
}
function
stopPullDownRefresh
()
{
if
(
pageId
)
{
UniServiceJSBridge
.
emit
(
pageId
+
'
.stopPullDownRefresh
'
,
{},
pageId
);
pageId
=
null
;
}
else
{
const
pages
=
getCurrentPages
();
if
(
pages
.
length
)
{
pageId
=
pages
[
pages
.
length
-
1
].
$page
.
id
;
UniServiceJSBridge
.
emit
(
pageId
+
'
.stopPullDownRefresh
'
,
{},
pageId
);
}
}
const
wrapperCallbacks
=
{};
for
(
let
name
in
extras
)
{
const
extra
=
extras
[
name
];
if
(
isFn
(
extra
))
{
wrapperCallbacks
[
name
]
=
tryCatchFramework
(
extra
);
delete
extras
[
name
];
return
{}
}
var
require_context_module_1_3
=
/*#__PURE__*/
Object
.
freeze
({
pageScrollTo
:
pageScrollTo$1
,
setPullDownRefreshPageId
:
setPullDownRefreshPageId
,
startPullDownRefresh
:
startPullDownRefresh
,
stopPullDownRefresh
:
stopPullDownRefresh
});
function
setStorage$1
({
key
,
data
}
=
{})
{
const
value
=
{
type
:
typeof
data
===
'
object
'
?
'
object
'
:
'
string
'
,
data
:
data
};
localStorage
.
setItem
(
key
,
JSON
.
stringify
(
value
));
const
keyList
=
localStorage
.
getItem
(
'
uni-storage-keys
'
);
if
(
!
keyList
)
{
localStorage
.
setItem
(
'
uni-storage-keys
'
,
JSON
.
stringify
([
key
]));
}
else
{
const
keys
=
JSON
.
parse
(
keyList
);
if
(
keys
.
indexOf
(
key
)
<
0
)
{
keys
.
push
(
key
);
localStorage
.
setItem
(
'
uni-storage-keys
'
,
JSON
.
stringify
(
keys
));
}
}
return
{
errMsg
:
'
setStorage:ok
'
}
}
const
{
beforeSuccess
,
afterSuccess
,
beforeFail
,
afterFail
,
beforeCancel
,
afterCancel
,
afterAll
}
=
wrapperCallbacks
;
const
callbackId
=
invokeCallbackId
++
;
const
invokeCallbackName
=
'
api.
'
+
apiName
+
'
.
'
+
callbackId
;
const
invokeCallback
=
function
(
res
)
{
res
.
errMsg
=
res
.
errMsg
||
apiName
+
'
:ok
'
;
const
errMsg
=
res
.
errMsg
;
if
(
errMsg
.
indexOf
(
apiName
+
'
:ok
'
)
===
0
)
{
isFn
(
beforeSuccess
)
&&
beforeSuccess
(
res
);
hasSuccess
&&
success
(
res
);
isFn
(
afterSuccess
)
&&
afterSuccess
(
res
);
}
else
if
(
errMsg
.
indexOf
(
apiName
+
'
:cancel
'
)
===
0
)
{
res
.
errMsg
=
res
.
errMsg
.
replace
(
apiName
+
'
:cancel
'
,
apiName
+
'
:fail cancel
'
);
hasFail
&&
fail
(
res
);
isFn
(
beforeCancel
)
&&
beforeCancel
(
res
);
hasCancel
&&
cancel
(
res
);
function
setStorageSync$1
(
key
,
data
)
{
setStorage$1
({
key
,
data
});
}
isFn
(
afterCancel
)
&&
afterCancel
(
res
);
}
else
if
(
errMsg
.
indexOf
(
apiName
+
'
:fail
'
)
===
0
)
{
isFn
(
beforeFail
)
&&
beforeFail
(
res
);
function
getStorage
({
key
}
=
{})
{
const
data
=
localStorage
.
getItem
(
key
);
return
data
?
{
data
:
JSON
.
parse
(
data
).
data
,
errMsg
:
'
getStorage:ok
'
}
:
{
data
:
''
,
errMsg
:
'
getStorage:fail
'
}
}
hasFail
&&
fail
(
res
);
function
getStorageSync
(
key
)
{
const
res
=
getStorage
({
key
});
return
res
.
data
}
isFn
(
afterFail
)
&&
afterFail
(
res
);
}
function
removeStorage
({
key
}
=
{})
{
const
keyList
=
localStorage
.
getItem
(
'
uni-storage-keys
'
);
if
(
keyList
)
{
const
keys
=
JSON
.
parse
(
keyList
);
const
index
=
keys
.
indexOf
(
key
);
keys
.
splice
(
index
,
1
);
localStorage
.
setItem
(
'
uni-storage-keys
'
,
JSON
.
stringify
(
keys
));
}
localStorage
.
removeItem
(
key
);
return
{
errMsg
:
'
removeStorage:ok
'
}
}
hasComplete
&&
complete
(
res
);
function
removeStorageSync
(
key
)
{
removeStorage
({
key
});
}
isFn
(
afterAll
)
&&
afterAll
(
res
);
};
function
clearStorage
()
{
localStorage
.
clear
();
return
{
errMsg
:
'
clearStorage:ok
'
}
}
invokeCallbacks
[
callbackId
]
=
{
name
:
invokeCallbackName
,
callback
:
invokeCallback
};
function
clearStorageSync
()
{
clearStorage
();
}
return
{
params
,
callbackId
function
getStorageInfo
()
{
// TODO 暂时先不做大小的转换
const
keyList
=
localStorage
.
getItem
(
'
uni-storage-keys
'
);
return
keyList
?
{
keys
:
JSON
.
parse
(
keyList
),
currentSize
:
0
,
limitSize
:
0
,
errMsg
:
'
getStorageInfo:ok
'
}
:
{
keys
:
''
,
currentSize
:
0
,
limitSize
:
0
,
errMsg
:
'
getStorageInfo:fail
'
}
}
function
createInvokeCallback
(
apiName
,
params
=
{},
extras
=
{})
{
function
getStorageInfoSync
()
{
const
res
=
getStorageInfo
();
delete
res
.
errMsg
;
return
res
}
var
require_context_module_1_4
=
/*#__PURE__*/
Object
.
freeze
({
setStorage
:
setStorage$1
,
setStorageSync
:
setStorageSync$1
,
getStorage
:
getStorage
,
getStorageSync
:
getStorageSync
,
removeStorage
:
removeStorage
,
removeStorageSync
:
removeStorageSync
,
clearStorage
:
clearStorage
,
clearStorageSync
:
clearStorageSync
,
getStorageInfo
:
getStorageInfo
,
getStorageInfoSync
:
getStorageInfoSync
});
const
EPS
=
1
e
-
4
;
const
BASE_DEVICE_WIDTH
=
750
;
let
isIOS
=
false
;
let
deviceWidth
=
0
;
let
deviceDPR
=
0
;
function
checkDeviceWidth
()
{
const
{
params
:
args
,
callbackId
}
=
createApiCallback
(
apiName
,
params
,
extras
);
if
(
isPlainObject
(
args
)
&&
!
validateParams
(
apiName
,
args
,
callbackId
))
{
return
{
params
:
args
,
callbackId
:
false
}
}
platform
,
pixelRatio
,
windowWidth
}
=
uni
.
getSystemInfoSync
();
return
{
params
:
args
,
callbackId
}
deviceWidth
=
windowWidth
;
deviceDPR
=
pixelRatio
;
isIOS
=
platform
===
'
ios
'
;
}
function
invokeCallbackHandler
(
invokeCallbackId
,
res
)
{
if
(
typeof
invokeCallbackId
===
'
number
'
)
{
const
invokeCallback
=
invokeCallbacks
[
invokeCallbackId
];
if
(
invokeCallback
)
{
if
(
!
invokeCallback
.
keepAlive
)
{
delete
invokeCallbacks
[
invokeCallbackId
];
}
return
invokeCallback
.
callback
(
res
)
}
function
upx2px
(
number
,
newDeviceWidth
)
{
if
(
deviceWidth
===
0
)
{
checkDeviceWidth
();
}
return
res
}
function
wrapperUnimplemented
(
name
)
{
return
function
(
args
)
{
console
.
error
(
'
API `
'
+
name
+
'
` is not yet implemented
'
);
number
=
Number
(
number
);
if
(
number
===
0
)
{
return
0
}
}
function
wrapper
(
name
,
invokeMethod
,
extras
)
{
if
(
!
isFn
(
invokeMethod
))
{
return
invokeMethod
let
result
=
(
number
/
BASE_DEVICE_WIDTH
)
*
(
newDeviceWidth
||
deviceWidth
);
if
(
result
<
0
)
{
result
=
-
result
;
}
return
function
(...
args
)
{
if
(
isSyncApi
(
name
))
{
if
(
validateParams
(
name
,
args
,
-
1
))
{
return
invokeMethod
.
apply
(
null
,
args
)
}
}
else
if
(
isCallbackApi
(
name
))
{
if
(
validateParams
(
name
,
args
,
-
1
))
{
return
invokeMethod
(
createKeepAliveApiCallback
(
name
,
args
[
0
]))
}
result
=
Math
.
floor
(
result
+
EPS
);
if
(
result
===
0
)
{
if
(
deviceDPR
===
1
||
!
isIOS
)
{
return
1
}
else
{
let
argsObj
=
{};
if
(
args
.
length
)
{
argsObj
=
args
[
0
];
}
const
{
params
,
callbackId
}
=
createInvokeCallback
(
name
,
argsObj
,
extras
);
if
(
callbackId
!==
false
)
{
let
res
;
if
(
isFn
(
params
))
{
res
=
invokeMethod
(
callbackId
);
}
else
{
res
=
invokeMethod
(
params
,
callbackId
);
}
if
(
res
&&
!
isTaskApi
(
name
))
{
res
=
invokeCallbackHandler
(
callbackId
,
res
);
if
(
isPlainObject
(
res
))
{
res
.
errMsg
=
res
.
errMsg
||
name
+
'
:ok
'
;
}
}
return
res
}
return
0.5
}
}
return
number
<
0
?
-
result
:
result
}
var
require_context_module_1_5
=
/*#__PURE__*/
Object
.
freeze
({
upx2px
:
upx2px
});
const
api
=
Object
.
create
(
null
);
const
uni$1
=
Object
.
create
(
null
);
const
baseApis
=
const
modules$1
=
(
function
()
{
var
map
=
{
'
./base64.js
'
:
require_context_module_1_0
,
...
...
@@ -2521,19 +2416,308 @@ const baseApis =
})();
baseApis
.
keys
().
forEach
(
function
(
key
)
{
Object
.
assign
(
api
,
baseApis
(
key
));
});
modules$1
.
keys
().
forEach
(
function
(
key
)
{
Object
.
assign
(
api
,
modules$1
(
key
));
});
const
{
invokeCallbackHandler
:
invoke
}
=
UniServiceJSBridge
;
let
waiting
;
let
waitingTimeout
;
let
toast
=
false
;
let
toastTimeout
;
function
showToast$1
({
title
=
''
,
icon
=
'
success
'
,
image
=
''
,
duration
=
1500
,
mask
=
false
,
position
=
''
}
=
{})
{
if
(
position
)
{
if
(
toast
)
{
toastTimeout
&&
clearTimeout
(
toastTimeout
);
plus
.
nativeUI
.
closeToast
();
}
if
(
waiting
)
{
waitingTimeout
&&
clearTimeout
(
waitingTimeout
);
waiting
.
close
();
}
if
(
~
[
'
top
'
,
'
center
'
,
'
bottom
'
].
indexOf
(
position
))
{
let
richText
=
`<span>
${
title
}
</span>`
;
plus
.
nativeUI
.
toast
(
richText
,
{
verticalAlign
:
position
,
type
:
'
richtext
'
});
toast
=
true
;
toastTimeout
=
setTimeout
(()
=>
{
hideToast
();
},
2000
);
return
}
console
.
warn
(
'
uni.showToast 传入的 "position" 值 "
'
+
position
+
'
" 无效
'
);
}
if
(
duration
)
{
if
(
waiting
)
{
waitingTimeout
&&
clearTimeout
(
waitingTimeout
);
waiting
.
close
();
}
if
(
toast
)
{
toastTimeout
&&
clearTimeout
(
toastTimeout
);
plus
.
nativeUI
.
closeToast
();
}
if
(
icon
&&
!~
[
'
success
'
,
'
loading
'
,
'
none
'
].
indexOf
(
icon
))
{
icon
=
'
success
'
;
}
const
waitingOptions
=
{
modal
:
mask
,
back
:
'
transmit
'
,
padding
:
'
10px
'
,
size
:
'
16px
'
// 固定字体大小
};
if
(
!
image
&&
(
!
icon
||
icon
===
'
none
'
))
{
// 无图
// waitingOptions.width = '120px'
// waitingOptions.height = '40px'
waitingOptions
.
loading
=
{
display
:
'
none
'
};
}
else
{
// 有图
waitingOptions
.
width
=
'
140px
'
;
waitingOptions
.
height
=
'
112px
'
;
}
if
(
image
)
{
waitingOptions
.
loading
=
{
display
:
'
block
'
,
height
:
'
55px
'
,
icon
:
image
,
interval
:
duration
};
}
else
{
if
(
icon
===
'
success
'
)
{
waitingOptions
.
loading
=
{
display
:
'
block
'
,
height
:
'
55px
'
,
icon
:
'
__uniappsuccess.png
'
,
interval
:
duration
};
}
}
waiting
=
plus
.
nativeUI
.
showWaiting
(
title
,
waitingOptions
);
waitingTimeout
=
setTimeout
(()
=>
{
hideToast
();
},
duration
);
}
return
{
errMsg
:
'
showToast:ok
'
}
}
function
hideToast
()
{
if
(
toast
)
{
toastTimeout
&&
clearTimeout
(
toastTimeout
);
plus
.
nativeUI
.
closeToast
();
toast
=
false
;
}
if
(
waiting
)
{
waitingTimeout
&&
clearTimeout
(
waitingTimeout
);
waiting
.
close
();
waiting
=
null
;
waitingTimeout
=
null
;
}
return
{
errMsg
:
'
hideToast:ok
'
}
}
function
showModal$1
({
title
=
''
,
content
=
''
,
showCancel
=
true
,
cancelText
=
'
取消
'
,
cancelColor
=
'
#000000
'
,
confirmText
=
'
确定
'
,
confirmColor
=
'
#3CC51F
'
}
=
{},
callbackId
)
{
plus
.
nativeUI
.
confirm
(
content
,
(
e
)
=>
{
if
(
showCancel
)
{
invoke
(
callbackId
,
{
errMsg
:
'
showModal:ok
'
,
confirm
:
e
.
index
===
1
,
cancel
:
e
.
index
===
0
||
e
.
index
===
-
1
});
}
else
{
invoke
(
callbackId
,
{
errMsg
:
'
showModal:ok
'
,
confirm
:
e
.
index
===
0
,
cancel
:
false
});
}
},
title
,
showCancel
?
[
cancelText
,
confirmText
]
:
[
confirmText
]);
}
function
showActionSheet$1
({
itemList
=
[],
itemColor
=
'
#000000
'
,
title
=
''
},
callbackId
)
{
const
options
=
{
buttons
:
itemList
.
map
(
item
=>
({
title
:
item
}))
};
if
(
title
)
{
options
.
title
=
title
;
}
if
(
plus
.
os
.
name
===
'
iOS
'
)
{
options
.
cancel
=
'
取消
'
;
}
plus
.
nativeUI
.
actionSheet
(
options
,
(
e
)
=>
{
if
(
e
.
index
>
0
)
{
invoke
(
callbackId
,
{
errMsg
:
'
showActionSheet:ok
'
,
tapIndex
:
e
.
index
-
1
});
}
else
{
invoke
(
callbackId
,
{
errMsg
:
'
showActionSheet:fail cancel
'
});
}
});
}
var
require_context_module_0_0
=
/*#__PURE__*/
Object
.
freeze
({
showToast
:
showToast$1
,
hideToast
:
hideToast
,
showModal
:
showModal$1
,
showActionSheet
:
showActionSheet$1
});
const
ANI_DURATION
=
300
;
const
ANI_SHOW
=
'
pop-in
'
;
function
showWebview
(
webview
,
animationType
,
animationDuration
)
{
setTimeout
(()
=>
{
webview
.
show
(
animationType
||
ANI_SHOW
,
animationDuration
||
ANI_DURATION
,
()
=>
{
console
.
log
(
'
show.callback
'
);
}
);
},
50
);
}
var
require_context_module_0_6
=
/*#__PURE__*/
Object
.
freeze
({
ANI_DURATION
:
ANI_DURATION
,
showWebview
:
showWebview
});
let
firstBackTime
=
0
;
function
navigateBack$1
({
delta
,
animationType
,
animationDuration
})
{
const
pages
=
getCurrentPages
();
const
len
=
pages
.
length
-
1
;
const
page
=
pages
[
len
];
if
(
page
.
$page
.
meta
.
isQuit
)
{
if
(
!
firstBackTime
)
{
firstBackTime
=
Date
.
now
();
plus
.
nativeUI
.
toast
(
'
再按一次退出应用
'
);
setTimeout
(()
=>
{
firstBackTime
=
null
;
},
2000
);
}
else
if
(
Date
.
now
()
-
firstBackTime
<
2000
)
{
plus
.
runtime
.
quit
();
}
}
else
{
pages
.
splice
(
len
,
1
);
if
(
animationType
)
{
page
.
$getAppWebview
().
close
(
animationType
,
animationDuration
||
ANI_DURATION
);
}
else
{
page
.
$getAppWebview
().
close
(
'
auto
'
);
}
UniServiceJSBridge
.
emit
(
'
onAppRoute
'
,
{
type
:
'
navigateBack
'
});
}
}
var
require_context_module_0_1
=
/*#__PURE__*/
Object
.
freeze
({
navigateBack
:
navigateBack$1
});
function
navigateTo$1
({
url
,
animationType
,
animationDuration
})
{
const
path
=
url
.
split
(
'
?
'
)[
0
];
UniServiceJSBridge
.
emit
(
'
onAppRoute
'
,
{
type
:
'
navigateTo
'
,
path
});
showWebview
(
__registerPage
({
path
}),
animationType
,
animationDuration
);
}
var
require_context_module_0_2
=
/*#__PURE__*/
Object
.
freeze
({
navigateTo
:
navigateTo$1
});
function
reLaunch$1
({
path
})
{}
var
require_context_module_0_3
=
/*#__PURE__*/
Object
.
freeze
({
reLaunch
:
reLaunch$1
});
function
redirectTo$1
({
path
})
{}
var
require_context_module_0_4
=
/*#__PURE__*/
Object
.
freeze
({
redirectTo
:
redirectTo$1
});
function
switchTab$1
({
path
})
{}
var
require_context_module_0_5
=
/*#__PURE__*/
Object
.
freeze
({
switchTab
:
switchTab$1
});
const
api$1
=
Object
.
create
(
null
);
const
platformApis
=
const
modules$2
=
(
function
()
{
var
map
=
{
'
./router/navigate-back.js
'
:
require_context_module_0_0
,
'
./router/navigate-to.js
'
:
require_context_module_0_1
,
'
./router/re-launch.js
'
:
require_context_module_0_2
,
'
./router/redirect-to.js
'
:
require_context_module_0_3
,
'
./router/switch-tab.js
'
:
require_context_module_0_4
,
'
./router/util.js
'
:
require_context_module_0_5
,
'
./popup.js
'
:
require_context_module_0_0
,
'
./router/navigate-back.js
'
:
require_context_module_0_1
,
'
./router/navigate-to.js
'
:
require_context_module_0_2
,
'
./router/re-launch.js
'
:
require_context_module_0_3
,
'
./router/redirect-to.js
'
:
require_context_module_0_4
,
'
./router/switch-tab.js
'
:
require_context_module_0_5
,
'
./router/util.js
'
:
require_context_module_0_6
,
};
var
req
=
function
req
(
key
)
{
...
...
@@ -2545,13 +2729,21 @@ const platformApis =
return
req
;
})();
platformApis
.
keys
().
forEach
(
function
(
key
)
{
Object
.
assign
(
api
,
platformApis
(
key
));
});
modules$2
.
keys
().
forEach
(
function
(
key
)
{
Object
.
assign
(
api$1
,
modules$2
(
key
));
});
const
api$2
=
Object
.
create
(
null
);
Object
.
assign
(
api$2
,
api
);
Object
.
assign
(
api$2
,
api$1
);
const
uni$1
=
Object
.
create
(
null
);
apis
.
forEach
(
name
=>
{
if
(
api
[
name
])
{
uni$1
[
name
]
=
promisify
(
name
,
wrapper
(
name
,
api
[
name
]));
if
(
api
$2
[
name
])
{
uni$1
[
name
]
=
promisify
(
name
,
wrapper
(
name
,
api
$2
[
name
]));
}
else
{
uni$1
[
name
]
=
wrapperUnimplemented
(
name
);
}
...
...
src/core/service/api.js
0 → 100644
浏览文件 @
29d27d3b
const
api
=
Object
.
create
(
null
)
const
modules
=
require
.
context
(
'
./api
'
,
true
,
/
\.
js$/
)
modules
.
keys
().
forEach
(
function
(
key
)
{
Object
.
assign
(
api
,
modules
(
key
))
})
export
default
api
src/platforms/app-plus/service/api.js
0 → 100644
浏览文件 @
29d27d3b
const
api
=
Object
.
create
(
null
)
const
modules
=
require
.
context
(
'
./api
'
,
true
,
/
\.
js$/
)
modules
.
keys
().
forEach
(
function
(
key
)
{
Object
.
assign
(
api
,
modules
(
key
))
})
export
default
api
src/platforms/app-plus/service/api/popup.js
0 → 100644
浏览文件 @
29d27d3b
const
{
invokeCallbackHandler
:
invoke
}
=
UniServiceJSBridge
let
waiting
let
waitingTimeout
let
toast
=
false
let
toastTimeout
export
function
showToast
({
title
=
''
,
icon
=
'
success
'
,
image
=
''
,
duration
=
1500
,
mask
=
false
,
position
=
''
}
=
{})
{
if
(
position
)
{
if
(
toast
)
{
toastTimeout
&&
clearTimeout
(
toastTimeout
)
plus
.
nativeUI
.
closeToast
()
}
if
(
waiting
)
{
waitingTimeout
&&
clearTimeout
(
waitingTimeout
)
waiting
.
close
()
}
if
(
~
[
'
top
'
,
'
center
'
,
'
bottom
'
].
indexOf
(
position
))
{
let
richText
=
`<span>
${
title
}
</span>`
plus
.
nativeUI
.
toast
(
richText
,
{
verticalAlign
:
position
,
type
:
'
richtext
'
})
toast
=
true
toastTimeout
=
setTimeout
(()
=>
{
hideToast
()
},
2000
)
return
}
console
.
warn
(
'
uni.showToast 传入的 "position" 值 "
'
+
position
+
'
" 无效
'
)
}
if
(
duration
)
{
if
(
waiting
)
{
waitingTimeout
&&
clearTimeout
(
waitingTimeout
)
waiting
.
close
()
}
if
(
toast
)
{
toastTimeout
&&
clearTimeout
(
toastTimeout
)
plus
.
nativeUI
.
closeToast
()
}
if
(
icon
&&
!~
[
'
success
'
,
'
loading
'
,
'
none
'
].
indexOf
(
icon
))
{
icon
=
'
success
'
}
const
waitingOptions
=
{
modal
:
mask
,
back
:
'
transmit
'
,
padding
:
'
10px
'
,
size
:
'
16px
'
// 固定字体大小
}
if
(
!
image
&&
(
!
icon
||
icon
===
'
none
'
))
{
// 无图
// waitingOptions.width = '120px'
// waitingOptions.height = '40px'
waitingOptions
.
loading
=
{
display
:
'
none
'
}
}
else
{
// 有图
waitingOptions
.
width
=
'
140px
'
waitingOptions
.
height
=
'
112px
'
}
if
(
image
)
{
waitingOptions
.
loading
=
{
display
:
'
block
'
,
height
:
'
55px
'
,
icon
:
image
,
interval
:
duration
}
}
else
{
if
(
icon
===
'
success
'
)
{
waitingOptions
.
loading
=
{
display
:
'
block
'
,
height
:
'
55px
'
,
icon
:
'
__uniappsuccess.png
'
,
interval
:
duration
}
}
}
waiting
=
plus
.
nativeUI
.
showWaiting
(
title
,
waitingOptions
)
waitingTimeout
=
setTimeout
(()
=>
{
hideToast
()
},
duration
)
}
return
{
errMsg
:
'
showToast:ok
'
}
}
export
function
hideToast
()
{
if
(
toast
)
{
toastTimeout
&&
clearTimeout
(
toastTimeout
)
plus
.
nativeUI
.
closeToast
()
toast
=
false
}
if
(
waiting
)
{
waitingTimeout
&&
clearTimeout
(
waitingTimeout
)
waiting
.
close
()
waiting
=
null
waitingTimeout
=
null
}
return
{
errMsg
:
'
hideToast:ok
'
}
}
export
function
showModal
({
title
=
''
,
content
=
''
,
showCancel
=
true
,
cancelText
=
'
取消
'
,
cancelColor
=
'
#000000
'
,
confirmText
=
'
确定
'
,
confirmColor
=
'
#3CC51F
'
}
=
{},
callbackId
)
{
plus
.
nativeUI
.
confirm
(
content
,
(
e
)
=>
{
if
(
showCancel
)
{
invoke
(
callbackId
,
{
errMsg
:
'
showModal:ok
'
,
confirm
:
e
.
index
===
1
,
cancel
:
e
.
index
===
0
||
e
.
index
===
-
1
})
}
else
{
invoke
(
callbackId
,
{
errMsg
:
'
showModal:ok
'
,
confirm
:
e
.
index
===
0
,
cancel
:
false
})
}
},
title
,
showCancel
?
[
cancelText
,
confirmText
]
:
[
confirmText
])
}
export
function
showActionSheet
({
itemList
=
[],
itemColor
=
'
#000000
'
,
title
=
''
},
callbackId
)
{
const
options
=
{
buttons
:
itemList
.
map
(
item
=>
({
title
:
item
}))
}
if
(
title
)
{
options
.
title
=
title
}
if
(
plus
.
os
.
name
===
'
iOS
'
)
{
options
.
cancel
=
'
取消
'
}
plus
.
nativeUI
.
actionSheet
(
options
,
(
e
)
=>
{
if
(
e
.
index
>
0
)
{
invoke
(
callbackId
,
{
errMsg
:
'
showActionSheet:ok
'
,
tapIndex
:
e
.
index
-
1
})
}
else
{
invoke
(
callbackId
,
{
errMsg
:
'
showActionSheet:fail cancel
'
})
}
})
}
src/platforms/app-plus/service/
framework/
polyfill.js
→
src/platforms/app-plus/service/polyfill.js
浏览文件 @
29d27d3b
文件已移动
src/platforms/app-plus/service/uni.js
浏览文件 @
29d27d3b
import
'
./polyfill
'
import
apis
from
'
uni-helpers/apis
'
import
{
wrapper
,
wrapperUnimplemented
}
from
'
uni-helpers/api
'
import
{
promisify
}
from
'
uni-helpers/promise
'
import
baseApi
from
'
uni-core/service/api
'
import
platformApi
from
'
./api
'
const
api
=
Object
.
create
(
null
)
const
uni
=
Object
.
create
(
null
)
Object
.
assign
(
api
,
baseApi
)
Object
.
assign
(
api
,
platformApi
)
const
baseApis
=
require
.
context
(
'
../../../core/service/api
'
,
true
,
/
\.
js$/
)
baseApis
.
keys
().
forEach
(
function
(
key
)
{
Object
.
assign
(
api
,
baseApis
(
key
))
})
const
platformApis
=
require
.
context
(
'
./api
'
,
true
,
/
\.
js$/
)
platformApis
.
keys
().
forEach
(
function
(
key
)
{
Object
.
assign
(
api
,
platformApis
(
key
))
})
const
uni
=
Object
.
create
(
null
)
apis
.
forEach
(
name
=>
{
if
(
api
[
name
])
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录