Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
lls_program
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2025-09-04 20:30:41 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8d2fa3190a328c65cd5f63f772179abe4ad189d0
8d2fa319
1 parent
b63574ad
feat(海报检查): 添加海报生成失败状态处理及按钮逻辑
增加海报生成失败状态变量及相应UI反馈 合并保存和重新生成操作为统一处理函数 根据状态显示不同按钮文本和样式
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
11 deletions
src/pages/PosterCheckin/index.vue
src/pages/PosterCheckin/index.vue
View file @
8d2fa31
...
...
@@ -79,11 +79,11 @@
</view>
<view
class="flex-1 text-white py-3 px-6 rounded-lg font-medium shadow-lg active:scale-95 transition-transform duration-150 flex items-center justify-center gap-2"
:class="posterPath ? 'bg-gradient-to-r from-green-400 to-green-500' :
'bg-gray-400'
"
@click="
savePoster
"
:disabled="!posterPath"
:class="posterPath ? 'bg-gradient-to-r from-green-400 to-green-500' :
(posterGenerateFailed ? 'bg-gradient-to-r from-orange-400 to-orange-500' : 'bg-gray-400')
"
@click="
handlePosterAction
"
:disabled="!posterPath
&& !posterGenerateFailed
"
>
<text>
保存海报
</text>
<text>
{{ posterPath ? '保存海报' : (posterGenerateFailed ? '重新生成' : '生成中...') }}
</text>
</view>
</view>
</view>
...
...
@@ -138,6 +138,7 @@ const posterPath = ref('') // 生成的海报路径
const backgroundImage = ref('') // 用户上传的背景图
const shouldGeneratePoster = ref(false) // 是否应该生成海报
const currentPosterIndex = ref(0) // 当前显示的海报索引
const posterGenerateFailed = ref(false) // 海报生成是否失败
// 页面参数
const pageParams = ref({
...
...
@@ -373,17 +374,11 @@ watch(currentPosterIndex, () => {
})
/**
* 返回上一页
*/
const goBack = () => {
Taro.navigateBack()
}
/**
* 生成当前海报
*/
const generateCurrentPoster = () => {
posterPath.value = ''
posterGenerateFailed.value = false
shouldGeneratePoster.value = false
// 延迟触发生成,确保配置更新
...
...
@@ -493,6 +488,7 @@ const uploadBackgroundImage = (filePath) => {
*/
const onPosterSuccess = (result) => {
posterPath.value = result.tempFilePath
posterGenerateFailed.value = false
// 更新当前海报的路径
if (posterList.value[currentPosterIndex.value]) {
posterList.value[currentPosterIndex.value].path = result.tempFilePath
...
...
@@ -506,6 +502,8 @@ const onPosterSuccess = (result) => {
*/
const onPosterFail = (error) => {
shouldGeneratePoster.value = false
posterGenerateFailed.value = true
posterPath.value = ''
Taro.showToast({ title: '海报生成失败', icon: 'none' })
console.error('海报生成失败:', error)
}
...
...
@@ -530,6 +528,19 @@ const closePreview = () => {
}
/**
* 处理海报按钮点击事件
*/
const handlePosterAction = () => {
if (posterPath.value) {
// 如果海报已生成,执行保存操作
savePoster()
} else if (posterGenerateFailed.value) {
// 如果生成失败,重新生成海报
generateCurrentPoster()
}
}
/**
* 保存海报到相册
*/
const savePoster = () => {
...
...
Please
register
or
login
to post a comment