hookehuyr

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

移除冗余的空格并添加TODO注释说明未来需要通过ID获取海报信息
优化背景图变化时的海报重新生成逻辑
...@@ -164,6 +164,8 @@ const pageParams = ref({ ...@@ -164,6 +164,8 @@ const pageParams = ref({
164 id: '', 164 id: '',
165 }) 165 })
166 166
167 +// TODO: 有真实数据的时候, 通过ID获取具体地点的海报信息, 赋值currentPosterIndex获取特定的海报
168 +
167 // 图片预览相关 169 // 图片预览相关
168 const previewVisible = ref(false) 170 const previewVisible = ref(false)
169 const previewImages = ref([]) 171 const previewImages = ref([])
...@@ -457,17 +459,17 @@ watch(backgroundImages, (newVal, oldVal) => { ...@@ -457,17 +459,17 @@ watch(backgroundImages, (newVal, oldVal) => {
457 const currentIndex = currentPosterIndex.value 459 const currentIndex = currentPosterIndex.value
458 const newBgImage = newVal[currentIndex] 460 const newBgImage = newVal[currentIndex]
459 const oldBgImage = oldVal?.[currentIndex] 461 const oldBgImage = oldVal?.[currentIndex]
460 - 462 +
461 if (newBgImage !== oldBgImage) { 463 if (newBgImage !== oldBgImage) {
462 console.log('背景图发生变化:', { currentIndex, newBgImage, oldBgImage }) 464 console.log('背景图发生变化:', { currentIndex, newBgImage, oldBgImage })
463 - 465 +
464 // 标记当前海报需要重新生成 466 // 标记当前海报需要重新生成
465 posterGeneratedFlags.value[currentIndex] = false 467 posterGeneratedFlags.value[currentIndex] = false
466 delete posterConfigHashes.value[currentIndex] 468 delete posterConfigHashes.value[currentIndex]
467 - 469 +
468 // 清除当前海报路径 470 // 清除当前海报路径
469 posterPath.value = '' 471 posterPath.value = ''
470 - 472 +
471 // 重新生成海报 473 // 重新生成海报
472 generateCurrentPoster() 474 generateCurrentPoster()
473 } 475 }
...@@ -625,20 +627,20 @@ const uploadBackgroundImage = (filePath) => { ...@@ -625,20 +627,20 @@ const uploadBackgroundImage = (filePath) => {
625 const data = JSON.parse(uploadRes.data) 627 const data = JSON.parse(uploadRes.data)
626 if (data.code === 0 && data.data) { 628 if (data.code === 0 && data.data) {
627 const currentIndex = currentPosterIndex.value 629 const currentIndex = currentPosterIndex.value
628 - 630 +
629 // 为当前海报设置背景图 631 // 为当前海报设置背景图
630 backgroundImages.value[currentIndex] = data.data.src 632 backgroundImages.value[currentIndex] = data.data.src
631 - 633 +
632 // 强制标记当前海报需要重新生成 634 // 强制标记当前海报需要重新生成
633 posterGeneratedFlags.value[currentIndex] = false 635 posterGeneratedFlags.value[currentIndex] = false
634 delete posterConfigHashes.value[currentIndex] 636 delete posterConfigHashes.value[currentIndex]
635 - 637 +
636 // 清除当前海报路径,强制重新生成 638 // 清除当前海报路径,强制重新生成
637 posterPath.value = '' 639 posterPath.value = ''
638 - 640 +
639 // 立即重新生成海报 641 // 立即重新生成海报
640 generateCurrentPoster() 642 generateCurrentPoster()
641 - 643 +
642 Taro.showToast({ title: '上传成功', icon: 'success' }) 644 Taro.showToast({ title: '上传成功', icon: 'success' })
643 } else { 645 } else {
644 Taro.showToast({ title: data.msg || '上传失败', icon: 'none' }) 646 Taro.showToast({ title: data.msg || '上传失败', icon: 'none' })
...@@ -669,13 +671,13 @@ const onPosterSuccess = (result) => { ...@@ -669,13 +671,13 @@ const onPosterSuccess = (result) => {
669 posterConfigHashes.value[currentIndex] = generateConfigHash() 671 posterConfigHashes.value[currentIndex] = generateConfigHash()
670 672
671 shouldGeneratePoster.value = false 673 shouldGeneratePoster.value = false
672 - 674 +
673 console.log('海报生成成功:', { 675 console.log('海报生成成功:', {
674 currentIndex, 676 currentIndex,
675 posterPath: result.tempFilePath, 677 posterPath: result.tempFilePath,
676 hasCustomBackground: !!backgroundImages.value[currentIndex] 678 hasCustomBackground: !!backgroundImages.value[currentIndex]
677 }) 679 })
678 - 680 +
679 Taro.showToast({ title: '海报生成成功', icon: 'success' }) 681 Taro.showToast({ title: '海报生成成功', icon: 'success' })
680 } 682 }
681 683
......