Commit 544667ef by 岑成威

fix: app商品

1 parent 4867473b
......@@ -147,10 +147,96 @@ const getSoureData = async (shopMerchantId, sceneType, params = {}) => {
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'),
......
......@@ -45,13 +45,6 @@
></div>
</template>
</view>
<view
v-if="showLongImageBtn"
class="long-image-btn"
@click.stop="openLongImagePopup"
>
查看长图
</view>
</template>
<template v-else>
<view class="nothing flex">
......@@ -71,12 +64,6 @@
<image class="gif" src="../assets/images/common/loadding.gif" />
</view>
</template>
<view v-if="longImagePopupVisible" class="long-image-popup" @click.stop>
<view class="popup-close" @click.stop="closeLongImagePopup">×</view>
<scroll-view class="popup-scroll" scroll-y show-scrollbar>
<image class="popup-long-image" :src="currentImageUrl" mode="widthFix" />
</scroll-view>
</view>
</view>
</template>
<script>
......@@ -118,11 +105,7 @@ export default {
default: () => ({})
},
custom: Boolean,
swiperType: [Number, String],
longImageFlagKey: {
type: String,
default: 'isLongImage'
}
swiperType: [Number, String]
},
watch: {
moduleList: {
......@@ -130,8 +113,9 @@ export default {
if (!val.length) {
this.datalist = []
this.imagelist = []
return
}
if (val.length && !this.imagelist.length) this.getDatalist()
if (!this.imagelist.length) this.getDatalist()
},
deep: true
},
......@@ -145,15 +129,6 @@ export default {
computed: {
moduleTitle () {
return this.moduleList[this.currentIndex]?.detailTitle || ''
},
currentModule () {
return this.moduleList[this.currentIndex] || {}
},
currentImageUrl () {
return this.currentModule?.[this.imgKey] || ''
},
showLongImageBtn () {
return !!this.currentModule?.[this.longImageFlagKey] && !!this.currentImageUrl
}
},
created () {
......@@ -175,8 +150,7 @@ export default {
{ index: 2, class: 'block-right' }
]),
blockX: 0,
viewX: 0,
longImagePopupVisible: false
viewX: 0
}
},
beforeDestroy () {
......@@ -336,13 +310,6 @@ export default {
if (toor == 2) this.updateCarouselPositions()
this.$emit('click', item.isIndex)
},
openLongImagePopup () {
if (!this.showLongImageBtn) return
this.longImagePopupVisible = true
},
closeLongImagePopup () {
this.longImagePopupVisible = false
},
starts (e) {
this.ismove = e.touches[0].pageX
this.playStatus = false
......@@ -498,51 +465,6 @@ export default {
background: #fff;
}
}
.long-image-btn {
position: absolute;
left: 50%;
bottom: toRpx(40);
transform: translateX(-50%);
z-index: 25;
padding: toRpx(12) toRpx(28);
border-radius: toRpx(28);
font-size: toRpx(24);
color: #ffffff;
background: linear-gradient(90deg, #61c0ff 0%, #2c66f7 100%);
}
.long-image-popup {
position: fixed;
left: 0;
top: 0;
width: 100vw;
height: 100vh;
z-index: 9999;
background: rgba(0, 0, 0, 0.92);
.popup-close {
position: absolute;
right: toRpx(28);
top: toRpx(28);
width: toRpx(56);
height: toRpx(56);
line-height: toRpx(56);
text-align: center;
border-radius: 50%;
font-size: toRpx(48);
color: #ffffff;
background: rgba(255, 255, 255, 0.16);
z-index: 2;
}
.popup-scroll {
width: 100%;
height: 100%;
box-sizing: border-box;
padding: toRpx(100) 0 toRpx(40);
}
.popup-long-image {
width: 100%;
display: block;
}
}
.nothing {
width: 100%;
height: 100%;
......
const target = ['ip', 'dev', 'uat', 'prod', 'beta']
const index = 1
const index = 2
/**
*
0本地
......
......@@ -163,7 +163,6 @@ export default {
console.log(this.orderObj, 'orderObj')
handleTransactionData(newVal)
} else {
this.userInfo = uni.$storage.get('userInfo') || {}
this.baseConfigData = uni.$storage.get('mock_data') || {}
this.orderCreateType = 'createWithPay'
this.orderObj = {
......@@ -193,7 +192,6 @@ export default {
orderCreateType: 'createWithPay', // supplementOrder(补录订单) createWithPay(新增)
titleList,
formList: utils.deepClone(FORM_LIST),
userInfo: {},
baseConfigData: {},
requiredList: [], // 录单设置的必填项
orderObj: {
......@@ -260,7 +258,6 @@ export default {
},
mounted() {
console.log('mounted', this.orderCreateType)
this.userInfo = uni.$storage.get('userInfo') || {}
this.baseConfigData = uni.$storage.get('mock_data') || {}
this.initData()
},
......
......@@ -96,6 +96,19 @@
:showPayPage.sync="showPayPage"
@finish="open"
/>
<view
v-if="showLongImageBtn"
class="long-image-btn"
@click.stop="openLongImagePopup"
>
查看长图
</view>
<view v-if="longImagePopupVisible" class="long-image-popup" @click.stop>
<view class="popup-close" @click.stop="closeLongImagePopup">×</view>
<scroll-view class="popup-scroll" scroll-y show-scrollbar>
<image class="popup-long-image" :src="longImageUrl" mode="widthFix" />
</scroll-view>
</view>
</view>
</template>
<script>
......@@ -154,7 +167,8 @@ export default {
currentMediaId: '',
touchDiffX: 0,
isTouching: false,
loadedIndexes: [] // 记录已加载组件的索引
loadedIndexes: [], // 记录已加载组件的索引
longImagePopupVisible: false
}
},
computed: {
......@@ -216,6 +230,37 @@ export default {
if (!this.renderList || !this.renderList.length) return -1
return this.renderList.findIndex(i => i.id == this.id)
},
currentMaterial () {
if (this.currentIndex < 0) return {}
return this.renderList[this.currentIndex] || {}
},
longImageUrl () {
const item = this.currentMaterial || {}
const matched = this.getMatchedMaterialDetail(item)
// 有车系详情时,图也以匹配到的 materialDetailList 项为准(未选车则无图)
if (Array.isArray(item.materialDetailList) && item.materialDetailList.length) {
return matched?.contentPicUrl || ''
}
const carKey = this.getCustomerCarKey()
const views = item.receptionSourceDetailList
// 车系映射:{ [seriesId]: url }
if (views && typeof views === 'object' && !Array.isArray(views) && !views.detailUrl) {
if (carKey && views[carKey]) return views[carKey]
const firstUrl = Object.values(views).find(v => typeof v === 'string' && v)
if (firstUrl) return firstUrl
}
if (views?.detailUrl) return views.detailUrl
if (Array.isArray(views) && views[0]?.detailUrl) return views[0].detailUrl
return item.homeEntranceCover || item.thumbnail || item.contentPicUrl || ''
},
showLongImageBtn () {
return this.isLongImageItem(this.currentMaterial) && !!this.longImageUrl
},
carBrandOpenStatus () {
return this.$store.state.user.carBrandOpenStatus
},
......@@ -261,6 +306,7 @@ export default {
immediate: true,
handler (newval) {
if (newval) {
this.closeLongImagePopup()
this.useCarConfig = false
this.dateilKey = Date.now()
this.pageToolList = this.toolList
......@@ -278,7 +324,8 @@ export default {
id: {
immediate: true,
handler (newval) {
if(!this.pageToolList.length) this.pageToolList = this.toolList
this.closeLongImagePopup()
if (!this.pageToolList.length) this.pageToolList = this.toolList
}
}
// toolList: {
......@@ -293,6 +340,7 @@ export default {
this.screenWidth = systemInfo.screenWidth
},
beforeDestroy() {
this.closeLongImagePopup()
// 1. 清理所有定时器
if (this.preloadTimer) clearTimeout(this.preloadTimer)
if (this.rafId) clearTimeout(this.rafId) // 兼容 raf
......@@ -329,11 +377,16 @@ export default {
uni.$logger.local.info(`预览${e.title}`)
},
back () {
if (this.longImagePopupVisible) {
this.closeLongImagePopup()
return
}
this.$refs?.toolRef?.hide()
this.$emit('back')
},
done (e) {
this.showPayPage = false
this.closeLongImagePopup()
this.$refs.toolRef.hide()
this.$refs.stepRef.close()
this.receptionTrackLeave()
......@@ -575,6 +628,52 @@ export default {
if (!this.loadedIndexes.includes(index)) {
this.loadedIndexes.push(index)
}
},
getCustomerCarKey () {
const customerInfo = this.customerInfo || {}
return (
customerInfo.carModelId ||
customerInfo.carSeriesId ||
customerInfo.oneCarBrandId ||
''
)
},
// 与接待页 views[carModelId] 一致:必须已选车才能匹配;未选车返回 null
getMatchedMaterialDetail (item = {}) {
const list = item.materialDetailList
if (!Array.isArray(list) || !list.length) return null
const carKey = this.getCustomerCarKey()
if (!carKey) return null
return (
list.find(
d =>
String(d.relVehicleSeriesId) === String(carKey) ||
String(d.relVehicleModelId) === String(carKey)
) || null
)
},
isTruthyLongImageFlag (flag) {
return flag === true || flag === 1 || flag === '1' || flag === 'true'
},
isLongImageItem (item = {}) {
if (!item || !Object.keys(item).length) return false
// 有 materialDetailList:必须已选车系且匹配项 longImage 为 true 才显示
if (Array.isArray(item.materialDetailList) && item.materialDetailList.length) {
const matched = this.getMatchedMaterialDetail(item)
if (!matched) return false
return this.isTruthyLongImageFlag(matched.longImage ?? matched.isLongImage)
}
// 无车系详情列表时,才看素材外层字段
return this.isTruthyLongImageFlag(item.longImage ?? item.isLongImage)
},
openLongImagePopup () {
if (!this.showLongImageBtn) return
this.longImagePopupVisible = true
},
closeLongImagePopup () {
this.longImagePopupVisible = false
}
}
}
......@@ -676,4 +775,51 @@ export default {
opacity: 1;
}
}
.long-image-btn {
position: fixed;
left: 50%;
bottom: toRpx(48);
transform: translateX(-50%);
z-index: 20;
padding: toRpx(14) toRpx(36);
border-radius: toRpx(32);
font-size: toRpx(28);
line-height: toRpx(36);
color: #ffffff;
background: linear-gradient(90deg, #61c0ff 0%, #2c66f7 100%);
white-space: nowrap;
}
.long-image-popup {
position: fixed;
left: 0;
top: 0;
width: 100vw;
height: 100vh;
z-index: 9999;
background: rgba(0, 0, 0, 0.92);
.popup-close {
position: absolute;
right: toRpx(28);
top: toRpx(28);
width: toRpx(56);
height: toRpx(56);
line-height: toRpx(56);
text-align: center;
border-radius: 50%;
font-size: toRpx(48);
color: #ffffff;
background: rgba(255, 255, 255, 0.16);
z-index: 2;
}
.popup-scroll {
width: 100%;
height: 100%;
box-sizing: border-box;
padding: toRpx(100) 0 toRpx(40);
}
.popup-long-image {
width: 100%;
display: block;
}
}
</style>
......@@ -200,6 +200,7 @@ export default {
},
// 完成接待
done (e) {
this.$refs.detail?.closeLongImagePopup?.()
this.$refs.home.finishRef.close()
if (this.recording) this.$refs.home.stopAudio()
this.recording = false
......@@ -213,12 +214,18 @@ export default {
},
back () {
const detailRef = this.$refs.detail
if (detailRef.showPayPage) return (detailRef.showPayPage = false)
// 手势/物理返回走父页,须先关掉详情里的长图弹层,否则组件常挂载会把状态带回
if (detailRef?.longImagePopupVisible) {
detailRef.closeLongImagePopup()
return
}
if (detailRef?.showPayPage) return (detailRef.showPayPage = false)
if (!this.id) return uni.navigateBack()
if (this.type != 'preview') return this.$refs.home.finishRef.open()
this.backHome()
},
backHome () {
this.$refs.detail?.closeLongImagePopup?.()
if (this.recording) this.$refs.home.stopAudio(true)
this.$refs.home.finishRef.close()
this.id = ''
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!