Commit f97509f9 by 岑成威

fix: 长图

1 parent 4e5f4a3b
......@@ -135,109 +135,17 @@ const getImageVersion = async () => {
/**获取素材配置 */
const getSoureData = async (shopMerchantId, sceneType, params = {}) => {
try {
uni.$logger?.local?.info?.(`[systemApi/getSoureData] start, shopMerchantId=${shopMerchantId}, sceneType=${sceneType}`)
const res = await getEquityMaterialId({
merchantId: shopMerchantId,
...params
})
uni.$logger?.local?.info?.(`[systemApi/getSoureData] getEquityMaterialId done, id=${res?.id || ''}`)
if (res && res.id) {
console.log(res.id, 'res.idres.idres.idres.id')
let data = await getEquityMaterialConfig({
id: res.id
})
if (data) {
// detail 接口原始返回(可读写关键字段;图片 URL 过长会截断)
const detailRawForLog = {
id: data.id,
topKeys: Object.keys(data || {}),
toolListLength: data.toolList?.length || 0,
materialInfoList: (data.materialInfoList || []).map(item => {
const copy = { ...item }
;['thumbnail', 'shortTitleUrl', 'productPoster'].forEach(k => {
if (typeof copy[k] === 'string' && copy[k].length > 120) {
copy[k] = `${copy[k].slice(0, 80)}...(len=${copy[k].length})`
}
})
if (Array.isArray(copy.receptionSourceDetailList)) {
copy.receptionSourceDetailList = copy.receptionSourceDetailList.map(d => {
const detail = { ...d }
Object.keys(detail).forEach(k => {
if (typeof detail[k] === 'string' && detail[k].length > 120) {
detail[k] = `${detail[k].slice(0, 80)}...(len=${detail[k].length})`
}
})
return detail
})
}
if (Array.isArray(copy.screenList)) {
copy.screenList = copy.screenList.map(s => {
const screen = { ...s }
Object.keys(screen).forEach(k => {
if (typeof screen[k] === 'string' && screen[k].length > 120) {
screen[k] = `${screen[k].slice(0, 80)}...(len=${screen[k].length})`
}
})
return screen
})
}
return copy
})
}
console.log(
'[detail接口] dj.api.car.boutique.reception.home.page.entrance.material.detail 原始返回:',
JSON.stringify(detailRawForLog, null, 2)
)
console.log('[getSoureData] getEquityMaterialConfig response:', data)
let { toolList, materialInfoList } = data,
storageName = `source_${sceneType}_${shopMerchantId}`
console.log('[getSoureData] materialInfoList:', materialInfoList)
if (materialInfoList?.[0]) {
const first = materialInfoList[0]
console.log('[getSoureData] first item keys:', Object.keys(first))
console.log('[getSoureData] first item long-related:', {
longImage: first.longImage,
isLongImage: first.isLongImage,
is_long_image: first.is_long_image,
imageWidth: first.imageWidth,
imageHeight: first.imageHeight,
image_width: first.image_width,
image_height: first.image_height,
materialTitle: first.materialTitle,
materialName: first.materialName,
detailTitle: first.detailTitle,
thumbnailType: typeof first.thumbnail
})
if (Array.isArray(first.receptionSourceDetailList) && first.receptionSourceDetailList[0]) {
console.log(
'[getSoureData] first receptionSourceDetailList[0] keys:',
Object.keys(first.receptionSourceDetailList[0])
)
console.log(
'[getSoureData] first receptionSourceDetailList[0] long-related:',
{
longImage: first.receptionSourceDetailList[0].longImage,
isLongImage: first.receptionSourceDetailList[0].isLongImage,
imageWidth: first.receptionSourceDetailList[0].imageWidth,
imageHeight: first.receptionSourceDetailList[0].imageHeight
}
)
}
}
console.log(
'[getSoureData] longImage flags:',
(materialInfoList || []).map(i => ({
id: i.id,
detailTitle: i.detailTitle || i.materialTitle || i.materialName,
longImage: i.longImage,
isLongImage: i.isLongImage,
imageWidth: i.imageWidth,
imageHeight: i.imageHeight,
hasOwnLongImage: Object.prototype.hasOwnProperty.call(i, 'longImage'),
hasOwnIsLongImage: Object.prototype.hasOwnProperty.call(i, 'isLongImage')
}))
)
uni.$logger?.local?.info?.(`[systemApi/getSoureData] materialInfoList length=${materialInfoList?.length || 0}`)
if (params.brandId && params.subBrandId) storageName += `_${params.brandId}_${params.subBrandId}`
let insurance = materialInfoList.find(e => e.componentName == 'insurance'),
hasEquity = toolList.find(e => e.id == insurance.id)
......@@ -275,8 +183,6 @@ const getSoureData = async (shopMerchantId, sceneType, params = {}) => {
}
data.toolList = await imgTransformBase64(toolList, ['shortTitleUrl'])
data.moduleList = await imgTransformBase64(materialInfoList, ['thumbnail', 'receptionSourceDetailList', 'screenList'])
console.log('[getSoureData] moduleList(after transform):', data.moduleList)
uni.$logger?.local?.info?.(`[systemApi/getSoureData] moduleList length=${data.moduleList?.length || 0}`)
uni.setStorageSync(storageName, {
moduleList: data.moduleList,
toolList: data.toolList,
......
......@@ -132,6 +132,8 @@ export default {
index = 0
if (clickFlga) return
this.clickFlga = true
// 进入车系选择过程中保持弹层打开态,避免「查看长图」按钮冒出来
this.$store.dispatch('setCarBrandOpenStatus', true)
this.selectItem = {
carBrand: e.brandName,
carBrandId: e.brandId,
......@@ -166,7 +168,10 @@ export default {
if (index < 0) index = 0
this.handleSelect(res[index])
}
else this.$refs.carBoxVisible.open()
else {
this.$store.dispatch('setCarBrandOpenStatus', true)
this.$refs.carBoxVisible.open()
}
}
this.clickFlga = false
}).catch(err => {
......@@ -197,6 +202,8 @@ export default {
this.$store.dispatch('setCurrentCarInfo', selectItem)
}
this.$refs.carBoxVisible?.close();
this.$refs.carBrandListVisible?.close();
this.carBrandListOff = false
this.$store.dispatch('setCarBrandOpenStatus', false)
this.$emit('select', {
...item,
......@@ -211,10 +218,16 @@ export default {
},
closeCarBoxVisible() {
if (this.carBrandListOff) return
else this.$emit('close')
// 关车系弹窗:若还要从品牌列表回来,保持打开态;否则关闭
if (this.carBrandListOff) {
this.$store.dispatch('setCarBrandOpenStatus', true)
return
}
this.$store.dispatch('setCarBrandOpenStatus', false)
this.$emit('close')
},
clickClose() {
this.carBrandListOff = false
this.$store.dispatch('setCarBrandOpenStatus', false)
this.$emit('close')
},
......
const target = ['ip', 'dev', 'uat', 'prod', 'beta']
const index = 1
const index = 2
/**
*
0本地
......
......@@ -6,6 +6,7 @@
:drawStatus="penSwitch"
custom
@scale="$emit('scale',$event)"
ref="canvasRef"
>
<template slot="customContent">
<view class="layout-content">
......@@ -64,10 +65,6 @@
class="content-image"
:src="contentUrl()"
/>
<!-- <image
class="content-bg"
:src="receptionBg()"
/> -->
</view>
</view>
</template>
......@@ -75,7 +72,7 @@
<car-brands
ref="carBrandListVisible"
@select="handleSelect($event,'carBrandListVisible')"
@close="resetFocusIndex"
@close="onBrandClose"
/>
</view>
</template>
......@@ -154,6 +151,23 @@ export default {
inputCustomer () {
this.$store.dispatch('setCustomerInfo', this.customerInfo)
},
showPopup (e, index) {
this.focusIndex = index
if (e === 'carBrandListVisible') this.$emit('brandPopupChange', true)
this.$refs[e].open()
},
closeAllPopup () {
this.$refs.carBrandListVisible.close()
this.resetFocusIndex()
this.$emit('brandPopupChange', false)
},
onBrandClose () {
this.resetFocusIndex()
this.$emit('brandPopupChange', false)
},
resetFocusIndex () {
this.focusIndex = -1
},
handleSelect (item, popkey) {
this.$refs[popkey].close()
if (popkey == 'employeeBoxVisible') {
......@@ -165,19 +179,9 @@ export default {
this.customerInfo.carModelId = item.id
}
this.resetFocusIndex()
this.$emit('brandPopupChange', false)
this.$store.dispatch('setCustomerInfo', this.customerInfo)
},
showPopup (e, index) {
this.focusIndex = index
this.$refs[e].open()
},
closeAllPopup () {
this.$refs.carBrandListVisible.close()
this.resetFocusIndex()
},
resetFocusIndex () {
this.focusIndex = -1
},
chooseCustomer (e) {
this.customerInfo = {
...this.customerInfo,
......@@ -232,10 +236,13 @@ export default {
color: #1a1a1a;
}
.content {
position: relative;
width: 100%;
height: 100%;
.form-box {
height: toRpx(80);
padding: 0 toRpx(110);
z-index: 2;
z-index: 3;
position: absolute;
left: toRpx(64);
top: toRpx(168);
......
......@@ -29,7 +29,11 @@
<!-- 极端性能优化:只渲染当前页及其左右邻居的空壳容器,更远的直接移除 DOM -->
<view
v-if="shouldRender(index)"
:class="['view', { showView: id == item.id }, modeName]"
:class="[
'view',
{ showView: id == item.id },
modeName
]"
:key="item.id"
:style="getViewStyle(item.id)"
@touchstart.stop="touchStart"
......@@ -44,7 +48,7 @@
v-if="isComponentLoaded(index) && shouldRenderContent(index)"
@full="handleFull"
:detail="item"
:is="item.componentName"
:is="normalizeComponentName(item.componentName)"
:views="item.receptionSourceDetailList || []"
:penSwitch="penSwitch"
:show="id == item.id"
......@@ -59,6 +63,7 @@
:isByd="isByd"
:hasCarBrand="item.hasCarBrand"
:aitoCarModelIds="aitoCarModelIds"
@brandPopupChange="brandPopupVisible = $event"
/>
</view>
</view>
......@@ -97,7 +102,7 @@
@finish="open"
/>
<view
v-if="showLongImageBtn"
v-if="showLongImageBtn && !longImagePopupVisible && !brandPopupVisible && !carBrandOpenStatus"
class="long-image-btn"
@click.stop="openLongImagePopup"
>
......@@ -113,7 +118,7 @@
</template>
<script>
import ToolBox from '@/components/ToolBox.vue'
import Reception from './components/Reception.vue'
import ReceptionPage from './components/Reception.vue'
import CaseCenter from './components/CaseCenter.vue'
import MediaComponent from './components/MediaComponent.vue'
import History from './components/History.vue'
......@@ -127,7 +132,7 @@ import { receptionTrackMixin } from '@/mixin/index.js'
export default {
components: {
ToolBox,
Reception,
Reception: ReceptionPage,
MediaComponent,
payPop,
CaseCenter,
......@@ -167,8 +172,9 @@ export default {
currentMediaId: '',
touchDiffX: 0,
isTouching: false,
loadedIndexes: [], // 记录已加载组件的索引
longImagePopupVisible: false
loadedIndexes: [],
longImagePopupVisible: false,
brandPopupVisible: false
}
},
computed: {
......@@ -363,19 +369,6 @@ export default {
handleFull (val) {
this.backZindex = val ? 0 : 9
},
/**切换素材 */
choose (e) {
Object.keys(this.$refs).map(refKey => {
let ref = this.$refs[refKey]
if (ref) {
if (Array.isArray(ref)) ref = ref[0]
ref && ref.closeAllPopup && ref.closeAllPopup()
}
})
this.receptionTrackLeave()
this.$emit('update:id', e.id)
uni.$logger.local.info(`预览${e.title}`)
},
back () {
if (this.longImagePopupVisible) {
this.closeLongImagePopup()
......@@ -392,6 +385,21 @@ export default {
this.receptionTrackLeave()
this.$emit('done', e)
},
/**切换素材 */
choose (e) {
this.closeLongImagePopup()
this.brandPopupVisible = false
Object.keys(this.$refs).map(refKey => {
let ref = this.$refs[refKey]
if (ref) {
if (Array.isArray(ref)) ref = ref[0]
ref && ref.closeAllPopup && ref.closeAllPopup()
}
})
this.receptionTrackLeave()
this.$emit('update:id', e.id)
uni.$logger.local.info(`预览${e.title}`)
},
toPay () {
this.$refs.pay.show()
},
......@@ -560,15 +568,9 @@ export default {
let storageName = `source_${sceneType}_${shopMerchantId}_${carBrandId}_${carChildsBrandId}`
let data = uni.getStorageSync(storageName)
try {
uni.$logger?.local?.info?.(`[equity/detail] setPageData start, shopMerchantId=${shopMerchantId}, sceneType=${sceneType}, brandId=${carBrandId}, subBrandId=${carChildsBrandId}`)
let requestData = await uni.$api.systemApi.getSoureData(shopMerchantId, sceneType, params)
uni.$logger?.local?.info?.(`[equity/detail] getSoureData done, hasData=${!!requestData}, moduleListLength=${requestData?.moduleList?.length || 0}`)
console.log('[equity/detail] getSoureData result:', requestData)
console.log('[equity/detail] getSoureData moduleList:', requestData?.moduleList || [])
if (requestData) this.setViewInfo(requestData)
} catch (error) {
uni.$logger?.local?.info?.(`[equity/detail] getSoureData error: ${error}`)
console.log('[equity/detail] getSoureData error:', error)
if (data) this.setViewInfo(data)
}
},
......@@ -670,8 +672,9 @@ export default {
},
openLongImagePopup () {
if (!this.showLongImageBtn) return
// 查看长图时关闭画笔并清空当前页笔迹
this.clearPenBoard()
const item = this.currentMaterial || {}
const matchedDetail = this.getMatchedMaterialDetail(item)
if (item?.id) {
const businessParam = {
materialId: item.id,
......@@ -681,10 +684,36 @@ export default {
uni.$track.add({ eventCode: 'app-longImage-detail', businessParam })
}
this.longImagePopupVisible = true
this.$nextTick(() => this.clearPenBoard())
},
// 接口 componentName 可能是小写 reception,需映射到已注册的 Reception
normalizeComponentName (name) {
if (!name) return name
const key = String(name)
if (key.toLowerCase() === 'reception') return 'Reception'
return key
},
clearPenBoard () {
this.drawStatus = false
let mediaRef = this.$refs['media' + this.id]
if (Array.isArray(mediaRef)) mediaRef = mediaRef[0]
if (!mediaRef) return
// Reception / MediaComponent / ThreeGuarantees 上的画布
let canvasRef =
mediaRef.$refs?.canvasRef ||
mediaRef.$refs?.threeGuarantees ||
mediaRef.$refs?.receptionCanvas
if (Array.isArray(canvasRef)) canvasRef = canvasRef[0]
if (canvasRef?.clearBoard) {
canvasRef.clearBoard()
return
}
// 兼容直接挂在子组件上的 clearBoard
mediaRef.clearBoard?.()
},
closeLongImagePopup () {
const item = this.currentMaterial || {}
if (item?.id) {
if (this.longImagePopupVisible && item?.id) {
const businessParam = {
materialId: item.id,
title: item.title || item.detailTitle || item.materialTitle
......@@ -799,7 +828,7 @@ export default {
left: 50%;
bottom: toRpx(48);
transform: translateX(-50%);
z-index: 20;
z-index: 11;
padding: toRpx(14) toRpx(36);
border-radius: toRpx(32);
font-size: toRpx(28);
......@@ -828,7 +857,7 @@ export default {
font-size: toRpx(48);
color: #ffffff;
background: rgba(255, 255, 255, 0.16);
z-index: 2;
z-index: 30;
}
.popup-scroll {
width: 100%;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!