功能基本完善版本 v1.2.22 - 行情管理优化
This commit is contained in:
parent
c7c2ad20f5
commit
79f2f2e2f8
|
|
@ -1,9 +1,10 @@
|
||||||
import React, { useState, useEffect } from 'react'
|
import React, { useState, useEffect } from 'react'
|
||||||
|
|
||||||
export default function Info() {
|
export default function Info() {
|
||||||
const [activeTab, setActiveTab] = useState('publish')
|
const [activeTab, setActiveTab] = useState('deal')
|
||||||
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)
|
||||||
|
|
||||||
|
|
@ -13,15 +14,21 @@ export default function Info() {
|
||||||
// content使用原生DOM
|
// content使用原生DOM
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (activeTab === 'manage') fetchMyList()
|
if (activeTab === 'deal') 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])
|
||||||
|
|
||||||
|
|
@ -43,7 +50,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: formData.category === '成交' ? 'deal' : 'seek' })
|
body: JSON.stringify({ title: formData.title, content: document.getElementById('publishContent')?.value || '', info_type: 'deal' })
|
||||||
})
|
})
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
if (data.id || data.code === 0) {
|
if (data.id || data.code === 0) {
|
||||||
|
|
@ -110,16 +117,8 @@ 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={{ position: 'sticky', top: 0, background: 'rgba(15,23,42,0.95)', backdropFilter: 'blur(10px)', padding: '16px 20px', borderBottom: '1px solid #1e293b', zIndex: 100 }}>
|
<div style={{ padding: '16px 20px', borderBottom: '1px solid #1e293b' }}>
|
||||||
<div style={{ display: 'flex', gap: '8px', background: '#1e293b', borderRadius: '12px', padding: '4px' }}>
|
<h2 style={{ color: '#fff', margin: 0, fontSize: '18px' }}>💰 行情管理</h2>
|
||||||
{[{ 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' }}>
|
||||||
|
|
@ -133,7 +132,7 @@ export default function Info() {
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* 发布管理 */}
|
{/* 发布管理 */}
|
||||||
{activeTab === 'manage' && (
|
{true && (
|
||||||
<div>
|
<div>
|
||||||
<Card title="📋 发布管理">
|
<Card title="📋 发布管理">
|
||||||
<div style={{ marginBottom: '16px' }}>
|
<div style={{ marginBottom: '16px' }}>
|
||||||
|
|
@ -173,7 +172,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' }}>
|
||||||
|
|
@ -202,12 +201,18 @@ 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' }}>
|
||||||
{myList.map(item => (
|
<div style={{ display: 'flex', gap: '8px', marginBottom: '16px' }}>
|
||||||
|
<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>}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue