a88b81d20b
- utils/hall.js(/hall/* /community/* 请求封装)+ styles/hall.scss 共享样式
- 大厅 Hub(四宫格统计入口)、人才大厅列表/详情、岗位大厅列表/详情+投递、
服务大厅列表/详情+咨询
- 社区页(话题筛选帖子流+点赞+发帖)与发帖页;实体社区复用载体列表(parks)
- task-detail/tasks 扩展 register 报名模式(报名走 /hall/tasks/{id}/register)
- 首页新增「大厅」「社区」入口卡;app.config.js 注册 9 个新页面
44 lines
1.9 KiB
React
44 lines
1.9 KiB
React
import { View, Text, Input, Textarea, Button } from '@tarojs/components';
|
|
import Taro from '@tarojs/taro';
|
|
import { useState } from 'react';
|
|
import { communityCreatePost } from '@/utils/hall';
|
|
import { isAuthed } from '@/utils/auth';
|
|
import { PageHeader } from '@/components/TopInset';
|
|
import '@/styles/hall.scss';
|
|
|
|
const TOPICS = ['交流', '求助', '资源', '经验', '公告'];
|
|
|
|
export default function CommunityPost() {
|
|
const [f, setF] = useState({ topic: '交流', title: '', content: '' });
|
|
const [msg, setMsg] = useState('');
|
|
const [busy, setBusy] = useState(false);
|
|
const submit = async () => {
|
|
if (!isAuthed()) { Taro.showToast({ title: '请先登录', icon: 'none' }); return; }
|
|
setBusy(true); setMsg('');
|
|
try {
|
|
await communityCreatePost(f);
|
|
Taro.showToast({ title: '发布成功', icon: 'success' });
|
|
setTimeout(() => Taro.navigateBack(), 800);
|
|
} catch (e) { setMsg((e && e.message) || '发布失败'); }
|
|
finally { setBusy(false); }
|
|
};
|
|
return (
|
|
<View className="hl-pad page-in">
|
|
<PageHeader no="COMM" title="发帖" en="POST" />
|
|
<View className="hl-detail">
|
|
<View className="hl-chips" style={{ padding: 0 }}>
|
|
{TOPICS.map((t) => (
|
|
<Text key={t} className={`hl-chip${f.topic === t ? ' on' : ''}`} onClick={() => setF((s) => ({ ...s, topic: t }))}>{t}</Text>
|
|
))}
|
|
</View>
|
|
<Input className="hl-input" placeholder="标题" value={f.title} onInput={(e) => setF((s) => ({ ...s, title: e.detail.value }))} />
|
|
<Textarea className="hl-textarea" style={{ minHeight: 240 }} placeholder="正文…" value={f.content} onInput={(e) => setF((s) => ({ ...s, content: e.detail.value }))} />
|
|
{msg && <Text className="hl-err">{msg}</Text>}
|
|
<View className="hl-actions">
|
|
<Button className="hl-btn" loading={busy} onClick={submit}>发布</Button>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
);
|
|
}
|