feat: 使用banana模型生成分镜图片,修复数据库列类型问题

- 修改RealAIService.submitTextToImageTask使用nano-banana/nano-banana-hd模型
- 支持根据hdMode参数选择模型(标准/高清)
- 修复数据库列类型:将result_url等字段改为TEXT类型以支持Base64图片
- 添加数据库修复SQL脚本(fix_database_columns.sql, update_database_schema.sql)
- 改进StoryboardVideoService的错误处理和空值检查
- 添加GlobalExceptionHandler全局异常处理
- 优化图片URL提取逻辑,支持url和b64_json两种格式
- 改进响应格式验证,确保data字段不为空
This commit is contained in:
AIGC Developer
2025-11-05 18:18:53 +08:00
parent 0b0ad442a0
commit b5820d9be2
63 changed files with 2207 additions and 341 deletions

View File

@@ -8,9 +8,9 @@
:close-on-click-modal="false"
:close-on-press-escape="true"
@close="handleClose"
center
:show-close="true"
custom-class="payment-modal-dialog"
:modal-class="'payment-modal-overlay'"
>
<div class="payment-content">
<!-- 支付方式选择 -->
@@ -36,8 +36,8 @@
<!-- 二维码区域 -->
<div class="qr-section">
<div class="qr-code">
<img id="qr-code-img" style="display: none; width: 200px; height: 200px;" alt="支付二维码" />
<div class="qr-placeholder">
<img id="qr-code-img" style="display: none; width: 200px; height: 200px; margin: 0; padding: 0; border: none; object-fit: contain; background: #1a1a1a;" alt="支付二维码" />
<div ref="qrPlaceholder" class="qr-placeholder">
<div class="qr-grid">
<div class="qr-dot" v-for="i in 64" :key="i"></div>
</div>
@@ -52,6 +52,26 @@
<p>请使用支付宝扫描上方二维码完成支付</p>
<p class="tip-small">支付完成后页面将自动更新</p>
</div>
<!-- 模拟支付完成按钮仅用于测试 -->
<div class="test-payment-section" style="margin-top: 16px; text-align: center;">
<button
class="test-payment-btn"
@click="handleTestPaymentComplete"
:disabled="!currentPaymentId || loading"
style="
padding: 8px 16px;
background: #ff9800;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 12px;
opacity: 0.8;
"
>
🧪 模拟支付完成测试用
</button>
</div>
</div>
<!-- 底部链接 -->
@@ -63,10 +83,10 @@
</template>
<script setup>
import { ref, watch } from 'vue'
import { ref, watch, onUnmounted } from 'vue'
import { ElMessage } from 'element-plus'
import { CreditCard } from '@element-plus/icons-vue'
import { createPayment, createAlipayPayment } from '@/api/payments'
import { createPayment, createAlipayPayment, getPaymentById, testPaymentComplete } from '@/api/payments'
const props = defineProps({
modelValue: {
@@ -92,15 +112,25 @@ const emit = defineEmits(['update:modelValue', 'pay-success', 'pay-error'])
const visible = ref(false)
const selectedMethod = ref('alipay')
const loading = ref(false)
const currentPaymentId = ref(null)
let paymentPollingTimer = null
// 监听 modelValue 变化
watch(() => props.modelValue, (newVal) => {
visible.value = newVal
// 当模态框打开时,自动开始支付流程
if (newVal) {
handlePay()
}
})
// 监听 visible 变化
watch(visible, (newVal) => {
emit('update:modelValue', newVal)
// 如果模态框关闭,停止轮询
if (!newVal) {
stopPaymentPolling()
}
})
// 选择支付方式
@@ -132,6 +162,7 @@ const handlePay = async () => {
if (createResponse.data && createResponse.data.success) {
const paymentId = createResponse.data.data.id
currentPaymentId.value = paymentId
console.log('2. 支付订单创建成功ID', paymentId)
ElMessage.info('正在生成支付宝二维码...')
@@ -148,24 +179,41 @@ const handlePay = async () => {
const qrCode = alipayResponse.data.data.qrCode
console.log('4. 支付宝二维码:', qrCode)
// 更新二维码显示
const qrCodeElement = document.querySelector('#qr-code-img')
if (qrCodeElement) {
qrCodeElement.src = `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(qrCode)}`
qrCodeElement.style.display = 'block'
console.log('5. 二维码图片已设置')
// 使用在线API生成二维码图片直接使用支付宝返回的URL生成二维码
try {
console.log('开始生成二维码,内容:', qrCode)
// 使用QuickChart API生成二维码完全去除白边
// 直接使用支付宝返回的URL作为二维码内容
const qrCodeUrl = `https://quickchart.io/qr?text=${encodeURIComponent(qrCode)}&size=200&margin=0&dark=ffffff&light=1a1a1a`
console.log('5. 二维码图片URL已生成')
// 更新二维码显示
const qrCodeElement = document.querySelector('#qr-code-img')
if (qrCodeElement) {
qrCodeElement.src = qrCodeUrl
qrCodeElement.style.display = 'block'
console.log('6. 二维码图片已设置')
}
// 隐藏模拟二维码
const qrPlaceholder = document.querySelector('.qr-placeholder')
if (qrPlaceholder) {
qrPlaceholder.style.display = 'none'
console.log('7. 模拟二维码已隐藏')
}
ElMessage.success('二维码已生成,请使用支付宝扫码支付')
console.log('=== 支付流程完成,开始轮询支付状态 ===')
// 开始轮询支付状态
startPaymentPolling(paymentId)
} catch (error) {
console.error('生成二维码失败:', error)
ElMessage.error('生成二维码失败,请重试')
}
// 隐藏模拟二维码
const qrPlaceholder = document.querySelector('.qr-placeholder')
if (qrPlaceholder) {
qrPlaceholder.style.display = 'none'
console.log('6. 模拟二维码已隐藏')
}
ElMessage.success('二维码已生成,请使用支付宝扫码支付')
console.log('=== 支付流程完成 ===')
} else {
console.error('支付宝响应失败:', alipayResponse)
ElMessage.error(alipayResponse.data?.message || '生成二维码失败')
@@ -192,11 +240,152 @@ const handlePay = async () => {
}
}
// 轮询支付状态
const startPaymentPolling = (paymentId) => {
// 清除之前的轮询
stopPaymentPolling()
let pollCount = 0
const maxPolls = 60 // 最多轮询60次10分钟每10秒一次
const poll = async () => {
if (pollCount >= maxPolls) {
console.log('轮询达到最大次数,停止轮询')
stopPaymentPolling()
return
}
try {
console.log(`轮询支付状态 (${pollCount + 1}/${maxPolls})支付ID:`, paymentId)
const response = await getPaymentById(paymentId)
if (response.data && response.data.success) {
const payment = response.data.data
const status = payment.status
console.log('支付状态:', status, '状态说明:', getStatusDescription(status))
if (status === 'SUCCESS' || status === 'COMPLETED') {
console.log('✅ 支付成功!支付数据:', payment)
stopPaymentPolling()
ElMessage.success('支付成功!')
emit('pay-success', payment)
// 延迟关闭模态框
setTimeout(() => {
visible.value = false
}, 2000)
return
} else if (status === 'FAILED' || status === 'CANCELLED') {
console.log('支付失败或取消')
stopPaymentPolling()
ElMessage.warning('支付已取消或失败')
emit('pay-error', new Error('支付已取消或失败'))
return
} else if (status === 'PROCESSING') {
console.log('支付处理中...')
// PROCESSING 状态继续轮询,但可以给用户提示
if (pollCount % 6 === 0) { // 每60秒提示一次
ElMessage.info('支付处理中,请稍候...')
}
} else if (status === 'PENDING') {
console.log('支付待处理中(等待支付宝回调)...')
// PENDING 状态继续轮询
if (pollCount % 6 === 0) { // 每60秒提示一次
ElMessage.info('等待支付确认,请确保已完成支付...')
}
}
}
// 继续轮询
pollCount++
paymentPollingTimer = setTimeout(poll, 10000) // 每10秒轮询一次
} catch (error) {
console.error('轮询支付状态失败:', error)
// 错误时也继续轮询,直到达到最大次数
pollCount++
if (pollCount < maxPolls) {
paymentPollingTimer = setTimeout(poll, 10000)
}
}
}
// 开始轮询等待5秒后开始第一次轮询
setTimeout(() => {
poll()
}, 5000)
}
// 停止轮询支付状态
const stopPaymentPolling = () => {
if (paymentPollingTimer) {
clearTimeout(paymentPollingTimer)
paymentPollingTimer = null
console.log('已停止轮询支付状态')
}
}
// 关闭模态框
const handleClose = () => {
stopPaymentPolling()
visible.value = false
}
// 组件卸载时清理轮询
onUnmounted(() => {
stopPaymentPolling()
})
// 获取支付状态描述
const getStatusDescription = (status) => {
const statusMap = {
'PENDING': '待支付 - 等待用户扫码支付',
'PROCESSING': '处理中 - 支付宝正在处理支付',
'SUCCESS': '支付成功',
'COMPLETED': '支付完成',
'FAILED': '支付失败',
'CANCELLED': '已取消',
'REFUNDED': '已退款'
}
return statusMap[status] || '未知状态'
}
// 模拟支付完成(用于测试)
const handleTestPaymentComplete = async () => {
if (!currentPaymentId.value) {
ElMessage.warning('支付订单尚未创建,请稍候...')
return
}
try {
loading.value = true
ElMessage.info('正在模拟支付完成...')
console.log('模拟支付完成支付ID:', currentPaymentId.value)
const response = await testPaymentComplete(currentPaymentId.value)
console.log('✅ 模拟支付完成响应:', response)
console.log('✅ 响应数据:', response.data)
if (response.data && response.data.success) {
console.log('✅ 模拟支付完成成功,支付数据:', response.data.data)
ElMessage.success('支付完成!')
stopPaymentPolling()
emit('pay-success', response.data.data)
// 延迟关闭模态框
setTimeout(() => {
visible.value = false
}, 2000)
} else {
console.error('❌ 模拟支付完成失败,响应:', response)
ElMessage.error(response.data?.message || '模拟支付完成失败')
}
} catch (error) {
console.error('模拟支付完成失败:', error)
ElMessage.error(`模拟支付完成失败:${error.message || '请重试'}`)
} finally {
loading.value = false
}
}
// 显示协议
const showAgreement = () => {
ElMessage.info('服务协议页面')
@@ -205,76 +394,256 @@ const showAgreement = () => {
<style scoped>
.payment-modal {
background: #0a0a0a;
background: #000000 !important;
}
/* 移除所有可能的白边和边框 */
.payment-modal :deep(.el-dialog),
.payment-modal-dialog {
background: #0a0a0a !important;
border-radius: 12px;
.payment-modal-dialog,
.payment-modal :deep(.el-dialog.el-dialog--center.payment-modal),
.payment-modal :deep(.el-dialog.el-dialog--center),
.payment-modal.el-dialog.el-dialog--center.payment-modal,
.payment-modal :deep(.el-dialog.el-dialog--center.payment-modal-dialog),
.payment-modal :deep(.payment-modal-dialog.el-dialog.el-dialog--center.payment-modal) {
background: #000000 !important;
background-color: #000000 !important;
background-image: none !important;
border-radius: 12px !important;
border: none !important;
border-width: 0 !important;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
border-style: none !important;
border-color: transparent !important;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), inset 0 0 0 0 transparent !important;
padding: 0 !important;
margin: 0 !important;
outline: none !important;
outline-width: 0 !important;
outline-style: none !important;
outline-color: transparent !important;
box-sizing: border-box !important;
overflow: hidden !important;
/* 移除所有可能的白色边框 */
-webkit-box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), inset 0 0 0 0 transparent !important;
-moz-box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), inset 0 0 0 0 transparent !important;
}
/* 移除所有伪元素可能产生的边框 */
.payment-modal :deep(.el-dialog::before),
.payment-modal :deep(.el-dialog::after),
.payment-modal :deep(.el-dialog__wrapper::before),
.payment-modal :deep(.el-dialog__wrapper::after),
.payment-modal :deep(.el-dialog__body::before),
.payment-modal :deep(.el-dialog__body::after) {
display: none !important;
content: none !important;
border: none !important;
outline: none !important;
box-shadow: none !important;
}
/* 移除所有可能的白色边框 - 使用更具体的选择器 */
.payment-modal :deep(.el-dialog),
.payment-modal :deep(.el-dialog *) {
border-left: none !important;
border-right: none !important;
border-top: none !important;
border-bottom: none !important;
}
.payment-modal :deep(.el-dialog__body) {
padding: 0 !important;
margin: 0 !important;
background: #0a0a0a !important;
background: #000000 !important;
background-color: #000000 !important;
border: none !important;
border-width: 0 !important;
border-style: none !important;
border-color: transparent !important;
outline: none !important;
outline-width: 0 !important;
outline-style: none !important;
outline-color: transparent !important;
overflow: hidden !important;
box-sizing: border-box !important;
}
/* 移除对话框内部的所有边框和间隙 */
.payment-modal :deep(.el-dialog) * {
border-color: transparent !important;
}
/* 确保对话框本身没有任何白色背景或边框 */
.payment-modal :deep(.el-dialog),
.payment-modal :deep(.el-dialog.el-dialog--center.payment-modal),
.payment-modal :deep(.el-dialog.el-dialog--center),
.payment-modal :deep(.payment-modal-dialog),
.payment-modal :deep(.payment-modal-dialog.el-dialog),
.payment-modal :deep(.payment-modal-dialog.el-dialog--center),
.payment-modal :deep(.payment-modal-dialog.el-dialog--center.payment-modal) {
background-color: #000000 !important;
background: #000000 !important;
background-image: none !important;
}
/* 移除所有可能的白色边框 */
.payment-modal :deep(.el-dialog),
.payment-modal :deep(.el-dialog__body) {
border: 0 !important;
border-top: none !important;
border-bottom: none !important;
border-left: none !important;
border-right: none !important;
border-width: 0 !important;
border-style: none !important;
border-color: transparent !important;
}
.payment-modal :deep(.el-dialog__header),
.payment-modal :deep(.el-dialog__header.show-close) {
background: #000000 !important;
background-color: #000000 !important;
border: none !important;
border-bottom: 1px solid #1a1a1a !important;
border-top: none !important;
border-left: none !important;
border-right: none !important;
border-width: 0 !important;
border-bottom-width: 1px !important;
border-bottom-style: solid !important;
border-bottom-color: #1a1a1a !important;
padding: 20px 24px !important;
margin: 0 !important;
color: white !important;
text-align: left !important;
}
/* 确保 header.show-close 内的所有文字都是白色 */
.payment-modal :deep(.el-dialog__header.show-close),
.payment-modal :deep(.el-dialog__header.show-close *),
.payment-modal :deep(.el-dialog__header.show-close .el-dialog__title),
.payment-modal :deep(.el-dialog__header.show-close .el-dialog__headerbtn) {
color: white !important;
}
/* 确保关闭按钮区域背景也与模态框一致 */
.payment-modal :deep(.el-dialog__headerbtn),
.payment-modal :deep(.el-dialog__headerbtn.is-close),
.payment-modal :deep(.el-dialog__header .el-dialog__headerbtn) {
background: transparent !important;
background-color: transparent !important;
}
.payment-modal :deep(.el-dialog__headerbtn:hover) {
background: rgba(255, 255, 255, 0.1) !important;
background-color: rgba(255, 255, 255, 0.1) !important;
}
.payment-modal :deep(.el-dialog__wrapper) {
background: transparent !important;
padding: 0 !important;
margin: 0 !important;
border: none !important;
border-width: 0 !important;
border-style: none !important;
border-color: transparent !important;
outline: none !important;
outline-width: 0 !important;
outline-style: none !important;
outline-color: transparent !important;
background: transparent !important;
}
.payment-modal :deep(.el-overlay) {
background: transparent !important;
/* 确保 wrapper 内的所有对话框元素背景为黑色 */
.payment-modal :deep(.el-dialog__wrapper .el-dialog),
.payment-modal :deep(.el-dialog__wrapper .el-dialog.el-dialog--center),
.payment-modal :deep(.el-dialog__wrapper .el-dialog.el-dialog--center.payment-modal),
.payment-modal :deep(.el-dialog__wrapper .payment-modal-dialog) {
background: #000000 !important;
background-color: #000000 !important;
}
.payment-modal :deep(.el-overlay),
.payment-modal :deep(.payment-modal-overlay),
.payment-modal :deep(.el-overlay.payment-modal-overlay),
.payment-modal :deep(.el-overlay.payment-modal-overlay.el-modal-dialog) {
background: rgba(0, 0, 0, 0.5) !important;
border: none !important;
outline: none !important;
}
/* 确保 el-overlay.payment-modal-overlay.el-modal-dialog 内的对话框背景为黑色 */
.payment-modal :deep(.el-overlay.payment-modal-overlay.el-modal-dialog .el-dialog),
.payment-modal :deep(.el-overlay.payment-modal-overlay.el-modal-dialog .el-dialog.el-dialog--center),
.payment-modal :deep(.el-overlay.payment-modal-overlay.el-modal-dialog .el-dialog.el-dialog--center.payment-modal),
.payment-modal :deep(.el-overlay.payment-modal-overlay.el-modal-dialog .el-dialog__body),
.payment-modal :deep(.el-overlay.payment-modal-overlay.el-modal-dialog .el-dialog__header) {
background: #000000 !important;
background-color: #000000 !important;
}
.payment-modal :deep(.el-overlay-dialog) {
background: transparent !important;
background: rgba(0, 0, 0, 0.5) !important;
border: none !important;
outline: none !important;
}
/* 确保 el-overlay-dialog 内的对话框背景为黑色 */
.payment-modal :deep(.el-overlay-dialog .el-dialog),
.payment-modal :deep(.el-overlay-dialog .el-dialog.el-dialog--center),
.payment-modal :deep(.el-overlay-dialog .el-dialog.el-dialog--center.payment-modal),
.payment-modal :deep(.el-overlay-dialog .el-dialog__body),
.payment-modal :deep(.el-overlay-dialog .el-dialog__header) {
background: #000000 !important;
background-color: #000000 !important;
}
/* 确保遮罩层没有白边 */
.payment-modal :deep(.el-overlay.is-message-box) {
background: transparent !important;
}
.payment-modal :deep(.el-dialog__header) {
background: #0a0a0a;
border-bottom: 1px solid #1a1a1a;
padding: 20px 24px;
background: rgba(0, 0, 0, 0.5) !important;
}
.payment-modal :deep(.el-dialog__title) {
color: white;
font-size: 18px;
font-weight: 600;
color: #ffffff !important;
font-size: 18px !important;
font-weight: bold !important;
font-family: "SimSun", "宋体", serif !important;
text-align: left !important;
line-height: 1.5 !important;
letter-spacing: 0.5px !important;
text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8), 0 0 10px rgba(255, 255, 255, 0.3) !important;
filter: brightness(1.1) contrast(1.2) !important;
}
.payment-modal :deep(.el-dialog__headerbtn) {
color: #999;
color: white !important;
}
.payment-modal :deep(.el-dialog__headerbtn:hover) {
color: white;
color: white !important;
}
.payment-modal :deep(.el-dialog__headerbtn svg) {
color: white !important;
fill: white !important;
}
.payment-content {
padding: 24px;
background: #0a0a0a;
color: white;
margin: 0;
background: #000000 !important;
background-color: #000000 !important;
color: white !important;
margin: 0 !important;
border: none !important;
border-width: 0 !important;
box-sizing: border-box !important;
}
/* 确保 payment-content 内的所有文字都是白色(链接除外) */
.payment-content,
.payment-content *:not(a),
.payment-content p,
.payment-content span,
.payment-content div {
color: white !important;
}
/* 支付方式选择 */
@@ -296,6 +665,7 @@ const showAgreement = () => {
transition: all 0.3s ease;
background: #1a1a1a;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
color: white;
}
.payment-method:hover {
@@ -323,8 +693,11 @@ const showAgreement = () => {
}
.payment-method span {
font-size: 14px;
font-weight: 500;
font-size: 14px !important;
font-weight: 500 !important;
color: white !important;
line-height: 1.5 !important;
letter-spacing: 0.3px !important;
}
/* 金额显示 */
@@ -334,16 +707,21 @@ const showAgreement = () => {
}
.amount-label {
font-size: 14px;
color: #999;
margin-bottom: 8px;
font-size: 14px !important;
color: white !important;
margin-bottom: 8px !important;
font-weight: 400 !important;
line-height: 1.5 !important;
letter-spacing: 0.3px !important;
}
.amount-value {
font-size: 32px;
font-weight: 700;
color: #e0e0e0;
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
font-size: 32px !important;
font-weight: 700 !important;
color: white !important;
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
line-height: 1.2 !important;
letter-spacing: 0.5px !important;
}
/* 二维码区域 */
@@ -356,13 +734,30 @@ const showAgreement = () => {
width: 200px;
height: 200px;
margin: 0 auto 16px;
padding: 0;
background: #1a1a1a;
border: none;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
overflow: hidden;
box-sizing: border-box;
position: relative;
line-height: 0;
}
.qr-code img {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
border: none;
display: block;
object-fit: contain;
object-position: center;
background: #1a1a1a;
box-sizing: border-box;
image-rendering: -webkit-optimize-contrast;
image-rendering: crisp-edges;
}
.qr-placeholder {
@@ -409,15 +804,20 @@ const showAgreement = () => {
top: 50%;
left: 50%;
transform: translate(-50%, calc(-50% + 40px));
color: #4a9eff;
font-size: 12px;
font-weight: 500;
opacity: 0.8;
color: white !important;
font-size: 12px !important;
font-weight: 500 !important;
opacity: 0.8 !important;
line-height: 1.5 !important;
letter-spacing: 0.3px !important;
}
.qr-tip {
font-size: 12px;
color: #999;
font-size: 12px !important;
color: white !important;
line-height: 1.5 !important;
letter-spacing: 0.2px !important;
font-weight: 400 !important;
}
/* 操作按钮 */
@@ -469,14 +869,21 @@ const showAgreement = () => {
}
.pay-tip p {
margin: 8px 0;
color: #e0e0e0;
font-size: 14px;
margin: 8px 0 !important;
color: white !important;
font-size: 14px !important;
line-height: 1.6 !important;
letter-spacing: 0.3px !important;
font-weight: 400 !important;
}
.tip-small {
color: #999 !important;
color: white !important;
font-size: 12px !important;
line-height: 1.5 !important;
letter-spacing: 0.2px !important;
font-weight: 400 !important;
opacity: 0.8 !important;
}
/* 底部链接 */
@@ -485,14 +892,17 @@ const showAgreement = () => {
}
.footer-link a {
color: #4a9eff;
text-decoration: none;
font-size: 12px;
transition: color 0.3s ease;
color: #4a9eff !important;
text-decoration: none !important;
font-size: 12px !important;
transition: color 0.3s ease !important;
line-height: 1.5 !important;
letter-spacing: 0.2px !important;
font-weight: 400 !important;
}
.footer-link a:hover {
color: #3a8bdf;
color: #3a8bdf !important;
}
/* 响应式设计 */