'f'
mh-two-thousand-and-two
2024-04-12 26f2711ef9461961fb953e2b497bd314ef95e345
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
import api from 'uni-invoke-api'
 
/**
 * 执行内部平台方法
 */
export function invokeMethod (name, ...args) {
  return api[name].apply(null, args)
}
/**
 * 监听 service 层内部平台方法回调,与 publish 对应
 * @param {Object} name
 * @param {Object} callback
 */
export function onMethod (name, callback) {
  return UniServiceJSBridge.on('api.' + name, callback)
}
 
export function getCurrentPageVm (method) {
  const pages = getCurrentPages()
  const len = pages.length
  if (!len) {
    UniServiceJSBridge.emit('onError', `${method}:fail`)
  }
  const page = pages[len - 1]
  return page.$vm
}
 
export function getCurrentPageId () {
  const pages = getCurrentPages()
  const page = pages[pages.length - 1]
  return page && page.$page.id
}