提交 ab082993 编写于 作者: fxy060608's avatar fxy060608

merge dev

上级 dd3f9793
......@@ -48,14 +48,16 @@ export default {
return $event
}
Vue.prototype.$getComponentDescriptor = function (vm, owner = false) {
return createComponentDescriptor(vm || this, owner)
Vue.prototype.$getComponentDescriptor = function (vm) {
return createComponentDescriptor(vm || this)
}
Vue.prototype.$handleWxsEvent = function ($event) {
if ($event instanceof Event) { // 未处理的 event 对象 需要对 target 校正及包装
const currentTarget = $event.currentTarget
const instance = currentTarget && currentTarget.__vue__ && currentTarget.__vue__.$getComponentDescriptor()
const instance = currentTarget &&
currentTarget.__vue__ &&
currentTarget.__vue__.$getComponentDescriptor()
$event = processEvent.call(this, $event.type, $event, {}, findUniTarget($event, this.$el) || $event.target,
$event.currentTarget)
$event.instance = instance
......@@ -78,13 +80,12 @@ export default {
initBehaviors(options, this)
}
if (__PLATFORM__ === 'h5') {
if (isPage(this)) {
options.mounted = options.mounted ? [].concat(pageMounted, options.mounted) : [pageMounted]
}
if (isPage(this)) {
options.mounted = options.mounted ? [].concat(pageMounted, options.mounted) : [pageMounted]
}
}
})
// TODO 跨平台时,View 层需要注入$page属性
}
}
......@@ -2,4 +2,6 @@ export * from './context/live-pusher'
export * from './context/map'
export * from './context/video'
export * from './plugin/require-native-plugin'
export * from './ui/create-selector-query'
export * from './plugin/require-native-plugin'
......@@ -7,7 +7,8 @@ import {
} from './util'
import {
setStatusBarStyle
setStatusBarStyle,
invoke
} from '../../bridge'
import {
......@@ -23,11 +24,12 @@ function _navigateTo ({
query,
animationType,
animationDuration
}) {
}, callbackId) {
UniServiceJSBridge.emit('onAppRoute', {
type: 'navigateTo',
path
})
})
showWebview(
registerPage({
path,
......@@ -35,7 +37,12 @@ function _navigateTo ({
openType: 'navigate'
}),
animationType,
animationDuration
animationDuration,
() => {
invoke(callbackId, {
errMsg: 'navigateTo:ok'
})
}
)
setStatusBarStyle()
}
......
......@@ -5,7 +5,8 @@ import {
} from './util'
import {
setStatusBarStyle
setStatusBarStyle,
invoke
} from '../../bridge'
import {
......@@ -21,7 +22,7 @@ import tabBar from '../../../../app-plus/service/framework/tab-bar'
function _switchTab ({
path,
from
}) {
}, callbackId) {
tabBar.switchTab(path.slice(1))
const pages = getCurrentPages()
......@@ -37,11 +38,14 @@ function _switchTab ({
}
})
currentPage.$remove()
if (currentPage.$page.openType === 'redirect') {
currentPage.$getAppWebview().close(ANI_CLOSE, ANI_DURATION)
} else {
currentPage.$getAppWebview().close('auto')
}
// 延迟执行避免iOS应用退出
setTimeout(() => {
if (currentPage.$page.openType === 'redirect') {
currentPage.$getAppWebview().close(ANI_CLOSE, ANI_DURATION)
} else {
currentPage.$getAppWebview().close('auto')
}
}, 100)
} else {
// 前一个 tabBar 触发 onHide
currentPage.$vm.__call_hook('onHide')
......@@ -65,17 +69,23 @@ function _switchTab ({
tabBarPage.$vm.__call_hook('onShow')
tabBarPage.$getAppWebview().show('none')
} else {
showWebview(
registerPage({
path,
query: {},
openType: 'switchTab'
return showWebview(registerPage({
path,
query: {},
openType: 'switchTab'
}), 'none', 0, () => {
invoke(callbackId, {
errMsg: 'switchTab:ok'
})
)
}, 70)
}
setStatusBarStyle()
}
return {
errMsg: 'switchTab:ok'
}
}
export function switchTab ({
url,
from
......
......@@ -6,7 +6,7 @@ export const ANI_DURATION = 300
const ANI_SHOW = 'pop-in'
export const ANI_CLOSE = 'pop-out'
export function showWebview (webview, animationType, animationDuration, showCallback) {
export function showWebview (webview, animationType, animationDuration, showCallback, delay = 50) {
animationDuration = typeof animationDuration === 'undefined' ? ANI_DURATION : parseInt(animationDuration)
setTimeout(() => {
webview.show(
......@@ -17,5 +17,5 @@ export function showWebview (webview, animationType, animationDuration, showCall
navigateStack(webview)
}
)
}, 50)
}, delay)
}
export const ANI_SHOW = 'pop-in'
export const ANI_DURATION = 300
export const TABBAR_HEIGHT = 56
export const TITLEBAR_HEIGHT = 44
export const VIEW_WEBVIEW_PATH = '__uniappview.html'
export const TITLEBAR_HEIGHT = 44
export const VIEW_WEBVIEW_PATH = '__uniappview.html'
......@@ -13,7 +13,6 @@ import {
} from './page'
import {
registerPlusMessage,
consumePlusMessage
} from './plus-message'
......@@ -105,26 +104,20 @@ function initTabBar () {
__uniConfig.__ready__ = true
const onLaunchWebviewReady = function onLaunchWebviewReady () {
const tabBarView = tabBar.init(__uniConfig.tabBar, (item, index) => {
UniServiceJSBridge.emit('onTabItemTap', {
index,
text: item.text,
pagePath: item.pagePath
})
uni.switchTab({
url: '/' + item.pagePath,
openType: 'switchTab',
from: 'tabbar'
})
tabBar.init(__uniConfig.tabBar, (item, index) => {
uni.switchTab({
url: '/' + item.pagePath,
openType: 'switchTab',
from: 'tabBar',
success () {
UniServiceJSBridge.emit('onTabItemTap', {
index,
text: item.text,
pagePath: item.pagePath
})
}
})
tabBarView && plus.webview.getLaunchWebview().append(tabBarView)
}
if (plus.webview.getLaunchWebview()) {
onLaunchWebviewReady()
} else {
registerPlusMessage('UniWebviewReady-' + plus.runtime.appid, onLaunchWebviewReady, false)
}
})
}
export function registerApp (appVm) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册