Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小浣熊撸代码
uni-app
提交
0a23d711
U
uni-app
项目概览
小浣熊撸代码
/
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,发现更多精彩内容 >>
提交
0a23d711
编写于
7月 31, 2019
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add modules
上级
0ae35ac7
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
1348 addition
and
851 deletion
+1348
-851
lib/modules.js
lib/modules.js
+65
-0
packages/uni-app-plus-nvue/dist/index.js
packages/uni-app-plus-nvue/dist/index.js
+1266
-850
packages/uni-h5/dist/index.umd.min.js
packages/uni-h5/dist/index.umd.min.js
+1
-1
packages/uni-h5/manifest.json
packages/uni-h5/manifest.json
+16
-0
未找到文件。
lib/modules.js
0 → 100644
浏览文件 @
0a23d711
module
.
exports
=
{
base
:
{
title
:
'
基础
'
,
api
:
[
'
base64ToArrayBuffer
'
,
'
arrayBufferToBase64
'
]
},
network
:
{
title
:
'
网络
'
,
api
:
[
'
request
'
'
connectSocket
'
'
sendSocketMessage
'
'
closeSocket
'
'
onSocketOpen
'
'
onSocketError
'
'
onSocketMessage
'
'
onSocketClose
'
'
downloadFile
'
'
uploadFile
'
]
},
storage
:
{
title
:
'
数据缓存
'
,
api
:
[
'
setStorage
'
'
setStorageSync
'
'
getStorage
'
'
getStorageSync
'
'
removeStorage
'
'
removeStorageSync
'
'
clearStorage
'
'
clearStorageSync
'
'
getStorageInfo
'
'
getStorageInfoSync
'
]
},
location
:
{
title
:
'
位置
'
,
api
:
[
'
getLocation
'
,
'
openLocation
'
,
'
chooseLocation
'
]
},
media
:
{
title
:
'
媒体
'
,
api
:
[
'
chooseImage
'
,
'
previewImage
'
,
'
getImageInfo
'
,
'
saveImageToPhotosAlbum
'
,
'
compressImage
'
,
'
getRecorderManager
'
,
'
getBackgroundAudioManager
'
,
'
createInnerAudioContext
'
,
'
chooseVideo
'
,
'
saveVideoToPhotosAlbum
'
,
'
createVideoContext
'
,
'
createCameraContext
'
,
'
createLivePlayerContext
'
]
}
}
packages/uni-app-plus-nvue/dist/index.js
浏览文件 @
0a23d711
export
function
createServiceContext
(
Vue
,
weex
,
plus
,
__uniConfig
,
__uniRoutes
,
UniServiceJSBridge
){
export
function
createServiceContext
(
Vue
,
weex
,
plus
,
__uniConfig
,
__uniRoutes
,
UniServiceJSBridge
,
instanceContext
){
var
localStorage
=
plus
.
storage
var
setTimeout
=
global
.
setTimeout
var
clearTimeout
=
global
.
clearTimeout
var
setTimeout
=
instanceContext
.
setTimeout
var
clearTimeout
=
instanceContext
.
clearTimeout
var
setInterval
=
instanceContext
.
setInterval
var
clearInterval
=
instanceContext
.
clearInterval
var
serviceContext
=
(
function
()
{
'
use strict
'
;
...
...
@@ -24,25 +26,49 @@ var serviceContext = (function () {
return
callHook
(
vm
,
hook
,
params
)
}
function
callApiSync
(
api
,
args
,
name
,
alias
)
{
const
ret
=
api
(
args
);
if
(
ret
&&
ret
.
errMsg
)
{
ret
.
errMsg
=
ret
.
errMsg
.
replace
(
name
,
alias
);
function
pack
(
args
)
{
return
args
}
return
ret
function
unpack
(
args
)
{
return
args
}
function
getLastWebview
()
{
try
{
function
invoke
(...
args
)
{
return
UniServiceJSBridge
.
invokeCallbackHandler
(...
args
)
}
function
requireNativePlugin
(
name
)
{
return
uni
.
requireNativePlugin
(
name
)
}
/**
* 触发 service 层,与 onMethod 对应
*/
function
publish
(
name
,
res
)
{
return
UniServiceJSBridge
.
emit
(
'
api.
'
+
name
,
res
)
}
let
lastStatusBarStyle
;
function
setStatusBarStyle
(
statusBarStyle
)
{
if
(
!
statusBarStyle
)
{
const
pages
=
getCurrentPages
();
if
(
pages
.
length
)
{
return
pages
[
pages
.
length
-
1
].
$getAppWebview
()
if
(
!
pages
.
length
)
{
return
}
}
catch
(
e
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
'
getCurrentPages is not ready
'
);
statusBarStyle
=
pages
[
pages
.
length
-
1
].
$page
.
meta
.
statusBarStyle
;
if
(
!
statusBarStyle
||
statusBarStyle
===
lastStatusBarStyle
)
{
return
}
}
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`[uni-app] setStatusBarStyle`
,
statusBarStyle
);
}
lastStatusBarStyle
=
statusBarStyle
;
plus
.
navigator
.
setStatusBarStyle
(
statusBarStyle
);
}
function
isTabBarPage
(
path
=
''
)
{
...
...
@@ -70,6 +96,27 @@ var serviceContext = (function () {
return
false
}
function
callApiSync
(
api
,
args
,
name
,
alias
)
{
const
ret
=
api
(
args
);
if
(
ret
&&
ret
.
errMsg
)
{
ret
.
errMsg
=
ret
.
errMsg
.
replace
(
name
,
alias
);
}
return
ret
}
function
getLastWebview
()
{
try
{
const
pages
=
getCurrentPages
();
if
(
pages
.
length
)
{
return
pages
[
pages
.
length
-
1
].
$getAppWebview
()
}
}
catch
(
e
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
'
getCurrentPages is not ready
'
);
}
}
}
const
getRealRoute
=
(
e
,
t
)
=>
{
if
(
t
.
indexOf
(
'
./
'
)
===
0
)
return
getRealRoute
(
e
,
t
.
substr
(
2
))
let
n
;
...
...
@@ -674,54 +721,13 @@ var serviceContext = (function () {
return
webview
}
function
unpack
(
args
)
{
return
args
}
function
invoke
(...
args
)
{
return
UniServiceJSBridge
.
invokeCallbackHandler
(...
args
)
}
function
requireNativePlugin
(
name
)
{
return
uni
.
requireNativePlugin
(
name
)
}
/**
* 触发 service 层,与 onMethod 对应
*/
function
publish
(
name
,
res
)
{
return
UniServiceJSBridge
.
emit
(
'
api.
'
+
name
,
res
)
}
let
lastStatusBarStyle
;
function
setStatusBarStyle
(
statusBarStyle
)
{
if
(
!
statusBarStyle
)
{
const
pages
=
getCurrentPages
();
if
(
!
pages
.
length
)
{
return
}
statusBarStyle
=
pages
[
pages
.
length
-
1
].
$page
.
meta
.
statusBarStyle
;
if
(
!
statusBarStyle
||
statusBarStyle
===
lastStatusBarStyle
)
{
return
}
}
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`[uni-app] setStatusBarStyle`
,
statusBarStyle
);
}
lastStatusBarStyle
=
statusBarStyle
;
plus
.
navigator
.
setStatusBarStyle
(
statusBarStyle
);
}
const
callbacks
=
{};
/**
* 注册 view 层通知 service 层事件处理
*/
function
registerPlusMessage
(
type
,
callback
,
keepAlive
=
true
)
{
if
(
callbacks
[
type
])
{
throw
new
Error
(
`
${
type
}
已注册:`
+
(
callbacks
[
type
].
toString
()))
return
console
.
warn
(
`
${
type
}
已注册:`
+
(
callbacks
[
type
].
toString
()))
}
callback
.
keepAlive
=
!!
keepAlive
;
callbacks
[
type
]
=
callback
;
...
...
@@ -1421,7 +1427,6 @@ var serviceContext = (function () {
'
getImageInfo
'
,
'
saveImageToPhotosAlbum
'
,
'
compressImage
'
,
'
chooseMessageFile
'
,
'
getRecorderManager
'
,
'
getBackgroundAudioManager
'
,
'
createInnerAudioContext
'
,
...
...
@@ -3716,28 +3721,6 @@ var serviceContext = (function () {
upx2px
:
upx2px$1
});
const
Emitter
=
new
Vue
();
function
apply
(
ctx
,
method
,
args
)
{
return
ctx
[
method
].
apply
(
ctx
,
args
)
}
function
$on$1
()
{
return
apply
(
Emitter
,
'
$on
'
,
[...
arguments
])
}
function
$off$1
()
{
return
apply
(
Emitter
,
'
$off
'
,
[...
arguments
])
}
function
$once$1
()
{
return
apply
(
Emitter
,
'
$once
'
,
[...
arguments
])
}
function
$emit$1
()
{
return
apply
(
Emitter
,
'
$emit
'
,
[...
arguments
])
}
let
audios
=
{};
const
evts
=
[
'
play
'
,
'
canplay
'
,
'
ended
'
,
'
stop
'
,
'
waiting
'
,
'
seeking
'
,
'
seeked
'
,
'
pause
'
];
...
...
@@ -4324,7 +4307,7 @@ var serviceContext = (function () {
/**
* 执行蓝牙相关方法
*/
function
bluetoothExec
(
method
,
callbackId
,
data
=
{}
,
beforeSuccess
)
{
function
bluetoothExec
(
method
,
callbackId
,
data
=
{})
{
var
deviceId
=
data
.
deviceId
;
if
(
deviceId
)
{
data
.
deviceId
=
deviceId
.
toUpperCase
();
...
...
@@ -4336,10 +4319,7 @@ var serviceContext = (function () {
plus
.
bluetooth
[
method
.
replace
(
'
Changed
'
,
'
Change
'
)](
Object
.
assign
(
data
,
{
success
(
data
)
{
if
(
typeof
beforeSuccess
===
'
function
'
)
{
beforeSuccess
(
data
);
}
invoke
(
callbackId
,
Object
.
assign
({},
data
,
{
invoke
(
callbackId
,
Object
.
assign
({},
pack
(
data
),
{
errMsg
:
`
${
method
}
:ok`
,
code
:
undefined
,
message
:
undefined
...
...
@@ -4356,12 +4336,9 @@ var serviceContext = (function () {
/**
* 监听蓝牙相关事件
*/
function
bluetoothOn
(
method
,
beforeSuccess
)
{
function
bluetoothOn
(
method
)
{
plus
.
bluetooth
[
method
.
replace
(
'
Changed
'
,
'
Change
'
)](
function
(
data
)
{
if
(
typeof
beforeSuccess
===
'
function
'
)
{
beforeSuccess
(
data
);
}
publish
(
method
,
Object
.
assign
({},
data
,
{
publish
(
method
,
Object
.
assign
({},
pack
(
data
),
{
code
:
undefined
,
message
:
undefined
}));
...
...
@@ -4369,16 +4346,6 @@ var serviceContext = (function () {
return
true
}
function
checkDevices
(
data
)
{
data
.
devices
=
data
.
devices
.
map
(
device
=>
{
var
advertisData
=
device
.
advertisData
;
if
(
advertisData
&&
typeof
advertisData
!==
'
string
'
)
{
device
.
advertisData
=
wx
.
arrayBufferToBase64
(
advertisData
);
}
return
device
});
}
var
onBluetoothAdapterStateChange
;
var
onBluetoothDeviceFound
;
var
onBLEConnectionStateChange
;
...
...
@@ -4399,7 +4366,7 @@ var serviceContext = (function () {
}
function
startBluetoothDevicesDiscovery
(
data
,
callbackId
)
{
onBluetoothDeviceFound
=
onBluetoothDeviceFound
||
bluetoothOn
(
'
onBluetoothDeviceFound
'
,
checkDevices
);
onBluetoothDeviceFound
=
onBluetoothDeviceFound
||
bluetoothOn
(
'
onBluetoothDeviceFound
'
);
bluetoothExec
(
'
startBluetoothDevicesDiscovery
'
,
callbackId
,
data
);
}
...
...
@@ -4408,7 +4375,7 @@ var serviceContext = (function () {
}
function
getBluetoothDevices
(
data
,
callbackId
)
{
bluetoothExec
(
'
getBluetoothDevices
'
,
callbackId
,
{}
,
checkDevices
);
bluetoothExec
(
'
getBluetoothDevices
'
,
callbackId
,
{});
}
function
getConnectedBluetoothDevices
(
data
,
callbackId
)
{
...
...
@@ -4434,18 +4401,12 @@ var serviceContext = (function () {
}
function
notifyBLECharacteristicValueChange
(
data
,
callbackId
)
{
onBLECharacteristicValueChange
=
onBLECharacteristicValueChange
||
bluetoothOn
(
'
onBLECharacteristicValueChange
'
,
data
=>
{
data
.
value
=
wx
.
arrayBufferToBase64
(
data
.
value
);
});
onBLECharacteristicValueChange
=
onBLECharacteristicValueChange
||
bluetoothOn
(
'
onBLECharacteristicValueChange
'
);
bluetoothExec
(
'
notifyBLECharacteristicValueChange
'
,
callbackId
,
data
);
}
function
notifyBLECharacteristicValueChanged
(
data
,
callbackId
)
{
onBLECharacteristicValueChange
=
onBLECharacteristicValueChange
||
bluetoothOn
(
'
onBLECharacteristicValueChange
'
,
data
=>
{
data
.
value
=
wx
.
arrayBufferToBase64
(
data
.
value
);
});
onBLECharacteristicValueChange
=
onBLECharacteristicValueChange
||
bluetoothOn
(
'
onBLECharacteristicValueChange
'
);
bluetoothExec
(
'
notifyBLECharacteristicValueChanged
'
,
callbackId
,
data
);
}
...
...
@@ -4454,8 +4415,7 @@ var serviceContext = (function () {
}
function
writeBLECharacteristicValue
(
data
,
callbackId
)
{
data
.
value
=
wx
.
base64ToArrayBuffer
(
data
.
value
);
bluetoothExec
(
'
writeBLECharacteristicValue
'
,
callbackId
,
data
);
bluetoothExec
(
'
writeBLECharacteristicValue
'
,
callbackId
,
unpack
(
data
));
}
function
getScreenBrightness
()
{
...
...
@@ -7021,15 +6981,11 @@ var serviceContext = (function () {
startPullDownRefresh
:
startPullDownRefresh
,
stopPullDownRefresh
:
stopPullDownRefresh
,
chooseImage
:
chooseImage$1
,
$on
:
$on$1
,
$off
:
$off$1
,
$once
:
$once$1
,
$emit
:
$emit$1
,
getMusicPlayerState
:
getMusicPlayerState
,
operateMusicPlayer
:
operateMusicPlayer
,
setBackgroundAudioState
:
setBackgroundAudioState
,
operateBackgroundAudio
:
operateBackgroundAudio
,
getBackgroundAudioState
:
getBackgroundAudioState
,
createAudioInstance
:
createAudioInstance
,
destroyAudioInstance
:
destroyAudioInstance
,
setAudioState
:
setAudioState
,
getAudioState
:
getAudioState
,
operateAudio
:
operateAudio
,
enableAccelerometer
:
enableAccelerometer
,
addPhoneContact
:
addPhoneContact
,
openBluetoothAdapter
:
openBluetoothAdapter
,
...
...
@@ -7081,11 +7037,11 @@ var serviceContext = (function () {
playVoice
:
playVoice
,
pauseVoice
:
pauseVoice
,
stopVoice
:
stopVoice
,
createAudioInstance
:
createAudioInstanc
e
,
destroyAudioInstance
:
destroyAudioInstance
,
set
AudioState
:
set
AudioState
,
getAudioState
:
getAudioState
,
operateAudio
:
operateAudio
,
getMusicPlayerState
:
getMusicPlayerStat
e
,
operateMusicPlayer
:
operateMusicPlayer
,
set
BackgroundAudioState
:
setBackground
AudioState
,
operateBackgroundAudio
:
operateBackgroundAudio
,
getBackgroundAudioState
:
getBackgroundAudioState
,
chooseVideo
:
chooseVideo$1
,
compressImage
:
compressImage
,
getImageInfo
:
getImageInfo$1
,
...
...
@@ -7131,895 +7087,1355 @@ var serviceContext = (function () {
showTabBar
:
showTabBar$2
});
const
SUCCESS
=
'
success
'
;
const
FAIL
=
'
fail
'
;
const
COMPLETE
=
'
complete
'
;
const
CALLBACKS
=
[
SUCCESS
,
FAIL
,
COMPLETE
];
const
Emitter
=
new
Vue
();
/**
* 调用无参数,或仅一个参数且为 callback 的 API
* @param {Object} vm
* @param {Object} method
* @param {Object} args
* @param {Object} extras
*/
function
invokeVmMethodWithoutArgs
(
vm
,
method
,
args
,
extras
)
{
if
(
!
vm
)
{
return
function
apply
(
ctx
,
method
,
args
)
{
return
ctx
[
method
].
apply
(
ctx
,
args
)
}
if
(
typeof
args
===
'
undefined
'
)
{
return
vm
[
method
]()
function
$on$1
()
{
return
apply
(
Emitter
,
'
$on
'
,
[...
arguments
])
}
const
[,
callbacks
]
=
normalizeArgs
(
args
,
extras
);
if
(
!
Object
.
keys
(
callbacks
).
length
)
{
return
vm
[
method
](
)
function
$off$1
(
)
{
return
apply
(
Emitter
,
'
$off
'
,
[...
arguments
]
)
}
return
vm
[
method
](
normalizeCallback
(
method
,
callbacks
))
function
$once$1
()
{
return
apply
(
Emitter
,
'
$once
'
,
[...
arguments
])
}
function
$emit$1
()
{
return
apply
(
Emitter
,
'
$emit
'
,
[...
arguments
])
}
var
eventApis
=
/*#__PURE__*/
Object
.
freeze
({
$on
:
$on$1
,
$off
:
$off$1
,
$once
:
$once$1
,
$emit
:
$emit$1
});
var
api
=
Object
.
assign
(
Object
.
create
(
null
),
appApi
,
eventApis
);
/**
* 调用两个参数(第一个入参为普通参数,第二个入参为 callback) API
* @param {Object} vm
* @param {Object} method
* @param {Object} args
* @param {Object} extras
* 执行内部平台方法
*/
function
invokeVmMethod
(
vm
,
method
,
args
,
extras
)
{
if
(
!
vm
)
{
return
}
const
[
pureArgs
,
callbacks
]
=
normalizeArgs
(
args
,
extras
);
if
(
!
Object
.
keys
(
callbacks
).
length
)
{
return
vm
[
method
](
pureArgs
)
function
invokeMethod
(
name
,
...
args
)
{
return
api
[
name
].
apply
(
null
,
args
)
}
return
vm
[
method
](
pureArgs
,
normalizeCallback
(
method
,
callbacks
))
/**
* 监听 service 层内部平台方法回调,与 publish 对应
* @param {Object} name
* @param {Object} callback
*/
function
onMethod
(
name
,
callback
)
{
return
UniServiceJSBridge
.
on
(
'
api.
'
+
name
,
callback
)
}
function
findElmById
(
id
,
vm
)
{
return
findElmByVNode
(
id
,
vm
.
_vnode
)
const
callbacks$1
=
[];
onMethod
(
'
onAccelerometerChange
'
,
function
(
res
)
{
callbacks$1
.
forEach
(
callbackId
=>
{
invoke
(
callbackId
,
res
);
});
});
let
isEnable
=
false
;
/**
* 监听加速度
* @param {*} callbackId
*/
function
onAccelerometerChange
(
callbackId
)
{
// TODO 当没有 start 时,添加 on 需要主动 start?
callbacks$1
.
push
(
callbackId
);
if
(
!
isEnable
)
{
startAccelerometer
();
}
}
function
findElmByVNode
(
id
,
vnode
)
{
if
(
!
id
||
!
vnode
)
{
function
startAccelerometer
({
interval
// TODO
}
=
{})
{
if
(
isEnable
)
{
return
}
if
(
vnode
.
data
&&
vnode
.
data
.
attrs
&&
vnode
.
data
.
attrs
.
id
===
id
)
{
return
vnode
.
elm
}
const
children
=
vnode
.
children
;
if
(
!
children
)
{
return
isEnable
=
true
;
return
invokeMethod
(
'
enableAccelerometer
'
,
{
enable
:
true
})
}
for
(
let
i
=
0
,
len
=
children
.
length
;
i
<
len
;
i
++
)
{
const
elm
=
findElmByVNode
(
id
,
children
[
i
]);
if
(
elm
)
{
return
elm
function
stopAccelerometer
()
{
isEnable
=
false
;
return
invokeMethod
(
'
enableAccelerometer
'
,
{
enable
:
false
})
}
var
require_context_module_1_4
=
/*#__PURE__*/
Object
.
freeze
({
onAccelerometerChange
:
onAccelerometerChange
,
startAccelerometer
:
startAccelerometer
,
stopAccelerometer
:
stopAccelerometer
});
function
on
(
method
)
{
const
callbacks
=
[];
onMethod
(
method
,
data
=>
{
callbacks
.
forEach
(
callbackId
=>
{
invoke
(
callbackId
,
data
);
});
});
return
function
(
callbackId
)
{
callbacks
.
push
(
callbackId
);
}
}
function
normalizeArgs
(
args
=
{},
extras
)
{
const
callbacks
=
Object
.
create
(
null
);
const
onBluetoothDeviceFound$1
=
on
(
'
onBluetoothDeviceFound
'
);
const
onBluetoothAdapterStateChange$1
=
on
(
'
onBluetoothAdapterStateChange
'
);
const
onBLEConnectionStateChange$1
=
on
(
'
onBLEConnectionStateChange
'
);
const
onBLECharacteristicValueChange$1
=
on
(
'
onBLECharacteristicValueChange
'
);
const
iterator
=
function
iterator
(
name
)
{
const
callback
=
args
[
name
];
if
(
isFn
(
callback
))
{
callbacks
[
name
]
=
callback
;
delete
args
[
name
];
}
};
var
require_context_module_1_5
=
/*#__PURE__*/
Object
.
freeze
({
onBluetoothDeviceFound
:
onBluetoothDeviceFound$1
,
onBluetoothAdapterStateChange
:
onBluetoothAdapterStateChange$1
,
onBLEConnectionStateChange
:
onBLEConnectionStateChange$1
,
onBLECharacteristicValueChange
:
onBLECharacteristicValueChange$1
});
CALLBACKS
.
forEach
(
iterator
)
;
const
callbacks$2
=
[]
;
extras
&&
extras
.
forEach
(
iterator
);
onMethod
(
'
onCompassChange
'
,
function
(
res
)
{
callbacks$2
.
forEach
(
callbackId
=>
{
invoke
(
callbackId
,
res
);
});
});
return
[
args
,
callbacks
]
let
isEnable$1
=
false
;
/**
* 监听加速度
* @param {*} callbackId
*/
function
onCompassChange
(
callbackId
)
{
// TODO 当没有 start 时,添加 on 需要主动 start?
callbacks$2
.
push
(
callbackId
);
if
(
!
isEnable$1
)
{
startCompass
();
}
}
function
normalizeCallback
(
method
,
callbacks
)
{
return
function
weexCallback
(
ret
)
{
const
type
=
ret
.
type
;
delete
ret
.
type
;
const
callback
=
callbacks
[
type
];
if
(
type
===
SUCCESS
)
{
ret
.
errMsg
=
`
${
method
}
:ok`
;
}
else
if
(
type
===
FAIL
)
{
ret
.
errMsg
=
method
+
'
:fail
'
+
(
ret
.
msg
?
(
'
'
+
ret
.
msg
)
:
''
);
function
startCompass
(
{
interval
// TODO
}
=
{})
{
if
(
isEnable$1
)
{
return
}
isEnable$1
=
true
;
return
invokeMethod
(
'
enableCompass
'
,
{
enable
:
true
})
}
delete
ret
.
code
;
delete
ret
.
msg
;
function
stopCompass
()
{
isEnable$1
=
false
;
return
invokeMethod
(
'
enableCompass
'
,
{
enable
:
false
})
}
isFn
(
callback
)
&&
callback
(
ret
);
var
require_context_module_1_6
=
/*#__PURE__*/
Object
.
freeze
({
onCompassChange
:
onCompassChange
,
startCompass
:
startCompass
,
stopCompass
:
stopCompass
});
if
(
type
===
SUCCESS
||
type
===
FAIL
)
{
const
complete
=
callbacks
[
'
complete
'
];
isFn
(
complete
)
&&
complete
(
ret
);
class
DownloadTask
{
constructor
(
downloadTaskId
,
callbackId
)
{
this
.
id
=
downloadTaskId
;
this
.
_callbackId
=
callbackId
;
this
.
_callbacks
=
[];
}
abort
()
{
invokeMethod
(
'
operateRequestTask
'
,
{
downloadTaskId
:
this
.
id
,
operationType
:
'
abort
'
});
}
onProgressUpdate
(
callback
)
{
if
(
typeof
callback
!==
'
function
'
)
{
return
}
class
LivePusherContext
{
constructor
(
id
,
ctx
)
{
this
.
id
=
id
;
this
.
ctx
=
ctx
;
this
.
_callbacks
.
push
(
callback
);
}
onHeadersReceived
()
{
start
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
start
'
,
cbs
)
}
stop
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
stop
'
,
cbs
)
offProgressUpdate
(
callback
)
{
const
index
=
this
.
_callbacks
.
indexOf
(
callback
);
if
(
index
>=
0
)
{
this
.
_callbacks
.
splice
(
index
,
1
);
}
pause
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
pause
'
,
cbs
)
}
offHeadersReceived
()
{
resume
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
resume
'
,
cbs
)
}
switchCamera
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
switchCamera
'
,
cbs
)
}
const
downloadTasks$1
=
Object
.
create
(
null
);
onMethod
(
'
onDownloadTaskStateChange
'
,
({
downloadTaskId
,
state
,
tempFilePath
,
statusCode
,
progress
,
totalBytesWritten
,
totalBytesExpectedToWrite
,
errMsg
})
=>
{
const
downloadTask
=
downloadTasks$1
[
downloadTaskId
];
const
callbackId
=
downloadTask
.
_callbackId
;
snapshot
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
snapshot
'
,
cbs
)
switch
(
state
)
{
case
'
progressUpdate
'
:
downloadTask
.
_callbacks
.
forEach
(
callback
=>
{
callback
({
progress
,
totalBytesWritten
,
totalBytesExpectedToWrite
});
});
break
case
'
success
'
:
invoke
(
callbackId
,
{
tempFilePath
,
statusCode
,
errMsg
:
'
request:ok
'
});
// eslint-disable-next-line no-fallthrough
case
'
fail
'
:
invoke
(
callbackId
,
{
errMsg
:
'
request:fail
'
+
errMsg
});
// eslint-disable-next-line no-fallthrough
default
:
// progressUpdate 可能晚于 success
setTimeout
(()
=>
{
delete
downloadTasks$1
[
downloadTaskId
];
},
100
);
break
}
toggleTorch
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
toggleTorch
'
,
cbs
)
});
function
downloadFile$1
(
args
,
callbackId
)
{
const
{
downloadTaskId
}
=
invokeMethod
(
'
createDownloadTask
'
,
args
);
const
task
=
new
DownloadTask
(
downloadTaskId
,
callbackId
);
downloadTasks$1
[
downloadTaskId
]
=
task
;
return
task
}
playBGM
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
playBGM
'
,
args
)
}
var
require_context_module_1_7
=
/*#__PURE__*/
Object
.
freeze
({
downloadFile
:
downloadFile$1
});
stopBGM
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
stopBGM
'
,
cbs
)
}
const
requestTasks$1
=
Object
.
create
(
null
);
pauseBGM
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
pauseBGM
'
,
cbs
)
function
formatResponse
(
res
,
args
)
{
if
(
typeof
res
.
data
===
'
string
'
&&
res
.
data
.
charCodeAt
(
0
)
===
65279
)
{
res
.
data
=
res
.
data
.
substr
(
1
);
}
resumeBGM
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
resumeBGM
'
,
cbs
)
}
res
.
statusCode
=
parseInt
(
res
.
statusCode
,
10
);
setBGMVolume
(
cbs
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
setBGMVolume
'
,
cbs
)
if
(
isPlainObject
(
res
.
header
))
{
res
.
header
=
Object
.
keys
(
res
.
header
).
reduce
(
function
(
ret
,
key
)
{
const
value
=
res
.
header
[
key
];
if
(
Array
.
isArray
(
value
))
{
ret
[
key
]
=
value
.
join
(
'
,
'
);
}
else
if
(
typeof
value
===
'
string
'
)
{
ret
[
key
]
=
value
;
}
startPreview
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
startPreview
'
,
cbs
)
return
ret
},
{});
}
stopPreview
(
args
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
stopPreview
'
,
args
)
}
if
(
args
.
dataType
&&
args
.
dataType
.
toLowerCase
()
===
'
json
'
)
{
try
{
res
.
data
=
JSON
.
parse
(
res
.
data
);
}
catch
(
e
)
{}
}
function
createLivePusherContext
(
id
,
vm
)
{
if
(
!
vm
)
{
return
console
.
warn
(
'
uni.createLivePusherContext 必须传入第二个参数,即当前 vm 对象(this)
'
)
return
res
}
const
elm
=
findElmById
(
id
,
vm
);
if
(
!
elm
)
{
return
console
.
warn
(
'
Can not find `
'
+
id
+
'
`
'
)
onMethod
(
'
onRequestTaskStateChange
'
,
function
({
requestTaskId
,
state
,
data
,
statusCode
,
header
,
errMsg
})
{
const
{
args
,
callbackId
}
=
requestTasks$1
[
requestTaskId
]
||
{};
if
(
!
callbackId
)
{
return
}
return
new
LivePusherContext
(
id
,
elm
)
delete
requestTasks$1
[
requestTaskId
];
switch
(
state
)
{
case
'
success
'
:
invoke
(
callbackId
,
formatResponse
({
data
,
statusCode
,
header
,
errMsg
:
'
request:ok
'
},
args
));
break
case
'
fail
'
:
invoke
(
callbackId
,
{
errMsg
:
'
request:fail
'
+
errMsg
});
break
}
});
class
MapContext
{
constructor
(
id
,
ctx
)
{
class
RequestTask
{
constructor
(
id
)
{
this
.
id
=
id
;
this
.
ctx
=
ctx
;
}
getCenterLocation
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
getCenterLocation
'
,
cbs
)
abort
()
{
invokeMethod
(
'
operateRequestTask
'
,
{
requestTaskId
:
this
.
id
,
operationType
:
'
abort
'
});
}
moveToLocation
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
moveToLocation
'
)
}
offHeadersReceived
()
{
translateMarker
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
translateMarker
'
,
args
,
[
'
animationEnd
'
])
}
includePoints
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
includePoints
'
,
args
)
}
onHeadersReceived
()
{
getRegion
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
getRegion
'
,
cbs
)
}
getScale
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
getScale
'
,
cbs
)
}
function
request$1
(
args
,
callbackId
)
{
const
{
requestTaskId
}
=
invokeMethod
(
'
createRequestTask
'
,
args
);
requestTasks$1
[
requestTaskId
]
=
{
args
,
callbackId
};
return
new
RequestTask
(
requestTaskId
)
}
function
createMapContext$1
(
id
,
vm
)
{
if
(
!
vm
)
{
return
console
.
warn
(
'
uni.createMapContext 必须传入第二个参数,即当前 vm 对象(this)
'
)
var
require_context_module_1_8
=
/*#__PURE__*/
Object
.
freeze
({
request
:
request$1
});
class
SocketTask
{
constructor
(
socketTaskId
)
{
this
.
id
=
socketTaskId
;
this
.
_callbacks
=
{
open
:
[],
close
:
[],
error
:
[],
message
:
[]
};
this
.
CLOSED
=
3
;
this
.
CLOSING
=
2
;
this
.
CONNECTING
=
0
;
this
.
OPEN
=
1
;
this
.
readyState
=
this
.
CLOSED
;
}
const
elm
=
findElmById
(
id
,
vm
);
if
(
!
elm
)
{
return
console
.
warn
(
'
Can not find `
'
+
id
+
'
`
'
)
send
(
args
)
{
if
(
this
.
readyState
!==
this
.
OPEN
)
{
this
.
_callback
(
args
,
'
sendSocketMessage:fail WebSocket is not connected
'
);
}
return
new
MapContext
(
id
,
elm
)
const
{
errMsg
}
=
invokeMethod
(
'
operateSocketTask
'
,
Object
.
assign
({},
args
,
{
operationType
:
'
send
'
,
socketTaskId
:
this
.
id
}));
this
.
_callback
(
args
,
errMsg
.
replace
(
'
operateSocketTask
'
,
'
sendSocketMessage
'
));
}
class
VideoContext
{
constructor
(
id
,
ctx
)
{
this
.
id
=
id
;
this
.
ctx
=
ctx
;
close
(
args
)
{
this
.
readyState
=
this
.
CLOSING
;
const
{
errMsg
}
=
invokeMethod
(
'
operateSocketTask
'
,
Object
.
assign
({},
args
,
{
operationType
:
'
close
'
,
socketTaskId
:
this
.
id
}));
this
.
_callback
(
args
,
errMsg
.
replace
(
'
operateSocketTask
'
,
'
closeSocket
'
));
}
play
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
play
'
)
onOpen
(
callback
)
{
this
.
_callbacks
.
open
.
push
(
callback
);
}
pause
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
pause
'
)
onClose
(
callback
)
{
this
.
_callbacks
.
close
.
push
(
callback
);
}
seek
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
seek
'
,
args
)
onError
(
callback
)
{
this
.
_callbacks
.
error
.
push
(
callback
);
}
stop
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
stop
'
)
onMessage
(
callback
)
{
this
.
_callbacks
.
message
.
push
(
callback
);
}
_callback
({
success
,
fail
,
complete
},
errMsg
)
{
var
data
=
{
errMsg
};
if
(
/:ok$/
.
test
(
errMsg
))
{
if
(
typeof
success
===
'
function
'
)
{
success
(
data
);
}
}
else
{
if
(
typeof
fail
===
'
function
'
)
{
fail
(
data
);
}
}
if
(
typeof
complete
===
'
function
'
)
{
complete
(
data
);
}
sendDanmu
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
sendDanmu
'
,
args
)
}
playbackRate
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
playbackRate
'
,
args
)
}
requestFullScreen
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
requestFullScreen
'
,
args
)
const
socketTasks$1
=
Object
.
create
(
null
);
const
socketTasksArray
=
[];
const
callbacks$3
=
Object
.
create
(
null
);
onMethod
(
'
onSocketTaskStateChange
'
,
({
socketTaskId
,
state
,
data
,
errMsg
})
=>
{
const
socketTask
=
socketTasks$1
[
socketTaskId
];
if
(
!
socketTask
)
{
return
}
socketTask
.
_callbacks
[
state
].
forEach
(
callback
=>
{
if
(
typeof
callback
===
'
function
'
)
{
callback
(
state
===
'
message
'
?
{
data
}
:
{});
}
});
if
(
state
===
'
open
'
)
{
socketTask
.
readyState
=
socketTask
.
OPEN
;
}
if
(
socketTask
===
socketTasksArray
[
0
]
&&
callbacks$3
[
state
])
{
invoke
(
callbacks$3
[
state
],
state
===
'
message
'
?
{
data
}
:
{});
}
if
(
state
===
'
error
'
||
state
===
'
close
'
)
{
socketTask
.
readyState
=
socketTask
.
CLOSED
;
delete
socketTasks$1
[
socketTaskId
];
const
index
=
socketTasksArray
.
indexOf
(
socketTask
);
if
(
index
>=
0
)
{
socketTasksArray
.
splice
(
index
,
1
);
}
}
});
exitFullScreen
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
exitFullScreen
'
)
function
connectSocket$1
(
args
,
callbackId
)
{
const
{
socketTaskId
}
=
invokeMethod
(
'
createSocketTask
'
,
args
);
const
task
=
new
SocketTask
(
socketTaskId
);
socketTasks$1
[
socketTaskId
]
=
task
;
socketTasksArray
.
push
(
task
);
setTimeout
(()
=>
{
invoke
(
callbackId
,
{
errMsg
:
'
connectSocket:ok
'
});
},
0
);
return
task
}
showStatusBar
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
showStatusBar
'
)
function
sendSocketMessage$1
(
args
,
callbackId
)
{
const
socketTask
=
socketTasksArray
[
0
];
if
(
!
socketTask
||
socketTask
.
readyState
!==
socketTask
.
OPEN
)
{
invoke
(
callbackId
,
{
errMsg
:
'
sendSocketMessage:fail WebSocket is not connected
'
});
return
}
return
invokeMethod
(
'
operateSocketTask
'
,
Object
.
assign
({},
args
,
{
operationType
:
'
send
'
,
socketTaskId
:
socketTask
.
id
}))
}
hideStatusBar
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
hideStatusBar
'
)
function
closeSocket$1
(
args
,
callbackId
)
{
const
socketTask
=
socketTasksArray
[
0
];
if
(
!
socketTask
)
{
invoke
(
callbackId
,
{
errMsg
:
'
closeSocket:fail WebSocket is not connected
'
});
return
}
socketTask
.
readyState
=
socketTask
.
CLOSING
;
return
invokeMethod
(
'
operateSocketTask
'
,
Object
.
assign
({},
args
,
{
operationType
:
'
close
'
,
socketTaskId
:
socketTask
.
id
}))
}
function
createVideoContext$1
(
id
,
vm
)
{
if
(
!
vm
)
{
return
console
.
warn
(
'
uni.createVideoContext 必须传入第二个参数,即当前 vm 对象(this)
'
)
function
onSocketOpen
(
callbackId
)
{
callbacks$3
.
open
=
callbackId
;
}
const
elm
=
findElmById
(
id
,
vm
);
if
(
!
elm
)
{
return
console
.
warn
(
'
Can not find `
'
+
id
+
'
`
'
)
function
onSocketError
(
callbackId
)
{
callbacks$3
.
error
=
callbackId
;
}
return
new
VideoContext
(
id
,
elm
)
function
onSocketMessage
(
callbackId
)
{
callbacks$3
.
message
=
callbackId
;
}
function
requireNativePlugin$1
(
name
)
{
return
weex
.
requireModule
(
name
)
function
onSocketClose
(
callbackId
)
{
callbacks$3
.
close
=
callbackId
;
}
const
ANI_DURATION$1
=
300
;
const
ANI_SHOW$1
=
'
pop-in
'
;
const
ANI_CLOSE
=
'
pop-out
'
;
var
require_context_module_1_9
=
/*#__PURE__*/
Object
.
freeze
({
connectSocket
:
connectSocket$1
,
sendSocketMessage
:
sendSocketMessage$1
,
closeSocket
:
closeSocket$1
,
onSocketOpen
:
onSocketOpen
,
onSocketError
:
onSocketError
,
onSocketMessage
:
onSocketMessage
,
onSocketClose
:
onSocketClose
});
function
showWebview
(
webview
,
animationType
,
animationDuration
,
callback
)
{
setTimeout
(()
=>
{
webview
.
show
(
animationType
||
ANI_SHOW$1
,
parseInt
(
animationDuration
)
||
ANI_DURATION$1
,
()
=>
{
callback
&&
callback
();
class
UploadTask
{
constructor
(
uploadTaskId
,
callbackId
)
{
this
.
id
=
uploadTaskId
;
this
.
_callbackId
=
callbackId
;
this
.
_callbacks
=
[];
}
);
},
50
);
abort
()
{
invokeMethod
(
'
operateRequestTask
'
,
{
uploadTaskId
:
this
.
id
,
operationType
:
'
abort
'
});
}
onProgressUpdate
(
callback
)
{
if
(
typeof
callback
!==
'
function
'
)
{
return
}
this
.
_callbacks
.
push
(
callback
);
}
onHeadersReceived
()
{
let
firstBackTime
=
0
;
function
quit
()
{
if
(
!
firstBackTime
)
{
firstBackTime
=
Date
.
now
();
plus
.
nativeUI
.
toast
(
'
再按一次退出应用
'
);
setTimeout
(()
=>
{
firstBackTime
=
null
;
},
2000
);
}
else
if
(
Date
.
now
()
-
firstBackTime
<
2000
)
{
plus
.
runtime
.
quit
();
}
offProgressUpdate
(
callback
)
{
const
index
=
this
.
_callbacks
.
indexOf
(
callback
);
if
(
index
>=
0
)
{
this
.
_callbacks
.
splice
(
index
,
1
);
}
}
offHeadersReceived
()
{
function
backWebview
(
webview
,
callback
)
{
if
(
!
webview
.
__uniapp_webview
)
{
return
callback
()
}
const
children
=
webview
.
children
();
if
(
!
children
||
!
children
.
length
)
{
// 有子 webview
return
callback
()
}
const
childWebview
=
children
[
0
];
childWebview
.
canBack
(({
canBack
const
uploadTasks$1
=
Object
.
create
(
null
);
onMethod
(
'
onUploadTaskStateChange
'
,
({
uploadTaskId
,
state
,
data
,
statusCode
,
progress
,
totalBytesSent
,
totalBytesExpectedToSend
,
errMsg
})
=>
{
if
(
canBack
)
{
childWebview
.
back
();
// webview 返回
}
else
{
callback
();
const
uploadTask
=
uploadTasks$1
[
uploadTaskId
];
const
callbackId
=
uploadTask
.
_callbackId
;
switch
(
state
)
{
case
'
progressUpdate
'
:
uploadTask
.
_callbacks
.
forEach
(
callback
=>
{
callback
({
progress
,
totalBytesSent
,
totalBytesExpectedToSend
});
});
break
case
'
success
'
:
invoke
(
callbackId
,
{
data
,
statusCode
,
errMsg
:
'
request:ok
'
});
// eslint-disable-next-line no-fallthrough
case
'
fail
'
:
invoke
(
callbackId
,
{
errMsg
:
'
request:fail
'
+
errMsg
});
// eslint-disable-next-line no-fallthrough
default
:
// progressUpdate 可能晚于 success
setTimeout
(()
=>
{
delete
uploadTasks$1
[
uploadTaskId
];
},
100
);
break
}
});
function
uploadFile$1
(
args
,
callbackId
)
{
const
{
uploadTaskId
}
=
invokeMethod
(
'
createUploadTask
'
,
args
);
const
task
=
new
UploadTask
(
uploadTaskId
,
callbackId
);
uploadTasks$1
[
uploadTaskId
]
=
task
;
return
task
}
function
back
(
delta
,
animationType
,
animationDuration
)
{
const
pages
=
getCurrentPages
();
const
len
=
pages
.
length
;
const
currentPage
=
pages
[
len
-
1
];
if
(
delta
>
1
)
{
// 中间页隐藏
pages
.
slice
(
len
-
delta
,
len
-
1
).
reverse
().
forEach
(
deltaPage
=>
{
deltaPage
.
$getAppWebview
().
close
(
'
none
'
);
var
require_context_module_1_10
=
/*#__PURE__*/
Object
.
freeze
({
uploadFile
:
uploadFile$1
});
}
backWebview
(
currentPage
,
()
=>
{
if
(
animationType
)
{
currentPage
.
$getAppWebview
().
close
(
animationType
,
animationDuration
||
ANI_DURATION$1
);
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
{
if
(
currentPage
.
$page
.
openType
===
'
redirect
'
)
{
// 如果是 redirectTo 跳转的,需要制定 back 动画
currentPage
.
$getAppWebview
().
close
(
ANI_CLOSE
,
ANI_DURATION$1
);
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
'
}
currentPage
.
$getAppWebview
().
close
(
'
auto
'
);
}
pages
.
slice
(
len
-
delta
,
len
).
forEach
(
page
=>
page
.
$remove
());
setStatusBarStyle
();
UniServiceJSBridge
.
emit
(
'
onAppRoute
'
,
{
type
:
'
navigateBack
'
});
function
setStorageSync$1
(
key
,
data
)
{
setStorage$1
({
key
,
data
});
}
function
navigateBack$1
({
delta
,
animationType
,
animationDuration
})
{
const
pages
=
getCurrentPages
();
const
len
=
pages
.
length
;
uni
.
hideToast
();
// 后退时,关闭 toast,loading
pages
[
len
-
1
].
$page
.
meta
.
isQuit
?
quit
()
:
back
(
delta
,
animationType
,
animationDuration
);
function
getStorage$1
({
key
}
=
{})
{
const
data
=
localStorage
.
getItem
(
key
);
return
data
?
{
data
:
JSON
.
parse
(
data
).
data
,
errMsg
:
'
getStorage:ok
'
}
:
{
data
:
''
,
errMsg
:
'
getStorage:fail
'
}
}
function
navigateTo$1
({
url
,
animationType
,
animationDuration
})
{
const
urls
=
url
.
split
(
'
?
'
);
const
path
=
urls
[
0
];
const
query
=
parseQuery
(
urls
[
1
]
||
''
);
UniServiceJSBridge
.
emit
(
'
onAppRoute
'
,
{
type
:
'
navigateTo
'
,
path
function
getStorageSync$1
(
key
)
{
const
res
=
getStorage$1
({
key
});
return
res
.
data
}
showWebview
(
__registerPage
({
path
,
query
,
openType
:
'
navigate
'
}),
animationType
,
animationDuration
);
function
removeStorage$1
({
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
'
}
}
setStatusBarStyle
();
function
removeStorageSync$1
(
key
)
{
removeStorage$1
({
key
});
}
function
reLaunch$1
({
url
})
{
const
urls
=
url
.
split
(
'
?
'
);
const
path
=
urls
[
0
];
function
clearStorage
()
{
localStorage
.
clear
();
return
{
errMsg
:
'
clearStorage:ok
'
}
}
const
query
=
parseQuery
(
urls
[
1
]
||
''
);
function
clearStorageSync
()
{
clearStorage
();
}
const
pages
=
getCurrentPages
(
true
).
slice
(
0
);
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
'
}
}
const
routeOptions
=
__uniRoutes
.
find
(
route
=>
route
.
path
===
path
);
function
getStorageInfoSync
()
{
const
res
=
getStorageInfo
();
delete
res
.
errMsg
;
return
res
}
if
(
routeOptions
.
meta
.
isTabBar
)
{
tabBar
.
switchTab
(
url
);
var
require_context_module_1_11
=
/*#__PURE__*/
Object
.
freeze
({
setStorage
:
setStorage$1
,
setStorageSync
:
setStorageSync$1
,
getStorage
:
getStorage$1
,
getStorageSync
:
getStorageSync$1
,
removeStorage
:
removeStorage$1
,
removeStorageSync
:
removeStorageSync$1
,
clearStorage
:
clearStorage
,
clearStorageSync
:
clearStorageSync
,
getStorageInfo
:
getStorageInfo
,
getStorageInfoSync
:
getStorageInfoSync
});
function
pageScrollTo$1
(
args
)
{
const
pages
=
getCurrentPages
();
if
(
pages
.
length
)
{
UniServiceJSBridge
.
publishHandler
(
'
pageScrollTo
'
,
args
,
pages
[
pages
.
length
-
1
].
$page
.
id
);
}
return
{}
}
showWebview
(
__registerPage
({
path
,
query
,
openType
:
'
reLaunch
'
}),
'
none
'
,
0
);
var
require_context_module_1_12
=
/*#__PURE__*/
Object
.
freeze
({
pageScrollTo
:
pageScrollTo$1
});
pages
.
forEach
(
page
=>
{
page
.
$remove
();
page
.
$getAppWebview
().
close
(
'
none
'
);
const
api$1
=
Object
.
create
(
null
);
const
modules$1
=
(
function
()
{
var
map
=
{
'
./base/base64.js
'
:
require_context_module_1_0
,
'
./base/can-i-use.js
'
:
require_context_module_1_1
,
'
./base/interceptor.js
'
:
require_context_module_1_2
,
'
./base/upx2px.js
'
:
require_context_module_1_3
,
'
./device/accelerometer.js
'
:
require_context_module_1_4
,
'
./device/bluetooth.js
'
:
require_context_module_1_5
,
'
./device/compass.js
'
:
require_context_module_1_6
,
'
./network/download-file.js
'
:
require_context_module_1_7
,
'
./network/request.js
'
:
require_context_module_1_8
,
'
./network/socket.js
'
:
require_context_module_1_9
,
'
./network/upload-file.js
'
:
require_context_module_1_10
,
'
./storage/storage.js
'
:
require_context_module_1_11
,
'
./ui/page-scroll-to.js
'
:
require_context_module_1_12
,
};
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
;
})();
modules$1
.
keys
().
forEach
(
function
(
key
)
{
Object
.
assign
(
api$1
,
modules$1
(
key
));
});
setStatusBarStyle
();
const
SUCCESS
=
'
success
'
;
const
FAIL
=
'
fail
'
;
const
COMPLETE
=
'
complete
'
;
const
CALLBACKS
=
[
SUCCESS
,
FAIL
,
COMPLETE
];
/**
* 调用无参数,或仅一个参数且为 callback 的 API
* @param {Object} vm
* @param {Object} method
* @param {Object} args
* @param {Object} extras
*/
function
invokeVmMethodWithoutArgs
(
vm
,
method
,
args
,
extras
)
{
if
(
!
vm
)
{
return
}
if
(
typeof
args
===
'
undefined
'
)
{
return
vm
[
method
]()
}
const
[,
callbacks
]
=
normalizeArgs
(
args
,
extras
);
if
(
!
Object
.
keys
(
callbacks
).
length
)
{
return
vm
[
method
]()
}
return
vm
[
method
](
normalizeCallback
(
method
,
callbacks
))
}
/**
* 调用两个参数(第一个入参为普通参数,第二个入参为 callback) API
* @param {Object} vm
* @param {Object} method
* @param {Object} args
* @param {Object} extras
*/
function
invokeVmMethod
(
vm
,
method
,
args
,
extras
)
{
if
(
!
vm
)
{
return
}
const
[
pureArgs
,
callbacks
]
=
normalizeArgs
(
args
,
extras
);
if
(
!
Object
.
keys
(
callbacks
).
length
)
{
return
vm
[
method
](
pureArgs
)
}
return
vm
[
method
](
pureArgs
,
normalizeCallback
(
method
,
callbacks
))
}
function
redirectTo$1
({
url
})
{
const
urls
=
url
.
split
(
'
?
'
);
const
path
=
urls
[
0
];
function
findElmById
(
id
,
vm
)
{
return
findElmByVNode
(
id
,
vm
.
_vnode
)
}
const
query
=
parseQuery
(
urls
[
1
]
||
''
);
function
findElmByVNode
(
id
,
vnode
)
{
if
(
!
id
||
!
vnode
)
{
return
}
if
(
vnode
.
data
&&
vnode
.
data
.
attrs
&&
vnode
.
data
.
attrs
.
id
===
id
)
{
return
vnode
.
elm
}
const
children
=
vnode
.
children
;
if
(
!
children
)
{
return
}
for
(
let
i
=
0
,
len
=
children
.
length
;
i
<
len
;
i
++
)
{
const
elm
=
findElmByVNode
(
id
,
children
[
i
]);
if
(
elm
)
{
return
elm
}
}
}
const
pages
=
getCurrentPages
();
const
lastPage
=
pages
[
pages
.
length
-
1
]
;
function
normalizeArgs
(
args
=
{},
extras
)
{
const
callbacks
=
Object
.
create
(
null
)
;
lastPage
&&
lastPage
.
$remove
();
const
iterator
=
function
iterator
(
name
)
{
const
callback
=
args
[
name
];
if
(
isFn
(
callback
))
{
callbacks
[
name
]
=
callback
;
delete
args
[
name
];
}
};
showWebview
(
__registerPage
({
path
,
query
,
openType
:
'
redirect
'
}),
'
none
'
,
0
,
()
=>
{
lastPage
&&
lastPage
.
$getAppWebview
().
close
(
'
none
'
);
CALLBACKS
.
forEach
(
iterator
);
extras
&&
extras
.
forEach
(
iterator
);
return
[
args
,
callbacks
]
}
);
setStatusBarStyle
();
function
normalizeCallback
(
method
,
callbacks
)
{
return
function
weexCallback
(
ret
)
{
const
type
=
ret
.
type
;
delete
ret
.
type
;
const
callback
=
callbacks
[
type
];
if
(
type
===
SUCCESS
)
{
ret
.
errMsg
=
`
${
method
}
:ok`
;
}
else
if
(
type
===
FAIL
)
{
ret
.
errMsg
=
method
+
'
:fail
'
+
(
ret
.
msg
?
(
'
'
+
ret
.
msg
)
:
''
);
}
function
switchTab$1
({
url
,
from
})
{
const
path
=
url
.
split
(
'
?
'
)[
0
];
delete
ret
.
code
;
delete
ret
.
msg
;
tabBar
.
switchTab
(
path
.
slice
(
1
)
);
isFn
(
callback
)
&&
callback
(
ret
);
const
pages
=
getCurrentPages
();
const
len
=
pages
.
length
;
if
(
type
===
SUCCESS
||
type
===
FAIL
)
{
const
complete
=
callbacks
[
'
complete
'
];
isFn
(
complete
)
&&
complete
(
ret
);
}
}
}
if
(
len
>=
1
)
{
// 前一个页面是非 tabBar 页面
const
currentPage
=
pages
[
len
-
1
];
if
(
!
currentPage
.
$page
.
meta
.
isTabBar
)
{
pages
.
reverse
().
forEach
(
page
=>
{
if
(
!
page
.
$page
.
meta
.
isTabBar
&&
page
!==
currentPage
)
{
page
.
$remove
();
page
.
$getAppWebview
().
close
(
'
none
'
);
class
LivePusherContext
{
constructor
(
id
,
ctx
)
{
this
.
id
=
id
;
this
.
ctx
=
ctx
;
}
});
currentPage
.
$remove
();
if
(
currentPage
.
$page
.
openType
===
'
redirect
'
)
{
currentPage
.
$getAppWebview
().
close
(
ANI_CLOSE
,
ANI_DURATION$1
);
}
else
{
currentPage
.
$getAppWebview
().
close
(
'
auto
'
);
start
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
start
'
,
cbs
)
}
}
else
{
// TODO 客户端 Bug
currentPage
.
$getAppWebview
().
hide
(
'
none
'
);
// 前一个 tabBar 触发 onHide
currentPage
.
$vm
.
__call_hook
(
'
onHide
'
);
stop
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
stop
'
,
cbs
)
}
pause
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
pause
'
,
cbs
)
}
let
tabBarPage
;
// 查找当前 tabBarPage,且设置 visible
getCurrentPages
(
true
).
forEach
(
page
=>
{
if
((
'
/
'
+
page
.
route
)
===
path
)
{
page
.
$page
.
meta
.
visible
=
true
;
tabBarPage
=
page
;
}
else
{
if
(
page
.
$page
.
meta
.
isTabBar
)
{
page
.
$page
.
meta
.
visible
=
false
;
resume
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
resume
'
,
cbs
)
}
switchCamera
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
switchCamera
'
,
cbs
)
}
snapshot
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
snapshot
'
,
cbs
)
}
toggleTorch
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
toggleTorch
'
,
cbs
)
}
playBGM
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
playBGM
'
,
args
)
}
stopBGM
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
stopBGM
'
,
cbs
)
}
pauseBGM
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
pauseBGM
'
,
cbs
)
}
resumeBGM
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
resumeBGM
'
,
cbs
)
}
setBGMVolume
(
cbs
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
setBGMVolume
'
,
cbs
)
}
startPreview
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
startPreview
'
,
cbs
)
}
stopPreview
(
args
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
stopPreview
'
,
args
)
}
}
function
createLivePusherContext
(
id
,
vm
)
{
if
(
!
vm
)
{
return
console
.
warn
(
'
uni.createLivePusherContext 必须传入第二个参数,即当前 vm 对象(this)
'
)
}
const
elm
=
findElmById
(
id
,
vm
);
if
(
!
elm
)
{
return
console
.
warn
(
'
Can not find `
'
+
id
+
'
`
'
)
}
return
new
LivePusherContext
(
id
,
elm
)
}
class
MapContext
{
constructor
(
id
,
ctx
)
{
this
.
id
=
id
;
this
.
ctx
=
ctx
;
}
getCenterLocation
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
getCenterLocation
'
,
cbs
)
}
moveToLocation
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
moveToLocation
'
)
}
translateMarker
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
translateMarker
'
,
args
,
[
'
animationEnd
'
])
}
includePoints
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
includePoints
'
,
args
)
}
getRegion
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
getRegion
'
,
cbs
)
}
getScale
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
getScale
'
,
cbs
)
}
}
function
createMapContext$1
(
id
,
vm
)
{
if
(
!
vm
)
{
return
console
.
warn
(
'
uni.createMapContext 必须传入第二个参数,即当前 vm 对象(this)
'
)
}
const
elm
=
findElmById
(
id
,
vm
);
if
(
!
elm
)
{
return
console
.
warn
(
'
Can not find `
'
+
id
+
'
`
'
)
}
return
new
MapContext
(
id
,
elm
)
}
class
VideoContext
{
constructor
(
id
,
ctx
)
{
this
.
id
=
id
;
this
.
ctx
=
ctx
;
}
play
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
play
'
)
}
pause
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
pause
'
)
}
seek
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
seek
'
,
args
)
}
stop
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
stop
'
)
}
});
if
(
tabBarPage
)
{
tabBarPage
.
$vm
.
__call_hook
(
'
onShow
'
);
tabBarPage
.
$getAppWebview
().
show
(
'
none
'
);
}
else
{
showWebview
(
__registerPage
({
path
,
query
:
{},
openType
:
'
switchTab
'
})
);
sendDanmu
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
sendDanmu
'
,
args
)
}
setStatusBarStyle
();
playbackRate
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
playbackRate
'
,
args
)
}
requestFullScreen
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
requestFullScreen
'
,
args
)
}
exitFullScreen
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
exitFullScreen
'
)
}
var
nvueApi
=
/*#__PURE__*/
Object
.
freeze
({
createLivePusherContext
:
createLivePusherContext
,
createMapContext
:
createMapContext$1
,
createVideoContext
:
createVideoContext$1
,
requireNativePlugin
:
requireNativePlugin$1
,
navigateBack
:
navigateBack$1
,
navigateTo
:
navigateTo$1
,
reLaunch
:
reLaunch$1
,
redirectTo
:
redirectTo$1
,
switchTab
:
switchTab$1
});
showStatusBar
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
showStatusBar
'
)
}
var
platformApi
=
Object
.
assign
(
Object
.
create
(
null
),
appApi
,
nvueApi
);
hideStatusBar
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
hideStatusBar
'
)
}
}
/**
* 执行内部平台方法
*/
function
invokeMethod
(
name
,
...
args
)
{
return
platformApi
[
name
].
apply
(
null
,
args
)
function
createVideoContext$1
(
id
,
vm
)
{
if
(
!
vm
)
{
return
console
.
warn
(
'
uni.createVideoContext 必须传入第二个参数,即当前 vm 对象(this)
'
)
}
/**
* 监听 service 层内部平台方法回调,与 publish 对应
* @param {Object} name
* @param {Object} callback
*/
function
onMethod
(
name
,
callback
)
{
return
UniServiceJSBridge
.
on
(
'
api.
'
+
name
,
callback
)
const
elm
=
findElmById
(
id
,
vm
);
if
(
!
elm
)
{
return
console
.
warn
(
'
Can not find `
'
+
id
+
'
`
'
)
}
return
new
VideoContext
(
id
,
elm
)
}
const
callbacks$1
=
[];
function
requireNativePlugin$1
(
name
)
{
return
weex
.
requireModule
(
name
)
}
onMethod
(
'
onAccelerometerChange
'
,
function
(
res
)
{
callbacks$1
.
forEach
(
callbackId
=>
{
invoke
(
callbackId
,
res
);
});
});
const
ANI_DURATION$1
=
300
;
const
ANI_SHOW$1
=
'
pop-in
'
;
const
ANI_CLOSE
=
'
pop-out
'
;
let
isEnable
=
false
;
/**
* 监听加速度
* @param {*} callbackId
*/
function
onAccelerometerChange
(
callbackId
)
{
// TODO 当没有 start 时,添加 on 需要主动 start?
callbacks$1
.
push
(
callbackId
);
if
(
!
isEnable
)
{
startAccelerometer
();
function
showWebview
(
webview
,
animationType
,
animationDuration
,
callback
)
{
setTimeout
(()
=>
{
webview
.
show
(
animationType
||
ANI_SHOW$1
,
parseInt
(
animationDuration
)
||
ANI_DURATION$1
,
()
=>
{
callback
&&
callback
();
}
);
},
50
);
}
function
startAccelerometer
({
interval
// TODO
}
=
{})
{
if
(
isEnable
)
{
return
let
firstBackTime
=
0
;
function
quit
()
{
if
(
!
firstBackTime
)
{
firstBackTime
=
Date
.
now
();
plus
.
nativeUI
.
toast
(
'
再按一次退出应用
'
);
setTimeout
(()
=>
{
firstBackTime
=
null
;
},
2000
);
}
else
if
(
Date
.
now
()
-
firstBackTime
<
2000
)
{
plus
.
runtime
.
quit
();
}
isEnable
=
true
;
return
invokeMethod
(
'
enableAccelerometer
'
,
{
enable
:
true
})
}
function
stopAccelerometer
()
{
isEnable
=
false
;
return
invokeMethod
(
'
enableAccelerometer
'
,
{
enable
:
false
})
function
backWebview
(
webview
,
callback
)
{
if
(
!
webview
.
__uniapp_webview
)
{
return
callback
()
}
const
children
=
webview
.
children
();
if
(
!
children
||
!
children
.
length
)
{
// 有子 webview
return
callback
()
}
const
childWebview
=
children
[
0
];
childWebview
.
canBack
(({
canBack
})
=>
{
if
(
canBack
)
{
childWebview
.
back
();
// webview 返回
}
else
{
callback
();
}
var
require_context_module_1_4
=
/*#__PURE__*/
Object
.
freeze
({
onAccelerometerChange
:
onAccelerometerChange
,
startAccelerometer
:
startAccelerometer
,
stopAccelerometer
:
stopAccelerometer
});
}
const
requestTasks$1
=
Object
.
create
(
null
);
function
back
(
delta
,
animationType
,
animationDuration
)
{
const
pages
=
getCurrentPages
();
const
len
=
pages
.
length
;
const
currentPage
=
pages
[
len
-
1
];
function
formatResponse
(
res
,
args
)
{
if
(
typeof
res
.
data
===
'
string
'
&&
res
.
data
.
charCodeAt
(
0
)
===
65279
)
{
res
.
data
=
res
.
data
.
substr
(
1
);
if
(
delta
>
1
)
{
// 中间页隐藏
pages
.
slice
(
len
-
delta
,
len
-
1
).
reverse
().
forEach
(
deltaPage
=>
{
deltaPage
.
$getAppWebview
().
close
(
'
none
'
);
});
}
res
.
statusCode
=
parseInt
(
res
.
statusCode
,
10
);
if
(
isPlainObject
(
res
.
header
))
{
res
.
header
=
Object
.
keys
(
res
.
header
).
reduce
(
function
(
ret
,
key
)
{
const
value
=
res
.
header
[
key
];
if
(
Array
.
isArray
(
value
))
{
ret
[
key
]
=
value
.
join
(
'
,
'
);
}
else
if
(
typeof
value
===
'
string
'
)
{
ret
[
key
]
=
value
;
backWebview
(
currentPage
,
()
=>
{
if
(
animationType
)
{
currentPage
.
$getAppWebview
().
close
(
animationType
,
animationDuration
||
ANI_DURATION$1
);
}
else
{
if
(
currentPage
.
$page
.
openType
===
'
redirect
'
)
{
// 如果是 redirectTo 跳转的,需要制定 back 动画
currentPage
.
$getAppWebview
().
close
(
ANI_CLOSE
,
ANI_DURATION$1
);
}
return
ret
},
{});
currentPage
.
$getAppWebview
().
close
(
'
auto
'
);
}
if
(
args
.
dataType
&&
args
.
dataType
.
toLowerCase
()
===
'
json
'
)
{
try
{
res
.
data
=
JSON
.
parse
(
res
.
data
);
}
catch
(
e
)
{}
}
pages
.
slice
(
len
-
delta
,
len
).
forEach
(
page
=>
page
.
$remove
());
return
res
setStatusBarStyle
();
UniServiceJSBridge
.
emit
(
'
onAppRoute
'
,
{
type
:
'
navigateBack
'
});
});
}
onMethod
(
'
onRequestTaskStateChange
'
,
function
({
requestTaskId
,
state
,
data
,
statusCode
,
header
,
errMsg
function
navigateBack$1
({
delta
,
animationType
,
animationDuration
})
{
const
{
args
,
callbackId
}
=
requestTasks$1
[
requestTaskId
];
const
pages
=
getCurrentPages
();
const
len
=
pages
.
length
;
if
(
!
callbackId
)
{
return
}
delete
requestTasks$1
[
requestTaskId
];
switch
(
state
)
{
case
'
success
'
:
invoke
(
callbackId
,
formatResponse
({
data
,
statusCode
,
header
,
errMsg
:
'
request:ok
'
},
args
));
break
case
'
fail
'
:
invoke
(
callbackId
,
{
errMsg
:
'
request:fail
'
+
errMsg
});
break
}
});
uni
.
hideToast
();
// 后退时,关闭 toast,loading
class
RequestTask
{
constructor
(
id
)
{
this
.
id
=
id
;
pages
[
len
-
1
].
$page
.
meta
.
isQuit
?
quit
()
:
back
(
delta
,
animationType
,
animationDuration
)
;
}
abort
()
{
invokeMethod
(
'
operateRequestTask
'
,
{
requestTaskId
:
this
.
id
,
operationType
:
'
abort
'
function
navigateTo$1
({
url
,
animationType
,
animationDuration
})
{
const
urls
=
url
.
split
(
'
?
'
);
const
path
=
urls
[
0
];
const
query
=
parseQuery
(
urls
[
1
]
||
''
);
UniServiceJSBridge
.
emit
(
'
onAppRoute
'
,
{
type
:
'
navigateTo
'
,
path
});
}
offHeadersReceived
()
{
showWebview
(
__registerPage
({
path
,
query
,
openType
:
'
navigate
'
}),
animationType
,
animationDuration
);
setStatusBarStyle
();
}
onHeadersReceived
()
{
function
reLaunch$1
({
url
})
{
const
urls
=
url
.
split
(
'
?
'
);
const
path
=
urls
[
0
];
}
}
const
query
=
parseQuery
(
urls
[
1
]
||
''
);
function
request$1
(
args
,
callbackId
)
{
const
{
requestTaskId
}
=
invokeMethod
(
'
createRequestTask
'
,
args
);
const
pages
=
getCurrentPages
(
true
).
slice
(
0
);
requestTasks$1
[
requestTaskId
]
=
{
args
,
callbackId
};
const
routeOptions
=
__uniRoutes
.
find
(
route
=>
route
.
path
===
path
);
return
new
RequestTask
(
requestTaskId
)
if
(
routeOptions
.
meta
.
isTabBar
)
{
tabBar
.
switchTab
(
url
);
}
var
require_context_module_1_5
=
/*#__PURE__*/
Object
.
freeze
({
request
:
request$1
});
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
'
}
}
showWebview
(
__registerPage
({
path
,
query
,
openType
:
'
reLaunch
'
}),
'
none
'
,
0
);
function
setStorageSync$1
(
key
,
data
)
{
setStorage$1
({
key
,
data
pages
.
forEach
(
page
=>
{
page
.
$remove
();
page
.
$getAppWebview
().
close
(
'
none
'
);
});
}
function
getStorage$1
({
key
}
=
{})
{
const
data
=
localStorage
.
getItem
(
key
);
return
data
?
{
data
:
JSON
.
parse
(
data
).
data
,
errMsg
:
'
getStorage:ok
'
}
:
{
data
:
''
,
errMsg
:
'
getStorage:fail
'
}
setStatusBarStyle
();
}
function
getStorageSync$1
(
key
)
{
const
res
=
getStorage$1
({
key
});
return
res
.
data
}
function
redirectTo$1
({
url
})
{
const
urls
=
url
.
split
(
'
?
'
);
const
path
=
urls
[
0
];
function
removeStorage$1
({
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
'
}
}
const
query
=
parseQuery
(
urls
[
1
]
||
''
);
function
removeStorageSync$1
(
key
)
{
removeStorage$1
({
key
});
}
const
pages
=
getCurrentPages
();
const
lastPage
=
pages
[
pages
.
length
-
1
];
function
clearStorage
()
{
localStorage
.
clear
();
return
{
errMsg
:
'
clearStorage:ok
'
}
}
lastPage
&&
lastPage
.
$remove
();
function
clearStorageSync
()
{
clearStorage
();
showWebview
(
__registerPage
({
path
,
query
,
openType
:
'
redirect
'
}),
'
none
'
,
0
,
()
=>
{
lastPage
&&
lastPage
.
$getAppWebview
().
close
(
'
none
'
);
}
);
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
'
}
setStatusBarStyle
();
}
function
getStorageInfoSync
()
{
const
res
=
getStorageInfo
();
delete
res
.
errMsg
;
return
res
}
function
switchTab$1
(
{
url
,
from
})
{
const
path
=
url
.
split
(
'
?
'
)[
0
];
var
require_context_module_1_6
=
/*#__PURE__*/
Object
.
freeze
({
setStorage
:
setStorage$1
,
setStorageSync
:
setStorageSync$1
,
getStorage
:
getStorage$1
,
getStorageSync
:
getStorageSync$1
,
removeStorage
:
removeStorage$1
,
removeStorageSync
:
removeStorageSync$1
,
clearStorage
:
clearStorage
,
clearStorageSync
:
clearStorageSync
,
getStorageInfo
:
getStorageInfo
,
getStorageInfoSync
:
getStorageInfoSync
});
tabBar
.
switchTab
(
path
.
slice
(
1
));
function
pageScrollTo$1
(
args
)
{
const
pages
=
getCurrentPages
();
if
(
pages
.
length
)
{
UniServiceJSBridge
.
publishHandler
(
'
pageScrollTo
'
,
args
,
pages
[
pages
.
length
-
1
].
$page
.
id
);
const
len
=
pages
.
length
;
if
(
len
>=
1
)
{
// 前一个页面是非 tabBar 页面
const
currentPage
=
pages
[
len
-
1
];
if
(
!
currentPage
.
$page
.
meta
.
isTabBar
)
{
pages
.
reverse
().
forEach
(
page
=>
{
if
(
!
page
.
$page
.
meta
.
isTabBar
&&
page
!==
currentPage
)
{
page
.
$remove
();
page
.
$getAppWebview
().
close
(
'
none
'
);
}
});
currentPage
.
$remove
();
if
(
currentPage
.
$page
.
openType
===
'
redirect
'
)
{
currentPage
.
$getAppWebview
().
close
(
ANI_CLOSE
,
ANI_DURATION$1
);
}
else
{
currentPage
.
$getAppWebview
().
close
(
'
auto
'
);
}
}
else
{
// 前一个 tabBar 触发 onHide
currentPage
.
$vm
.
__call_hook
(
'
onHide
'
);
}
return
{}
}
var
require_context_module_1_7
=
/*#__PURE__*/
Object
.
freeze
({
pageScrollTo
:
pageScrollTo$1
let
tabBarPage
;
// 查找当前 tabBarPage,且设置 visible
getCurrentPages
(
true
).
forEach
(
page
=>
{
if
((
'
/
'
+
page
.
route
)
===
path
)
{
page
.
$page
.
meta
.
visible
=
true
;
tabBarPage
=
page
;
}
else
{
if
(
page
.
$page
.
meta
.
isTabBar
)
{
page
.
$page
.
meta
.
visible
=
false
;
}
}
});
const
api
=
Object
.
create
(
null
);
if
(
tabBarPage
)
{
tabBarPage
.
$vm
.
__call_hook
(
'
onShow
'
);
tabBarPage
.
$getAppWebview
().
show
(
'
none
'
);
}
else
{
showWebview
(
__registerPage
({
path
,
query
:
{},
openType
:
'
switchTab
'
})
);
}
const
modules$1
=
(
function
()
{
var
map
=
{
'
./base/base64.js
'
:
require_context_module_1_0
,
'
./base/can-i-use.js
'
:
require_context_module_1_1
,
'
./base/interceptor.js
'
:
require_context_module_1_2
,
'
./base/upx2px.js
'
:
require_context_module_1_3
,
'
./device/accelerometer.js
'
:
require_context_module_1_4
,
'
./network/request.js
'
:
require_context_module_1_5
,
'
./storage/storage.js
'
:
require_context_module_1_6
,
'
./ui/page-scroll-to.js
'
:
require_context_module_1_7
,
setStatusBarStyle
();
}
};
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
;
})();
modules$1
.
keys
().
forEach
(
function
(
key
)
{
Object
.
assign
(
api
,
modules$1
(
key
));
var
nvueApi
=
/*#__PURE__*/
Object
.
freeze
({
createLivePusherContext
:
createLivePusherContext
,
createMapContext
:
createMapContext$1
,
createVideoContext
:
createVideoContext$1
,
requireNativePlugin
:
requireNativePlugin$1
,
navigateBack
:
navigateBack$1
,
navigateTo
:
navigateTo$1
,
reLaunch
:
reLaunch$1
,
redirectTo
:
redirectTo$1
,
switchTab
:
switchTab$1
});
var
api$1
=
Object
.
assign
(
Object
.
create
(
null
),
api
,
platformApi
);
var
platformApi
=
Object
.
assign
(
Object
.
create
(
null
),
appApi
,
nvueApi
);
var
api$2
=
Object
.
assign
(
Object
.
create
(
null
),
api$1
,
platformApi
);
const
uni$1
=
Object
.
create
(
null
);
apis_1
.
forEach
(
name
=>
{
if
(
api$
1
[
name
])
{
uni$1
[
name
]
=
promisify
(
name
,
wrapper
(
name
,
api$
1
[
name
]));
if
(
api$
2
[
name
])
{
uni$1
[
name
]
=
promisify
(
name
,
wrapper
(
name
,
api$
2
[
name
]));
}
else
{
uni$1
[
name
]
=
wrapperUnimplemented
(
name
);
}
...
...
packages/uni-h5/dist/index.umd.min.js
浏览文件 @
0a23d711
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
packages/uni-h5/manifest.json
浏览文件 @
0a23d711
...
...
@@ -406,6 +406,22 @@
"/platforms/h5/service/api/device/vibrate.js"
,
[]
],
"onBluetoothDeviceFound"
:
[
"/core/service/api/device/bluetooth.js"
,
[]
],
"onBluetoothAdapterStateChange"
:
[
"/core/service/api/device/bluetooth.js"
,
[]
],
"onBLEConnectionStateChange"
:
[
"/core/service/api/device/bluetooth.js"
,
[]
],
"onBLECharacteristicValueChange"
:
[
"/core/service/api/device/bluetooth.js"
,
[]
],
"hideKeyboard"
:
[
"/platforms/h5/service/api/device/hide-keyboard.js"
,
[]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录