From 40dd0e9898bf2a88e51d497c46d826ea8f7326f4 Mon Sep 17 00:00:00 2001
From: shinnosuke <tantao@1hoper.com>
Date: 星期四, 20 八月 2026 09:37:15 +0800
Subject: [PATCH] fix: connect premium merchants and restrict approval PDFs

---
 talent-card-admin/src/views/MerchantCreateView.vue |   30 ++++++++++++++++++++++++++----
 1 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/talent-card-admin/src/views/MerchantCreateView.vue b/talent-card-admin/src/views/MerchantCreateView.vue
index 35e3bf1..03b012b 100644
--- a/talent-card-admin/src/views/MerchantCreateView.vue
+++ b/talent-card-admin/src/views/MerchantCreateView.vue
@@ -22,6 +22,7 @@
   updateProduct,
   updateProductStatus,
   uploadAdminImage,
+  uploadAdminPdf,
 } from '../api/admin'
 import AdminRichTextEditor from '../components/AdminRichTextEditor.vue'
 import type { Coupon, CouponPayload, MerchantPayload, Product, ProductPayload } from '../types/admin'
@@ -1274,6 +1275,7 @@
 
 function changeCover(target: 'merchant' | 'productCover' | 'productImage' | 'approvalWindow') {
   imageUploadTarget.value = target
+  if (imageInputRef.value) imageInputRef.value.accept = target === 'approvalWindow' ? 'application/pdf,.pdf' : 'image/jpeg,image/png,image/webp'
   imageInputRef.value?.click()
 }
 
@@ -1295,6 +1297,30 @@
   input.value = ''
   if (!file) return
 
+  if (imageUploadTarget.value === 'approvalWindow') {
+    const isPdf = file.type === 'application/pdf' || file.name.toLowerCase().endsWith('.pdf')
+    if (!isPdf) {
+      ElMessage.warning('窗口信息只能上传 PDF 文件')
+      return
+    }
+    if (file.size > 20 * 1024 * 1024) {
+      ElMessage.warning('PDF 文件大小不能超过 20 MB')
+      return
+    }
+    imageUploading.value = true
+    try {
+      const result = await uploadAdminPdf(file)
+      if (approvalUploadIndex.value >= 0) approvalItems.value[approvalUploadIndex.value].windowInfoUrl = result.url
+      ElMessage.success('窗口信息上传成功')
+    } catch {
+      // The shared HTTP interceptor displays the upload error.
+    } finally {
+      approvalUploadIndex.value = -1
+      imageUploading.value = false
+    }
+    return
+  }
+
   const acceptedTypes = ['image/jpeg', 'image/png', 'image/webp']
   if (!acceptedTypes.includes(file.type)) {
     ElMessage.warning('请选择 JPG、PNG 或 WEBP 格式的图片')
@@ -1312,10 +1338,6 @@
       form.coverUrl = result.url
       resetMerchantCoverPreview()
       merchantFormRef.value?.validateField('coverUrl').catch(() => undefined)
-    } else if (imageUploadTarget.value === 'approvalWindow') {
-      if (approvalUploadIndex.value >= 0) {
-        approvalItems.value[approvalUploadIndex.value].windowInfoUrl = result.url
-      }
     } else if (imageUploadTarget.value === 'productCover') {
       productForm.coverUrl = result.url
       resetProductCoverPreview()

--
Gitblit v1.7.1