提交 0a33ce6d 编写于 作者: Q qiang

feat: App端增加方法 uni.onTabBarMidButtonTap

上级 057fb9c2
...@@ -115,7 +115,7 @@ const device = [ ...@@ -115,7 +115,7 @@ const device = [
] ]
const keyboard = [ const keyboard = [
'hideKeyboard', 'hideKeyboard',
'onKeyboardHeightChange' 'onKeyboardHeightChange'
] ]
...@@ -138,6 +138,7 @@ const ui = [ ...@@ -138,6 +138,7 @@ const ui = [
'removeTabBarBadge', 'removeTabBarBadge',
'showTabBarRedDot', 'showTabBarRedDot',
'hideTabBarRedDot', 'hideTabBarRedDot',
'onTabBarMidButtonTap',
'setBackgroundColor', 'setBackgroundColor',
'setBackgroundTextStyle', 'setBackgroundTextStyle',
'createAnimation', 'createAnimation',
...@@ -209,4 +210,4 @@ const apis = [ ...@@ -209,4 +210,4 @@ const apis = [
...third ...third
] ]
module.exports = apis module.exports = apis
import { import {
isFn isFn
} from 'uni-shared' } from 'uni-shared'
const todoApis = Object.create(null) const todoApis = Object.create(null)
const TODOS = [ const TODOS = [
'onTabBarMidButtonTap',
'subscribePush', 'subscribePush',
'unsubscribePush', 'unsubscribePush',
'onPush', 'onPush',
...@@ -29,4 +30,4 @@ TODOS.forEach(function (name) { ...@@ -29,4 +30,4 @@ TODOS.forEach(function (name) {
todoApis[name] = createTodoApi(name) todoApis[name] = createTodoApi(name)
}) })
export default todoApis export default todoApis
import { import {
onMethod,
invokeMethod invokeMethod
} from '../../platform' } from '../../platform'
import {
invoke
} from 'uni-core/service/bridge'
export function removeTabBarBadge ({ export function removeTabBarBadge ({
index index
}) { }) {
...@@ -20,4 +25,16 @@ export function showTabBarRedDot ({ ...@@ -20,4 +25,16 @@ export function showTabBarRedDot ({
}) })
} }
export const hideTabBarRedDot = removeTabBarBadge export const hideTabBarRedDot = removeTabBarBadge
const callbacks = []
onMethod('onTabBarMidButtonTap', res => {
callbacks.forEach(callbackId => {
invoke(callbackId, res)
})
})
export function onTabBarMidButtonTap (callbackId) {
callbacks.push(callbackId)
}
...@@ -3,6 +3,7 @@ import { ...@@ -3,6 +3,7 @@ import {
} from '../api/util' } from '../api/util'
import { import {
publish,
requireNativePlugin requireNativePlugin
} from '../bridge' } from '../bridge'
...@@ -102,6 +103,9 @@ export default { ...@@ -102,6 +103,9 @@ export default {
tabBar && tabBar.onClick(({ index }) => { tabBar && tabBar.onClick(({ index }) => {
clickCallback(config.list[index], index, true) clickCallback(config.list[index], index, true)
}) })
tabBar && tabBar.onMidButtonClick(() => {
publish('onTabBarMidButtonTap', {})
})
}, },
switchTab (page) { switchTab (page) {
const itemLength = config.list.length const itemLength = config.list.length
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册