v0.1.2 - 创建群表单新增6个必填字段

This commit is contained in:
甲辰生产 2026-04-30 21:36:02 +08:00
parent a31d6cc153
commit f695dfbfa0
5 changed files with 128 additions and 16 deletions

View File

@ -16,10 +16,12 @@ router = APIRouter(prefix="/api/purchase", tags=["认购"])
# ============ Schema ============
class PurchaseGroupCreate(BaseModel):
cycle_months: Optional[int] = None
start_date: Optional[str] = None
name: str
description: Optional[str] = None
description: str
total_members: int
total_collections: int
cycle_months: int
start_date: str
class PurchaseGroupResponse(BaseModel):
cycle_months: Optional[int] = None
@ -238,6 +240,8 @@ def create_group(
creator_id=current_user.f99_90_id,
creator_name=current_user.f01_01_name,
status="active",
total_members=data.total_members,
total_collections=data.total_collections,
cycle_months=data.cycle_months,
start_date=start_date
)

View File

@ -1,5 +1,23 @@
# 版本更新记录
## v0.1.2 (2026-04-30)
### 前端更新
- **Home.jsx**
- 修复:我的认购入口字体颜色改为蓝色 #3b82f6
- **Purchase.jsx**
- 新增创建群表单6个必填字段
- 认购群名称
- 认购介绍(群介绍)
- 参与人数
- 总认购数
- 认购周期(月)
- 开始日期
### 后端更新
- **purchase.py**
- 新增:创建群接口支持新字段 total_members、total_collections
## v0.0.12 (2026-04-29)
### 前端更新

View File

