完善原生内容卡与H5详情分工
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
import { type H5BridgeMessage, type H5ExperienceRequest } from '../../game/experience/h5Experience'
|
||||
|
||||
type ExperienceWebViewPageData = {
|
||||
pageTitle: string
|
||||
pageSubtitle: string
|
||||
presentation: 'sheet' | 'dialog' | 'fullscreen'
|
||||
webViewSrc: string
|
||||
webViewReady: boolean
|
||||
loadErrorText: string
|
||||
panelBodyHeightPx: number
|
||||
}
|
||||
|
||||
let currentRequest: H5ExperienceRequest | null = null
|
||||
@@ -47,19 +51,29 @@ function emitCloseAndBack(payload?: Record<string, unknown>) {
|
||||
|
||||
Page<ExperienceWebViewPageData, WechatMiniprogram.IAnyObject>({
|
||||
data: {
|
||||
pageTitle: '内容体验',
|
||||
pageSubtitle: '',
|
||||
presentation: 'sheet',
|
||||
webViewSrc: '',
|
||||
webViewReady: false,
|
||||
loadErrorText: '',
|
||||
panelBodyHeightPx: 420,
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
const systemInfo = wx.getSystemInfoSync()
|
||||
const windowHeight = typeof systemInfo.windowHeight === 'number' ? systemInfo.windowHeight : 700
|
||||
pageResolved = false
|
||||
currentRequest = null
|
||||
currentEventChannel = null
|
||||
this.setData({
|
||||
pageTitle: '内容体验',
|
||||
pageSubtitle: '',
|
||||
presentation: 'sheet',
|
||||
webViewSrc: '',
|
||||
webViewReady: false,
|
||||
loadErrorText: '',
|
||||
panelBodyHeightPx: Math.max(420, Math.floor(windowHeight * 0.62)),
|
||||
})
|
||||
|
||||
try {
|
||||
@@ -74,14 +88,21 @@ Page<ExperienceWebViewPageData, WechatMiniprogram.IAnyObject>({
|
||||
|
||||
currentEventChannel.on('init', (request: H5ExperienceRequest) => {
|
||||
currentRequest = request
|
||||
wx.setNavigationBarTitle({
|
||||
title: request.title || '内容体验',
|
||||
fail: () => {},
|
||||
})
|
||||
const presentation = request.presentation || 'sheet'
|
||||
const panelHeightPx = presentation === 'dialog'
|
||||
? Math.max(420, Math.floor(windowHeight * 0.7))
|
||||
: presentation === 'fullscreen'
|
||||
? Math.max(520, windowHeight - 24)
|
||||
: Math.max(420, Math.floor(windowHeight * 0.72))
|
||||
const headerHeightPx = presentation === 'fullscreen' ? 84 : 76
|
||||
this.setData({
|
||||
pageTitle: request.title || '内容体验',
|
||||
pageSubtitle: request.subtitle || '',
|
||||
presentation,
|
||||
webViewSrc: buildWebViewSrc(request),
|
||||
webViewReady: true,
|
||||
loadErrorText: '',
|
||||
panelBodyHeightPx: Math.max(240, panelHeightPx - headerHeightPx),
|
||||
})
|
||||
})
|
||||
},
|
||||
@@ -133,4 +154,8 @@ Page<ExperienceWebViewPageData, WechatMiniprogram.IAnyObject>({
|
||||
})
|
||||
emitFallbackAndClose()
|
||||
},
|
||||
|
||||
handleCloseTap() {
|
||||
emitCloseAndBack({})
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user