hookehuyr

refactor(PosterCheckin): 优化海报生成逻辑并添加TODO注释

移除冗余的空格并添加TODO注释说明未来需要通过ID获取海报信息
优化背景图变化时的海报重新生成逻辑
......@@ -164,6 +164,8 @@ const pageParams = ref({
id: '',
})
// TODO: 有真实数据的时候, 通过ID获取具体地点的海报信息, 赋值currentPosterIndex获取特定的海报
// 图片预览相关
const previewVisible = ref(false)
const previewImages = ref([])
......@@ -457,17 +459,17 @@ watch(backgroundImages, (newVal, oldVal) => {
const currentIndex = currentPosterIndex.value
const newBgImage = newVal[currentIndex]
const oldBgImage = oldVal?.[currentIndex]
if (newBgImage !== oldBgImage) {
console.log('背景图发生变化:', { currentIndex, newBgImage, oldBgImage })
// 标记当前海报需要重新生成
posterGeneratedFlags.value[currentIndex] = false
delete posterConfigHashes.value[currentIndex]
// 清除当前海报路径
posterPath.value = ''
// 重新生成海报
generateCurrentPoster()
}
......@@ -625,20 +627,20 @@ const uploadBackgroundImage = (filePath) => {
const data = JSON.parse(uploadRes.data)
if (data.code === 0 && data.data) {
const currentIndex = currentPosterIndex.value
// 为当前海报设置背景图
backgroundImages.value[currentIndex] = data.data.src
// 强制标记当前海报需要重新生成
posterGeneratedFlags.value[currentIndex] = false
delete posterConfigHashes.value[currentIndex]
// 清除当前海报路径,强制重新生成
posterPath.value = ''
// 立即重新生成海报
generateCurrentPoster()
Taro.showToast({ title: '上传成功', icon: 'success' })
} else {
Taro.showToast({ title: data.msg || '上传失败', icon: 'none' })
......@@ -669,13 +671,13 @@ const onPosterSuccess = (result) => {
posterConfigHashes.value[currentIndex] = generateConfigHash()
shouldGeneratePoster.value = false
console.log('海报生成成功:', {
currentIndex,
posterPath: result.tempFilePath,
hasCustomBackground: !!backgroundImages.value[currentIndex]
})
Taro.showToast({ title: '海报生成成功', icon: 'success' })
}
......