Commit 0e7aaa95 by 李伟康

chore: 升级版本至2.26.7,修复离线素材问题并优化缓存

- 更新manifest.json版本号从2.26.6到2.26.7
- 为完成接待弹框新增关闭事件回调与可见状态管理
- 移除权益详情页冗余的sourceOnline状态,简化素材加载逻辑
- 优化素材图片缓存工具,避免重复下载并完善错误处理机制
- 新增弹框展示时延迟页面刷新,关闭后自动补刷的逻辑
1 parent 1871c760
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
ref="formRef" ref="formRef"
@cancel="cancel" @cancel="cancel"
@confirm="submit" @confirm="submit"
@close="handleClose"
:cancelBtnText="`${step == 1 ? '取消' : '上一步'}`" :cancelBtnText="`${step == 1 ? '取消' : '上一步'}`"
:confirmBtnText="`${sceneType == 0 ? (step == 1 ? '下一步' : '完成接待') : '完成接待'}`" :confirmBtnText="`${sceneType == 0 ? (step == 1 ? '下一步' : '完成接待') : '完成接待'}`"
:title="`${step == 1 ? '客户信息完善' : '结果反馈'}`" :title="`${step == 1 ? '客户信息完善' : '结果反馈'}`"
...@@ -160,6 +161,8 @@ export default { ...@@ -160,6 +161,8 @@ export default {
data () { data () {
return { return {
step: 1, step: 1,
// 完成接待弹框是否处于打开状态,供外层决定是否需要延时刷新。
visible: false,
formObject: [ formObject: [
{ {
label: "车主姓名", label: "车主姓名",
...@@ -277,6 +280,11 @@ export default { ...@@ -277,6 +280,11 @@ export default {
this.receptionStatus = -1 this.receptionStatus = -1
this.$refs.formRef.close() this.$refs.formRef.close()
}, },
// 弹框实际关闭(取消、右上角关闭或提交后收起)时同步状态并通知外层。
handleClose () {
this.visible = false
this.$emit('close')
},
check (all = false) { check (all = false) {
let flag = true let flag = true
try { try {
...@@ -362,6 +370,7 @@ export default { ...@@ -362,6 +370,7 @@ export default {
} }
this.step = step this.step = step
this.$refs.formRef.open() this.$refs.formRef.open()
this.visible = true
this.updateViewKey = Date.now() this.updateViewKey = Date.now()
}) })
}, },
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
"name" : "展业助手", "name" : "展业助手",
"appid" : "__UNI__D3BD3DF", "appid" : "__UNI__D3BD3DF",
"description" : "", "description" : "",
"versionName" : "2.26.6", "versionName" : "2.26.7",
"versionCode" : 2266, "versionCode" : 2267,
"transformPx" : false, "transformPx" : false,
"sassImplementationName" : "node-sass", "sassImplementationName" : "node-sass",
/* 5+App特有相关 */ /* 5+App特有相关 */
......
...@@ -97,6 +97,7 @@ ...@@ -97,6 +97,7 @@
<finish-step <finish-step
ref="stepRef" ref="stepRef"
@submit="done" @submit="done"
@close="handleFinishStepClose"
:titleTips="finishTips" :titleTips="finishTips"
/> />
<informationEntry <informationEntry
...@@ -178,7 +179,6 @@ export default { ...@@ -178,7 +179,6 @@ export default {
loadedIndexes: [], loadedIndexes: [],
longImagePopupVisible: false, longImagePopupVisible: false,
brandPopupVisible: false, brandPopupVisible: false,
sourceOnline: true,
offlineReadyId: '' offlineReadyId: ''
} }
}, },
...@@ -250,7 +250,7 @@ export default { ...@@ -250,7 +250,7 @@ export default {
return this.renderList[this.currentIndex] || {} return this.renderList[this.currentIndex] || {}
}, },
longImageUrl () { longImageUrl () {
if (!this.sourceOnline && String(this.offlineReadyId) !== String(this.id)) return '' if (String(this.offlineReadyId) !== String(this.id)) return ''
const item = this.currentMaterial || {} const item = this.currentMaterial || {}
const matched = this.getMatchedMaterialDetail(item) const matched = this.getMatchedMaterialDetail(item)
...@@ -348,7 +348,7 @@ export default { ...@@ -348,7 +348,7 @@ export default {
this.offlineReadyId = '' this.offlineReadyId = ''
} }
if (!this.pageToolList.length) this.pageToolList = this.toolList if (!this.pageToolList.length) this.pageToolList = this.toolList
if (newval && !this.sourceOnline && this._offlineSource) return this.loadOfflineMaterial(newval) if (newval && this._offlineSource) return this.loadOfflineMaterial(newval)
if (newval && oldval !== undefined && !oldval) return this.setPageData() if (newval && oldval !== undefined && !oldval) return this.setPageData()
} }
}, },
...@@ -406,10 +406,18 @@ export default { ...@@ -406,10 +406,18 @@ export default {
this.showPayPage = false this.showPayPage = false
this.closeLongImagePopup() this.closeLongImagePopup()
this.$refs.toolRef.hide() this.$refs.toolRef.hide()
// 提交完成接待后页面即将重置,不再补做被延后的刷新。
this._pendingPageData = false
this.$refs.stepRef.close() this.$refs.stepRef.close()
this.receptionTrackLeave() this.receptionTrackLeave()
this.$emit('done', e) this.$emit('done', e)
}, },
// 用户关闭完成接待弹框后,补一次弹框期间被延后的素材刷新。
handleFinishStepClose () {
if (!this._pendingPageData) return
this._pendingPageData = false
this.setPageData()
},
/**切换素材 */ /**切换素材 */
choose (e) { choose (e) {
this.closeLongImagePopup() this.closeLongImagePopup()
...@@ -584,6 +592,11 @@ export default { ...@@ -584,6 +592,11 @@ export default {
// }, // },
async setPageData (networkStatus) { async setPageData (networkStatus) {
// 完成接待弹框打开期间不刷新素材,避免弹框上下文被重渲染打断;关闭后再补一次。
if (this.$refs.stepRef?.visible) {
this._pendingPageData = true
return
}
const startedAt = Date.now() const startedAt = Date.now()
const previousSource = this._offlineSource const previousSource = this._offlineSource
this._offlineSource = null this._offlineSource = null
...@@ -601,7 +614,6 @@ export default { ...@@ -601,7 +614,6 @@ export default {
const online = typeof networkStatus === 'boolean' ? networkStatus : await materialCache.getNetworkStatus() const online = typeof networkStatus === 'boolean' ? networkStatus : await materialCache.getNetworkStatus()
if (!isCurrent()) return if (!isCurrent()) return
const networkMs = Date.now() - startedAt const networkMs = Date.now() - startedAt
this.sourceOnline = online
const storageName = materialCache.getSourceKey(shopMerchantId, sceneType, params) const storageName = materialCache.getSourceKey(shopMerchantId, sceneType, params)
let resolvedKey = storageName let resolvedKey = storageName
// 同品牌切车系复用轻量基础配置,图片仍按本次素材 ID / 车系的 key 查找。 // 同品牌切车系复用轻量基础配置,图片仍按本次素材 ID / 车系的 key 查找。
...@@ -622,9 +634,9 @@ export default { ...@@ -622,9 +634,9 @@ export default {
// 保留诊断信息,避免离线时将整包 base64 输出到控制台。 // 保留诊断信息,避免离线时将整包 base64 输出到控制台。
console.log('setPageData cache', { id: data.id, modules: data.moduleList.length, tools: data.toolList.length, online, networkMs, baseMs: Date.now() - startedAt - networkMs, reused: !!reuseBase }) console.log('setPageData cache', { id: data.id, modules: data.moduleList.length, tools: data.toolList.length, online, networkMs, baseMs: Date.now() - startedAt - networkMs, reused: !!reuseBase })
const target = this.getSourceTarget(data) const target = this.getSourceTarget(data)
if (!online) this._offlineSource = { key: resolvedKey, requestedKey: storageName, base: data, carKey, requestId } this._offlineSource = { key: resolvedKey, requestedKey: storageName, base: data, carKey, requestId, online }
this.setViewInfo(data) // 先从缓存中获取数据 this.setViewInfo(data) // 先从缓存中获取数据
if (!online && target) await this.loadOfflineMaterial(target.id) if (target) await this.loadOfflineMaterial(target.id)
} else { } else {
this.useCarConfig = false this.useCarConfig = false
this.moduleList = [] this.moduleList = []
...@@ -633,8 +645,13 @@ export default { ...@@ -633,8 +645,13 @@ export default {
} }
if (!online) return if (!online) return
try { try {
let requestData = await uni.$api.systemApi.getSoureData(shopMerchantId, sceneType, params) const requestData = await uni.$api.systemApi.getSoureData(shopMerchantId, sceneType, params)
if (isCurrent() && requestData) this.setViewInfo(requestData) if (!isCurrent() || !requestData) return
// 接口返回不走原始 URL,改为和缓存一致:以接口数据为源补齐 base64 后再渲染。
this._offlineSource = { key: storageName, requestedKey: storageName, base: requestData, carKey, requestId, online: true }
const target = this.getSourceTarget(requestData)
this.setViewInfo(requestData)
if (target) await this.loadOfflineMaterial(target.id)
} catch (error) { } catch (error) {
// 保留已展示的缓存;过期请求不能修改当前车型。 // 保留已展示的缓存;过期请求不能修改当前车型。
} }
...@@ -648,13 +665,15 @@ export default { ...@@ -648,13 +665,15 @@ export default {
}, },
async loadOfflineMaterial (materialId = this.id) { async loadOfflineMaterial (materialId = this.id) {
const source = this._offlineSource const source = this._offlineSource
if (!source || this.sourceOnline || !this.id) return if (!source || !this.id) return
const imageRequestId = this._offlineImageRequestId = (this._offlineImageRequestId || 0) + 1 const imageRequestId = this._offlineImageRequestId = (this._offlineImageRequestId || 0) + 1
const isCurrent = () => this._offlineSource === source && !this.sourceOnline && !!this.id && const isCurrent = () => this._offlineSource === source && !!this.id &&
!this._sourceDisposed && source.requestId === this._sourceRequestId && imageRequestId === this._offlineImageRequestId !this._sourceDisposed && source.requestId === this._sourceRequestId && imageRequestId === this._offlineImageRequestId
this.offlineReadyId = '' this.offlineReadyId = ''
const display = await materialCache.hydrateSourceImages(source.key, source.base, { const display = await materialCache.hydrateSourceImages(source.key, source.base, {
moduleIds: [materialId], toolIds: [materialId], carKey: source.carKey, isCurrent, moduleIds: [materialId], toolIds: [materialId], carKey: source.carKey, isCurrent,
// 在线时缺失的图片按需补齐,避免渲染出原始 URL。
allowDownload: source.online !== false,
onMetrics: metrics => { if (isCurrent()) console.log('setPageData images', { materialId, carKey: source.carKey, ...metrics }) } onMetrics: metrics => { if (isCurrent()) console.log('setPageData images', { materialId, carKey: source.carKey, ...metrics }) }
}) })
if (!isCurrent() || !display) return if (!isCurrent() || !display) return
...@@ -673,11 +692,12 @@ export default { ...@@ -673,11 +692,12 @@ export default {
}, },
async loadOfflineTools (visible) { async loadOfflineTools (visible) {
const source = this._offlineSource const source = this._offlineSource
if (!visible || !source || this.sourceOnline || !this.id) return if (!visible || !source || !this.id) return
const isCurrent = () => this._offlineSource === source && !this.sourceOnline && !!this.id && const isCurrent = () => this._offlineSource === source && !!this.id &&
!this._sourceDisposed && source.requestId === this._sourceRequestId && this.$refs.toolRef?.show === false !this._sourceDisposed && source.requestId === this._sourceRequestId && this.$refs.toolRef?.show === false
const display = await materialCache.hydrateSourceImages(source.key, source.base, { const display = await materialCache.hydrateSourceImages(source.key, source.base, {
moduleIds: [], toolIds: source.base.toolList.map(item => item.id), carKey: source.carKey, isCurrent moduleIds: [], toolIds: source.base.toolList.map(item => item.id), carKey: source.carKey, isCurrent,
allowDownload: source.online !== false
}) })
if (display && isCurrent()) this.applyOfflineTools(display.toolList) if (display && isCurrent()) this.applyOfflineTools(display.toolList)
}, },
...@@ -689,7 +709,8 @@ export default { ...@@ -689,7 +709,8 @@ export default {
this.receptionTrackLeave() this.receptionTrackLeave()
// 使用 Object.freeze 冻结大对象,提升性能 // 使用 Object.freeze 冻结大对象,提升性能
this.moduleList = Object.freeze(moduleList) this.moduleList = Object.freeze(moduleList)
this.pageToolList = Object.freeze(this.sourceOnline ? toolList : toolList.map(item => ({ // 统一走 base64:工具图标先置空,等 hydrate 补齐后再展示,避免直接消耗在线地址。
this.pageToolList = Object.freeze(toolList.map(item => ({
...item, shortTitleUrl: /^https?:\/\//i.test(item.shortTitleUrl || '') ? '' : item.shortTitleUrl ...item, shortTitleUrl: /^https?:\/\//i.test(item.shortTitleUrl || '') ? '' : item.shortTitleUrl
}))) })))
this.useCarConfig = true this.useCarConfig = true
...@@ -718,17 +739,13 @@ export default { ...@@ -718,17 +739,13 @@ export default {
// 即使 loadedIndexes 里有,如果距离太远,也要销毁内容以释放内存 // 即使 loadedIndexes 里有,如果距离太远,也要销毁内容以释放内存
shouldRenderContent(index) { shouldRenderContent(index) {
const current = this.currentIndex const current = this.currentIndex
// 配置素材统一走 base64:只挂载已按 key 补齐的当前素材,其他素材被选中时再读取。
if (this.useCarConfig) return index === current && String(this.offlineReadyId) === String(this.id)
// 配置未就绪时展示的是兜底素材列表,不依赖图片缓存,保留当前页及其左右邻居。
const len = this.renderList.length const len = this.renderList.length
// 离线仅挂载已按 key 补齐的当前素材,其他素材被选中时再读取。
if (!this.sourceOnline) return index === current && String(this.offlineReadyId) === String(this.id)
// 基础范围:当前页的前后一页
if (Math.abs(index - current) <= 1) return true if (Math.abs(index - current) <= 1) return true
// 循环边界处理
if (current === 0 && index === len - 1) return true if (current === 0 && index === len - 1) return true
if (current === len - 1 && index === 0) return true if (current === len - 1 && index === 0) return true
return false return false
}, },
// 判断组件是否应该实际渲染(配合 v-if) // 判断组件是否应该实际渲染(配合 v-if)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!