NativeApis.js
1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
export const NativeMethodNames = {
AppInfoApi: 'nativeAppInfo',
AppShare: 'nativeAppShare',
AppBottomMenu: 'nativeMenu'
}
export const JsMethodNames = {
PayResult: 'payResult'
}
export const JsInterfaces = objVal2Array(JsMethodNames)
export const NativeMenuApi = {
nativeMenuStatus: (isShow) => {
const param = isShow && { type: '1' } || { type: '2' }
return $api.call(NativeMethodNames.AppBottomMenu, param, false)
},
nativeChangeMenu: (param) => {
const newParam = { ...param, type: '3' }
return $api.call(NativeMethodNames.AppBottomMenu, newParam, false)
}
}
export const NativeApi = {
on: (jsMethodName, callback) => {
$api.on(jsMethodName, callback)
},
call: (nativeMethodName, param, isBack) => {
return $api.call(nativeMethodName, param, isBack)
},
nativeAppInfo: (param) => {
return $api.call(NativeMethodNames.AppInfoApi, param, true)
},
nativeAppShare: (param) => {
return $api.call(NativeMethodNames.AppShare, param, true)
}
}
function objVal2Array (obj) {
const arrays = []
for (const key in obj) {
arrays.push(obj[key])
}
return arrays
}