diff --git a/VERSION b/VERSION index 2d04904..da5c718 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.2.90 +1.2.91 \ No newline at end of file diff --git a/config/VERSION b/config/VERSION index f73f4c0..55f1222 100644 --- a/config/VERSION +++ b/config/VERSION @@ -1 +1 @@ -VERSION=1.2.81 +1.2.89 diff --git a/frontend/src/pages/Add.jsx b/frontend/src/pages/Add.jsx index 0c21dd0..5fde9a7 100644 --- a/frontend/src/pages/Add.jsx +++ b/frontend/src/pages/Add.jsx @@ -824,21 +824,32 @@ export default function Add() { setSavingDeal(true) try { const token = localStorage.getItem('token') - const digits = dealForm.serial.replace('J', '').replace(/[^0-9]/g, '').slice(0, 9) - let tailNumber = '', sizeType = '' - if (dealForm.packaging === '标十' && digits.length >= 2) { - tailNumber = digits.slice(-2) - sizeType = ['01','11','21','31','41','51'].includes(tailNumber) ? '小号' : '大号' - } else if (dealForm.packaging === '标百' && digits.length >= 3) { - tailNumber = digits.slice(-3) - sizeType = ['101','201','301','401','501'].includes(tailNumber) ? '小号' : '大号' + // 冠字号矫正:用户输入的数字位数不同,生成规则不同 + // 7位 → J0 + 0 + 数字 (如 J00123456) + // 8位 → J0 + 数字 (如 J01234567) + // 9位 → J0 + 取后8位数字 (如 J02345678) + const rawSerial = dealForm.serial.replace('J', '').replace(/\D/g, '') + let normalizedSerial = '' + if (rawSerial.length === 7) { + normalizedSerial = 'J0' + '0' + rawSerial + } else if (rawSerial.length === 8) { + normalizedSerial = 'J0' + rawSerial + } else if (rawSerial.length >= 9) { + normalizedSerial = 'J0' + rawSerial.slice(1, 9) // 取后8位 + } else { + normalizedSerial = 'J0' + rawSerial } + + const tailNumber = rawSerial.slice(-2) + const sizeType = (dealForm.packaging === '标十' && ['01','11','21','31','41','51','61','71','81','91'].includes(tailNumber)) ? '小号' : + (dealForm.packaging === '标百' && ['001','011','021','031','041','051','061','071','081','091'].includes(rawSerial.slice(-3))) ? '小号' : '大号' + const response = await fetch(`${API_BASE}/api/information/`, { method: 'POST', headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ info_type: 'deal', - title: `J0${dealForm.serial.replace('J', '').slice(0, 8)}-¥${dealForm.price}`, + title: `${normalizedSerial}-¥${dealForm.price}`, content: `分类: ${dealForm.category || '未分类'}\n尾号: ${tailNumber || '-'}\n大小号: ${sizeType || '-'}\n包装: ${dealForm.packaging}\n平台: ${dealForm.platform}\n价格: ¥${dealForm.price}\n出售者: ${dealForm.seller || '-'}\n购买者: ${dealForm.buyer || '-'}\n日期: ${dealForm.date}\n评级: ${dealForm.gradingCompany ? dealForm.gradingCompany + ' ' + dealForm.gradingScore : '未评级'}`, deal_price: parseFloat(dealForm.price), deal_date: dealForm.date, diff --git a/frontend/src/pages/Home.jsx b/frontend/src/pages/Home.jsx index 90c9aab..f6912a9 100644 --- a/frontend/src/pages/Home.jsx +++ b/frontend/src/pages/Home.jsx @@ -174,32 +174,58 @@ export default function Home() {