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

merge dev

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