@ -1,16 +1,16 @@
{
"version": "0.1.1",
"updated": "2026-04-29",
"version": "0.1.2",
"updated": "2026-04-30",
"modules": {
"frontend": {
"version": "0.1.1",
"version": "0.1.2",
"pages": {
"Home": "0.1.0",
"Purchase": "0.1.2"
"Purchase": "0.0.2"
}
},
"backend": {
"version": "0.1.1",
"version": "0.1.2",
"routers": {
"purchase": "0.1.0"
},

View File

@ -238,7 +238,7 @@ export default function Home() {
justifyContent: 'center',
textAlign: 'center'
}}>
<div style={{ color: '#ec4899', fontSize: '18px', fontWeight: '600', whiteSpace: 'nowrap' }}>我的认购</div>
<div style={{ color: '#3b82f6', fontSize: '18px', fontWeight: '600', whiteSpace: 'nowrap' }}>我的认购</div>
<div style={{ color: 'rgba(255,255,255,0.5)', fontSize: '10px', marginTop: '2px' }}>认购群入口</div>
</div>
</div>

View File

@ -1,7 +1,8 @@
/**
* Purchase - 我的认购/团购页面
* Version: 0.0.1 (2026-04-24)
* Version: 0.0.2 (2026-04-30)
* 认购群管理加入查看详情
* 更新创建群表单新增6个字段群名介绍人数总数周期开始日期
*/
import React, { useState, useEffect } from 'react'
@ -19,7 +20,14 @@ function Purchase() {
const [groupMembers, setGroupMembers] = useState([])
const [groupCollections, setGroupCollections] = useState([])
const [showCollectionForm, setShowCollectionForm] = useState(false)
const [newGroup, setNewGroup] = useState({ name: '', description: '' })
const [newGroup, setNewGroup] = useState({
name: '',
description: '',
total_members: '',
total_collections: '',
cycle_months: '',
start_date: ''
})
const [newCollection, setNewCollection] = useState({ number: 'J0________', price: '' })
const [loading, setLoading] = useState(true)
const [activeTab, setActiveTab] = useState('my') // my/all
@ -61,6 +69,11 @@ function Purchase() {
const token = localStorage.getItem('token')
if (!token) { alert('请先登录'); return }
if (!newGroup.name.trim()) { alert('请输入认购群名称'); return }
if (!newGroup.description.trim()) { alert('请输入认购介绍'); return }
if (!newGroup.total_members) { alert('请输入参与人数'); return }
if (!newGroup.total_collections) { alert('请输入总认购数'); return }
if (!newGroup.cycle_months) { alert('请输入认购周期'); return }
if (!newGroup.start_date) { alert('请选择开始日期'); return }
try {
const res = await fetch(`${API_BASE}/api/purchase/groups`, {
@ -75,7 +88,7 @@ function Purchase() {
if (res.ok) {
alert('创建成功!')
setShowCreate(false)
setNewGroup({ name: '', description: '' })
setNewGroup({ name: '', description: '', total_members: '', total_collections: '', cycle_months: '', start_date: '' })
fetchGroups()
} else {
alert(data.detail || '创建失败')
@ -749,10 +762,12 @@ function Purchase() {
maxWidth: '400px'
}}>
<div style={{ fontSize: '18px', fontWeight: 'bold', marginBottom: '16px' }}>创建认购群</div>
{/* 1. 认购群名称 */}
<input
value={newGroup.name}
onChange={(e) => setNewGroup({...newGroup, name: e.target.value})}
placeholder="认购群名称"
placeholder="* 认购群名称"
style={{
width: '100%',
background: 'rgba(255,255,255,0.1)',
@ -764,11 +779,13 @@ function Purchase() {
marginBottom: '12px'
}}
/>
{/* 2. 认购介绍 */}
<textarea
value={newGroup.description}
onChange={(e) => setNewGroup({...newGroup, description: e.target.value})}
placeholder="描述(可选"
rows={3}
placeholder="* 认购介绍(群介绍"
rows={2}
style={{
width: '100%',
background: 'rgba(255,255,255,0.1)',
@ -777,10 +794,83 @@ function Purchase() {
padding: '12px',
color: '#fff',
fontSize: '14px',
marginBottom: '16px',
marginBottom: '12px',
resize: 'none'
}}
/>
{/* 3. 参与人数 */}
<input
type="number"
value={newGroup.total_members}
onChange={(e) => setNewGroup({...newGroup, total_members: e.target.value})}
placeholder="* 参与人数"
style={{
width: '100%',
background: 'rgba(255,255,255,0.1)',
border: '1px solid rgba(255,255,255,0.2)',
borderRadius: '8px',
padding: '12px',
color: '#fff',
fontSize: '14px',
marginBottom: '12px'
}}
/>
{/* 4. 总认购数 */}
<input
type="number"
value={newGroup.total_collections}
onChange={(e) => setNewGroup({...newGroup, total_collections: e.target.value})}
placeholder="* 总认购数"
style={{
width: '100%',
background: 'rgba(255,255,255,0.1)',
border: '1px solid rgba(255,255,255,0.2)',
borderRadius: '8px',
padding: '12px',
color: '#fff',
fontSize: '14px',
marginBottom: '12px'
}}
/>
{/* 5. 认购周期 */}
<input
type="number"
value={newGroup.cycle_months}
onChange={(e) => setNewGroup({...newGroup, cycle_months: e.target.value})}
placeholder="* 认购周期(月)"
style={{
width: '100%',
background: 'rgba(255,255,255,0.1)',
border: '1px solid rgba(255,255,255,0.2)',
borderRadius: '8px',
padding: '12px',
color: '#fff',
fontSize: '14px',
marginBottom: '12px'
}}
/>
{/* 6. 开始日期 */}
<input
type="date"
value={newGroup.start_date}
onChange={(e) => setNewGroup({...newGroup, start_date: e.target.value})}
placeholder="* 开始日期"
style={{
width: '100%',
background: 'rgba(255,255,255,0.1)',
border: '1px solid rgba(255,255,255,0.2)',
borderRadius: '8px',
padding: '12px',
color: '#fff',
fontSize: '14px',
marginBottom: '16px'
}}
/>
<div style={{ display: 'flex', gap: '8px' }}>
<button
onClick={() => setShowCreate(false)}