寻号功能完善v1.2.20:
1. 发布寻号面板去掉类型、匹配度字段 2. 标题移到正文前面 3. 联系方式默认***隐藏 4. 增加匹配状态按钮 5. 增加匹配并联系藏友、留言藏友按钮 6. 留言功能完善,留言后自动刷新 7. 记住用户浏览的标签页
This commit is contained in:
parent
ce08c68d04
commit
2cd90a0604
4
VERSION
4
VERSION
|
|
@ -1,2 +1,2 @@
|
||||||
VERSION=1.2.18
|
VERSION=1.2.19
|
||||||
# 2026-03-27 寻号功能基础版:寻配号发布、自动配号匹配、我的寻号列表编辑
|
# 2026-03-28 寻号功能增强:去掉类型匹配度字段,标题在正文前面,联系方式***隐藏,匹配状态按钮,留言功能
|
||||||
|
|
|
||||||
|
|
@ -195,7 +195,7 @@ class Information(Base):
|
||||||
created_at = Column(DateTime(timezone=True), server_default=func.now(), index=True)
|
created_at = Column(DateTime(timezone=True), server_default=func.now(), index=True)
|
||||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
||||||
|
|
||||||
user = relationship("User")
|
user = relationship("User", foreign_keys=[user_id])
|
||||||
collection = relationship("Collection")
|
collection = relationship("Collection")
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -209,7 +209,7 @@ class InformationComment(Base):
|
||||||
content = Column(Text, nullable=False)
|
content = Column(Text, nullable=False)
|
||||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||||
|
|
||||||
user = relationship("User")
|
user = relationship("User", foreign_keys=[user_id])
|
||||||
|
|
||||||
|
|
||||||
# 资讯联系方式查看记录
|
# 资讯联系方式查看记录
|
||||||
|
|
@ -221,7 +221,7 @@ class InformationContactView(Base):
|
||||||
viewer_id = Column(String(36), ForeignKey("users.f99_90_id", ondelete="CASCADE"), nullable=False, index=True)
|
viewer_id = Column(String(36), ForeignKey("users.f99_90_id", ondelete="CASCADE"), nullable=False, index=True)
|
||||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||||
|
|
||||||
viewer = relationship("User")
|
viewer = relationship("User", foreign_keys=[viewer_id])
|
||||||
|
|
||||||
|
|
||||||
# 资讯关联用户 (收藏/点赞)
|
# 资讯关联用户 (收藏/点赞)
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,8 @@ class InformationResponse(BaseModel):
|
||||||
deal_price: Optional[float]
|
deal_price: Optional[float]
|
||||||
deal_date: Optional[date]
|
deal_date: Optional[date]
|
||||||
status: str
|
status: str
|
||||||
|
is_matched: str = "pending"
|
||||||
|
matched_user_id: Optional[str] = None
|
||||||
view_count: int
|
view_count: int
|
||||||
contact_count: int
|
contact_count: int
|
||||||
created_at: datetime
|
created_at: datetime
|
||||||
|
|
@ -126,6 +128,8 @@ def get_information_list(
|
||||||
deal_price=item.deal_price,
|
deal_price=item.deal_price,
|
||||||
deal_date=item.deal_date,
|
deal_date=item.deal_date,
|
||||||
status=item.status,
|
status=item.status,
|
||||||
|
is_matched=item.is_matched,
|
||||||
|
matched_user_id=item.matched_user_id,
|
||||||
view_count=item.view_count,
|
view_count=item.view_count,
|
||||||
contact_count=item.contact_count,
|
contact_count=item.contact_count,
|
||||||
created_at=item.created_at,
|
created_at=item.created_at,
|
||||||
|
|
@ -530,6 +534,8 @@ def get_my_seeks(
|
||||||
deal_price=item.deal_price,
|
deal_price=item.deal_price,
|
||||||
deal_date=item.deal_date,
|
deal_date=item.deal_date,
|
||||||
status=item.status,
|
status=item.status,
|
||||||
|
is_matched=item.is_matched,
|
||||||
|
matched_user_id=item.matched_user_id,
|
||||||
view_count=item.view_count,
|
view_count=item.view_count,
|
||||||
contact_count=item.contact_count,
|
contact_count=item.contact_count,
|
||||||
created_at=item.created_at,
|
created_at=item.created_at,
|
||||||
|
|
@ -643,6 +649,8 @@ def get_my_information_list(
|
||||||
deal_price=item.deal_price,
|
deal_price=item.deal_price,
|
||||||
deal_date=item.deal_date,
|
deal_date=item.deal_date,
|
||||||
status=item.status,
|
status=item.status,
|
||||||
|
is_matched=item.is_matched,
|
||||||
|
matched_user_id=item.matched_user_id,
|
||||||
view_count=item.view_count,
|
view_count=item.view_count,
|
||||||
contact_count=item.contact_count,
|
contact_count=item.contact_count,
|
||||||
created_at=item.created_at,
|
created_at=item.created_at,
|
||||||
|
|
@ -760,3 +768,27 @@ def add_comment(
|
||||||
"created_at": comment.created_at
|
"created_at": comment.created_at
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# ============ 获取评论列表 ============
|
||||||
|
@router.get("/comments/{information_id}")
|
||||||
|
def get_comments(
|
||||||
|
information_id: str,
|
||||||
|
db: Session = Depends(get_db)
|
||||||
|
):
|
||||||
|
"""获取资讯的评论列表"""
|
||||||
|
from app.models.models import InformationComment
|
||||||
|
comments = db.query(InformationComment).filter(
|
||||||
|
InformationComment.information_id == information_id
|
||||||
|
).order_by(InformationComment.created_at.desc()).all()
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"id": c.id,
|
||||||
|
"content": c.content,
|
||||||
|
"user_name": c.user.f01_01_name if c.user else '匿名用户',
|
||||||
|
"user_avatar": c.user.avatar if c.user else None,
|
||||||
|
"created_at": c.created_at
|
||||||
|
}
|
||||||
|
for c in comments
|
||||||
|
]
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
VERSION=1.2.17
|
VERSION=1.2.19
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'
|
||||||
|
|
||||||
// 资讯页面 - 展示寻配号和行情信息(所有人可见)
|
// 资讯页面 - 展示寻配号和行情信息(所有人可见)
|
||||||
export default function News() {
|
export default function News() {
|
||||||
const [activeTab, setActiveTab] = useState('deal')
|
const [activeTab, setActiveTab] = useState(localStorage.getItem('news_activeTab') || 'seek')
|
||||||
const [showSeekPublish, setShowSeekPublish] = useState(false)
|
const [showSeekPublish, setShowSeekPublish] = useState(false)
|
||||||
const [showMySeeks, setShowMySeeks] = useState(false) // 我的寻号
|
const [showMySeeks, setShowMySeeks] = useState(false) // 我的寻号
|
||||||
const [showContactId, setShowContactId] = useState(null) // 显示联系方式的寻号ID
|
const [showContactId, setShowContactId] = useState(null) // 显示联系方式的寻号ID
|
||||||
|
|
@ -56,7 +56,7 @@ export default function News() {
|
||||||
|
|
||||||
// 获取寻号评论
|
// 获取寻号评论
|
||||||
const fetchComments = async (infoId) => {
|
const fetchComments = async (infoId) => {
|
||||||
if (comments[infoId]) return; // 已加载则跳过
|
// 每次都重新获取评论
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${API_BASE}/api/information/comments/${infoId}`)
|
const res = await fetch(`${API_BASE}/api/information/comments/${infoId}`)
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
|
|
@ -78,13 +78,27 @@ export default function News() {
|
||||||
body: JSON.stringify({ information_id: infoId, content: commentText })
|
body: JSON.stringify({ information_id: infoId, content: commentText })
|
||||||
})
|
})
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
if (data.message === '留言成功') {
|
if (data.message === '留言成功' || data.message === '评论成功') {
|
||||||
setCommentText('')
|
setCommentText('')
|
||||||
setComments(prev => ({...prev, [infoId]: [...(prev[infoId] || []), data.comment]}))
|
// 强制刷新评论列表,先清空缓存
|
||||||
|
setComments(prev => {
|
||||||
|
const newComments = {...prev}
|
||||||
|
delete newComments[infoId]
|
||||||
|
return newComments
|
||||||
|
})
|
||||||
|
// 然后重新获取
|
||||||
|
setTimeout(() => fetchComments(infoId), 100)
|
||||||
|
// 确保停留在寻号 tab
|
||||||
|
if (activeTab !== 'seek') {
|
||||||
|
setActiveTab('seek')
|
||||||
|
}
|
||||||
alert('留言成功!')
|
alert('留言成功!')
|
||||||
|
} else {
|
||||||
|
alert(data.detail || '留言失败')
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
alert('留言失败: ' + e.message)
|
console.error('留言失败:', e)
|
||||||
|
alert('留言失败,请重试')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -214,7 +228,7 @@ export default function News() {
|
||||||
{tabs.map(tab => (
|
{tabs.map(tab => (
|
||||||
<div
|
<div
|
||||||
key={tab.key}
|
key={tab.key}
|
||||||
onClick={() => setActiveTab(tab.key)}
|
onClick={() => { setActiveTab(tab.key); localStorage.setItem('news_activeTab', tab.key); }}
|
||||||
style={{
|
style={{
|
||||||
padding: '10px 20px',
|
padding: '10px 20px',
|
||||||
borderRadius: '8px',
|
borderRadius: '8px',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue