v1.2.24 - 登录状态优化(基于最新代码)+ 行情管理优化
This commit is contained in:
parent
79f2f2e2f8
commit
27e14270a3
3
VERSION
3
VERSION
|
|
@ -1,2 +1 @@
|
||||||
VERSION=1.2.19
|
VERSION=1.2.24
|
||||||
# 2026-03-28 寻号功能增强:去掉类型匹配度字段,标题在正文前面,联系方式***隐藏,匹配状态按钮,留言功能
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
VERSION=1.2.19
|
VERSION=1.2.24
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
import React, { useState, useEffect } from 'react'
|
import React, { useState, useEffect } from 'react'
|
||||||
|
|
||||||
export default function Info() {
|
export default function Info() {
|
||||||
const [activeTab, setActiveTab] = useState('deal')
|
const [activeTab, setActiveTab] = useState('publish')
|
||||||
const [showPublish, setShowPublish] = useState(false)
|
const [showPublish, setShowPublish] = useState(false)
|
||||||
const [myList, setMyList] = useState([])
|
const [myList, setMyList] = useState([])
|
||||||
const [listFilter, setListFilter] = useState('all')
|
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const [editingItem, setEditingItem] = useState(null)
|
const [editingItem, setEditingItem] = useState(null)
|
||||||
|
|
||||||
|
|
@ -14,21 +13,15 @@ export default function Info() {
|
||||||
// content使用原生DOM
|
// content使用原生DOM
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (activeTab === 'deal') fetchMyList()
|
if (activeTab === 'manage') fetchMyList()
|
||||||
}, [activeTab])
|
}, [activeTab])
|
||||||
|
|
||||||
// Auto-fetch on mount (only if logged in)
|
|
||||||
useEffect(() => {
|
|
||||||
const token = localStorage.getItem('token')
|
|
||||||
if (token) fetchMyList()
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
// 自动生成标题
|
// 自动生成标题
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
const date = `${now.getFullYear()}/${now.getMonth() + 1}/${now.getDate()}`
|
const date = `${now.getFullYear()}/${now.getMonth() + 1}/${now.getDate()}`
|
||||||
const gradeNote = formData.isGraded ? '(评级币)' : '(裸钞)'
|
const gradeNote = formData.isGraded ? '(评级币)' : '(裸钞)'
|
||||||
const title = `「${date} ${formData.edition} ${formData.type} ${formData.category} ${gradeNote}」`
|
const title = `「${date} ${formData.edition} ${formData.type} ${formData.category} 行情信息${gradeNote}」`
|
||||||
setFormData(prev => ({...prev, title}))
|
setFormData(prev => ({...prev, title}))
|
||||||
}, [formData.edition, formData.type, formData.isGraded, formData.category])
|
}, [formData.edition, formData.type, formData.isGraded, formData.category])
|
||||||
|
|
||||||
|
|
@ -50,7 +43,7 @@ export default function Info() {
|
||||||
const token = localStorage.getItem('token')
|
const token = localStorage.getItem('token')
|
||||||
const res = await fetch(`${API_BASE}/api/information/`, {
|
const res = await fetch(`${API_BASE}/api/information/`, {
|
||||||
method: 'POST', headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' },
|
method: 'POST', headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ title: formData.title, content: document.getElementById('publishContent')?.value || '', info_type: 'deal' })
|
body: JSON.stringify({ title: formData.title, content: document.getElementById('publishContent')?.value || '', info_type: formData.category === '成交' ? 'deal' : 'seek' })
|
||||||
})
|
})
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
if (data.id || data.code === 0) {
|
if (data.id || data.code === 0) {
|
||||||
|
|
@ -117,8 +110,16 @@ export default function Info() {
|
||||||
return (
|
return (
|
||||||
<div style={{ minHeight: '100vh', background: 'linear-gradient(180deg, #0f172a 0%, #1e293b 100%)', paddingBottom: '80px' }}>
|
<div style={{ minHeight: '100vh', background: 'linear-gradient(180deg, #0f172a 0%, #1e293b 100%)', paddingBottom: '80px' }}>
|
||||||
{/* 顶部标签 */}
|
{/* 顶部标签 */}
|
||||||
<div style={{ padding: '16px 20px', borderBottom: '1px solid #1e293b' }}>
|
<div style={{ position: 'sticky', top: 0, background: 'rgba(15,23,42,0.95)', backdropFilter: 'blur(10px)', padding: '16px 20px', borderBottom: '1px solid #1e293b', zIndex: 100 }}>
|
||||||
<h2 style={{ color: '#fff', margin: 0, fontSize: '18px' }}>💰 行情管理</h2>
|
<div style={{ display: 'flex', gap: '8px', background: '#1e293b', borderRadius: '12px', padding: '4px' }}>
|
||||||
|
{[{ key: 'publish', label: '📝 寻配号发布' }, { key: 'manage', label: '📋 发布管理' }].map(t => (
|
||||||
|
<div key={t.key} onClick={() => setActiveTab(t.key)}
|
||||||
|
style={{ flex: 1, padding: '12px 16px', borderRadius: '10px', background: activeTab === t.key ? 'linear-gradient(135deg, #3b82f6 0%, #2563eb 100%)' : 'transparent',
|
||||||
|
color: activeTab === t.key ? '#fff' : '#9ca3af', cursor: 'pointer', textAlign: 'center', fontSize: '14px', fontWeight: '600', transition: 'all 0.3s' }}>
|
||||||
|
{t.label}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style={{ padding: '20px' }}>
|
<div style={{ padding: '20px' }}>
|
||||||
|
|
@ -132,7 +133,7 @@ export default function Info() {
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* 发布管理 */}
|
{/* 发布管理 */}
|
||||||
{true && (
|
{activeTab === 'manage' && (
|
||||||
<div>
|
<div>
|
||||||
<Card title="📋 发布管理">
|
<Card title="📋 发布管理">
|
||||||
<div style={{ marginBottom: '16px' }}>
|
<div style={{ marginBottom: '16px' }}>
|
||||||
|
|
@ -172,7 +173,7 @@ export default function Info() {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<BtnGroup label="分类" options={[
|
<BtnGroup label="分类" options={[
|
||||||
{ value: '求购', label: '🔍 求购' }, { value: '出售', label: '💰 出售' }, { value: '成交', label: '📈 成交' }
|
{ value: '成交', label: '💰 成交' }, { value: '求购', label: '🔍 求购' }, { value: '出售', label: '💵 出售' }
|
||||||
]} value={formData.category} onChange={v => setFormData({...formData, category: v})} />
|
]} value={formData.category} onChange={v => setFormData({...formData, category: v})} />
|
||||||
|
|
||||||
<div style={{ marginBottom: '16px' }}>
|
<div style={{ marginBottom: '16px' }}>
|
||||||
|
|
@ -201,18 +202,12 @@ export default function Info() {
|
||||||
<div style={{ color: '#9ca3af', textAlign: 'center', padding: '30px', fontSize: '14px' }}>暂无发布记录</div>
|
<div style={{ color: '#9ca3af', textAlign: 'center', padding: '30px', fontSize: '14px' }}>暂无发布记录</div>
|
||||||
) : (
|
) : (
|
||||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
|
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
|
||||||
<div style={{ display: 'flex', gap: '8px', marginBottom: '16px' }}>
|
{myList.map(item => (
|
||||||
<button onClick={() => setListFilter('deal')} style={{ padding: '8px 16px', background: listFilter === 'all' ? '#3b82f6' : '#374151', border: 'none', borderRadius: '6px', color: '#fff', fontSize: '13px' }}>全部</button>
|
|
||||||
<button onClick={() => setListFilter('seek')} style={{ padding: '8px 16px', background: listFilter === 'seek' ? '#3b82f6' : '#374151', border: 'none', borderRadius: '6px', color: '#fff', fontSize: '13px' }}>🔍 寻号</button>
|
|
||||||
<button onClick={() => setListFilter('deal')} style={{ padding: '8px 16px', background: listFilter === 'deal' ? '#10b981' : '#374151', border: 'none', borderRadius: '6px', color: '#fff', fontSize: '13px' }}>💰 行情</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{myList.filter(i => listFilter === 'all' || i.info_type === listFilter).map(item => (
|
|
||||||
<div key={item.id} style={{ background: '#0f172a', borderRadius: '12px', padding: '16px', border: '1px solid #374151' }}>
|
<div key={item.id} style={{ background: '#0f172a', borderRadius: '12px', padding: '16px', border: '1px solid #374151' }}>
|
||||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', marginBottom: '8px' }}>
|
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', marginBottom: '8px' }}>
|
||||||
<div style={{ color: '#10b981', fontSize: '15px', fontWeight: '600', flex: 1 }}>{item.title}</div>
|
<div style={{ color: '#10b981', fontSize: '15px', fontWeight: '600', flex: 1 }}>{item.title}</div>
|
||||||
<span style={{ background: item.info_type === 'deal' ? 'rgba(16,185,129,0.2)' : 'rgba(59,130,246,0.2)', color: item.info_type === 'deal' ? '#10b981' : '#3b82f6', padding: '4px 10px', borderRadius: '20px', fontSize: '12px' }}>
|
<span style={{ background: item.info_type === 'deal' ? 'rgba(16,185,129,0.2)' : 'rgba(59,130,246,0.2)', color: item.info_type === 'deal' ? '#10b981' : '#3b82f6', padding: '4px 10px', borderRadius: '20px', fontSize: '12px' }}>
|
||||||
{item.info_type === 'deal' ? '💰 行情' : '🔍 求购'}
|
{item.info_type === 'deal' ? '💰 成交' : '🔍 求购'}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{item.content && <div style={{ color: '#9ca3af', fontSize: '13px', marginBottom: '12px', lineHeight: '1.5' }}>{item.content}</div>}
|
{item.content && <div style={{ color: '#9ca3af', fontSize: '13px', marginBottom: '12px', lineHeight: '1.5' }}>{item.content}</div>}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import React, { useState, useEffect } from 'react'
|
||||||
export default function News() {
|
export default function News() {
|
||||||
const [activeTab, setActiveTab] = useState(localStorage.getItem('news_activeTab') || 'seek')
|
const [activeTab, setActiveTab] = useState(localStorage.getItem('news_activeTab') || 'seek')
|
||||||
const [showSeekPublish, setShowSeekPublish] = useState(false)
|
const [showSeekPublish, setShowSeekPublish] = useState(false)
|
||||||
const [customModal, setCustomModal] = useState({show: false, title: '', content: ''})
|
|
||||||
const [showMySeeks, setShowMySeeks] = useState(false) // 我的寻号
|
const [showMySeeks, setShowMySeeks] = useState(false) // 我的寻号
|
||||||
const [showContactId, setShowContactId] = useState(null) // 显示联系方式的寻号ID
|
const [showContactId, setShowContactId] = useState(null) // 显示联系方式的寻号ID
|
||||||
const [showCommentId, setShowCommentId] = useState(null) // 显示评论输入的寻号ID
|
const [showCommentId, setShowCommentId] = useState(null) // 显示评论输入的寻号ID
|
||||||
|
|
@ -118,7 +117,7 @@ export default function News() {
|
||||||
if (data.message === '匹配成功,已通知发布者') {
|
if (data.message === '匹配成功,已通知发布者') {
|
||||||
setMatchedStatus(prev => ({...prev, [infoId]: 'matched'}))
|
setMatchedStatus(prev => ({...prev, [infoId]: 'matched'}))
|
||||||
setShowContactId(infoId) // 显示联系方式
|
setShowContactId(infoId) // 显示联系方式
|
||||||
setCustomModal({show: true, title: '匹配成功', content: '已通知发布者,请等待对方联系'})
|
alert('匹配成功!')
|
||||||
fetchInfoList() // 刷新列表
|
fetchInfoList() // 刷新列表
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
@ -131,7 +130,7 @@ export default function News() {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${API_BASE}/api/information/seek/matched-user/${infoId}`, { headers: { Authorization: `Bearer ${token}` } })
|
const res = await fetch(`${API_BASE}/api/information/seek/matched-user/${infoId}`, { headers: { Authorization: `Bearer ${token}` } })
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
if (data.matched_user_id) setCustomModal({show: true, title: '匹配者信息', content: `用户名: ${data.user_name}\n联系方式: ${data.matched_contact || '未提供'}`})
|
if (data.matched_user_id) alert(`匹配者: ${data.user_name}, 联系方式: ${data.matched_contact || '未提供'}`)
|
||||||
} catch (e) { console.error(e) }
|
} catch (e) { console.error(e) }
|
||||||
}
|
}
|
||||||
const fetchPublisherInfo = async (infoId) => {
|
const fetchPublisherInfo = async (infoId) => {
|
||||||
|
|
@ -140,7 +139,7 @@ export default function News() {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${API_BASE}/api/information/seek/publisher/${infoId}`, { headers: { Authorization: `Bearer ${token}` } })
|
const res = await fetch(`${API_BASE}/api/information/seek/publisher/${infoId}`, { headers: { Authorization: `Bearer ${token}` } })
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
if (data.user_id) setCustomModal({show: true, title: '发布者信息', content: `用户名: ${data.user_name}\n联系方式: ${data.contact || '未提供'}`})
|
if (data.user_id) alert(`发布者: ${data.user_name}, 联系方式: ${data.contact || '未提供'}`)
|
||||||
} catch (e) { console.error(e) }
|
} catch (e) { console.error(e) }
|
||||||
}
|
}
|
||||||
const fetchMatchCollections = async (infoId) => {
|
const fetchMatchCollections = async (infoId) => {
|
||||||
|
|
@ -250,7 +249,7 @@ export default function News() {
|
||||||
})
|
})
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
if (data.id || data.code === 0) {
|
if (data.id || data.code === 0) {
|
||||||
setCustomModal({show: true, title: '发布成功', content: '您的寻配号信息已发布成功'})
|
alert('发布成功!')
|
||||||
setShowSeekPublish(false)
|
setShowSeekPublish(false)
|
||||||
setSeekForm({ edition: '龙钞', type: '', category: '寻号', price: '', matchType: '模糊', features: '', content: '', title: '', contact: (() => { try { const u = JSON.parse(localStorage.getItem('user') || '{}'); return u.phone || '' } catch { return '' } })() || '' })
|
setSeekForm({ edition: '龙钞', type: '', category: '寻号', price: '', matchType: '模糊', features: '', content: '', title: '', contact: (() => { try { const u = JSON.parse(localStorage.getItem('user') || '{}'); return u.phone || '' } catch { return '' } })() || '' })
|
||||||
fetchInfoList()
|
fetchInfoList()
|
||||||
|
|
@ -505,7 +504,7 @@ export default function News() {
|
||||||
: 1
|
: 1
|
||||||
}}>
|
}}>
|
||||||
{(item.is_matched === 'matched' || matchedStatus[item.id] === 'matched') ? '已经匹配' : '尚未匹配'}
|
{(item.is_matched === 'matched' || matchedStatus[item.id] === 'matched') ? '已经匹配' : '尚未匹配'}
|
||||||
{(item.is_matched === 'matched' || matchedStatus[item.id] === 'matched') && <button onClick={() => { if(item.user_id === currentUserId) fetchMatchedUserInfo(item.id); else if(item.matched_user_id === currentUserId) fetchPublisherInfo(item.id) }} style={{padding:'4px 10px',borderRadius:'4px',fontSize:'12px',background:(item.user_id === currentUserId || item.matched_user_id === currentUserId) ? '#10b981' : '#6b7280',border:'none',color:(item.user_id === currentUserId || item.matched_user_id === currentUserId) ? '#fb923c' : '#9ca3af',fontWeight:'bold',cursor:(item.user_id === currentUserId || item.matched_user_id === currentUserId) ? 'pointer' : 'not-allowed',marginLeft:'4px'}}>{item.user_id === currentUserId ? '匹配者信息' : '发布者信息'}</button>}
|
{(item.is_matched === 'matched' || matchedStatus[item.id] === 'matched') && <button onClick={() => item.user_id === currentUserId ? fetchMatchedUserInfo(item.id) : fetchPublisherInfo(item.id)} style={{padding:'4px 10px',borderRadius:'4px',fontSize:'12px',background:(item.user_id === currentUserId || item.matched_user_id === currentUserId) ? '#10b981' : '#6b7280',border:'none',color:(item.user_id === currentUserId || item.matched_user_id === currentUserId) ? '#fb923c' : '#9ca3af',fontWeight:'bold',cursor:(item.user_id === currentUserId || item.matched_user_id === currentUserId) ? 'pointer' : 'not-allowed',marginLeft:'4px'}}>{item.user_id === currentUserId ? '匹配者信息' : '发布者信息'}</button>}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
@ -769,24 +768,6 @@ export default function News() {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{customModal.show && (
|
|
||||||
<div style={{position:'fixed',top:0,left:0,right:0,bottom:0,background:'rgba(0,0,0,0.7)',zIndex:2000,display:'flex',alignItems:'center',justifyContent:'center'}}>
|
|
||||||
<div style={{background:'linear-gradient(135deg, #1e293b 0%, #0f172a 100%)',borderRadius:'16px',padding:'24px',width:'85%',maxWidth:'380px',boxShadow:'0 20px 60px rgba(0,0,0,0.5)',border:'1px solid rgba(255,255,255,0.1)'}}>
|
|
||||||
<div style={{textAlign:'center',marginBottom:'20px'}}>
|
|
||||||
<h3 style={{color:'#10b981',fontSize:'20px',fontWeight:'bold',margin:'0'}}>{customModal.title}</h3>
|
|
||||||
</div>
|
|
||||||
<div style={{background:'rgba(0,0,0,0.3)',borderRadius:'12px',padding:'16px',marginBottom:'20px'}}>
|
|
||||||
{customModal.content.split('\n').map((line, i) => (
|
|
||||||
<div key={i} style={{color:'#e2e8f0',fontSize:'15px',lineHeight:'2',display:'flex',justifyContent:'space-between'}}>
|
|
||||||
<span style={{color:'#94a3b8'}}>{line.split(':')[0]}</span>
|
|
||||||
<span style={{color:'#fbbf24',fontWeight:'600'}}>{line.split(':')[1]}</span>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
<button onClick={()=>setCustomModal({...customModal,show:false})} style={{width:'100%',padding:'14px',background:'#10b981',border:'none',borderRadius:'10px',color:'#fff',fontSize:'16px',fontWeight:'bold',cursor:'pointer'}}>知道了</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue