feat: 发帖去身份用昵称、标签对齐筛选、图片限2、无类型任务也留痕

- 发帖去掉「发布身份」选择,统一用发布者昵称(后端按 user 取昵称)
- 发帖标签改成 晒宠/新手求助/经验,和社区顶部筛选完全一致;
  tabTag 新手求助→新手求助(原来映射成「求助」对不上)
- 内容输入框:点整块 field 都聚焦(原生 textarea 在 scroll-view 里
  命中区域会偏,只有 placeholder 处能点)
- 发帖图片上限 3→2,文案标注「最多 2 张」
- 无记录类型的自定义任务完成后,补一条 note 记录,最近记录里留痕

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Blizzard
2026-07-31 14:12:52 +08:00
parent b52729dec8
commit a91f5e39ca
4 changed files with 34 additions and 37 deletions
@@ -43,8 +43,8 @@ const REMINDER_TYPES = [
const REMINDER_LABELS = REMINDER_TYPES.map((t) => t.label);
const IDENTITY = ['petName', 'anonymous', 'official'];
const PTAG = ['晒宠', '求助', '经验', '避坑'];
// 标签和社区顶部筛选保持一致(晒宠 / 新手求助 / 经验)
const PTAG = ['晒宠', '新手求助', '经验'];
Component({
options: { addGlobalClass: true },
@@ -61,6 +61,7 @@ Component({
optSel: {},
// 通用简易记录(洗护/清洁那 15 种共用)
postContent: '',
pfFocus: false, // 发帖内容框聚焦标记(点整块 field 聚焦用)
postImages: [],
remForm: { id: '', typeIdx: 0, title: '', date: '', freq: '' },
remTypeLabels: REMINDER_LABELS,
@@ -345,6 +346,9 @@ Component({
this.setData({ optSel });
},
onPostInput(e) { this.setData({ postContent: e.detail.value }); },
// 点内容 field 任意处都聚焦(原生 textarea 在 scroll-view 里命中区域会偏)
onPostFieldTap() { this.setData({ pfFocus: true }); },
onPostBlur() { this.setData({ pfFocus: false }); },
loadComments() {
if (!this.data.postId) return;
api.listComments(this.data.postId)
@@ -539,8 +543,8 @@ Component({
api.getTasks(id).then((tasks) => this.setData({ manageTasks: tasks || [] })).catch(() => {});
},
onPickPostImages() {
const left = 3 - this.data.postImages.length;
if (left <= 0) return wx.showToast({ title: '最多 3 张', icon: 'none' });
const left = 2 - this.data.postImages.length;
if (left <= 0) return wx.showToast({ title: '最多 2 张', icon: 'none' });
upload
.chooseAndUploadImages(left)
.then((list) => this.setData({ postImages: this.data.postImages.concat(list) }))
@@ -604,14 +608,13 @@ Component({
async onCreatePost() {
const content = (this.data.postContent || '').trim();
if (!content) return wx.showToast({ title: '写点什么吧', icon: 'none' });
const identity = IDENTITY[this.segIdx('ident')];
const tag = PTAG[this.data.optSel.ptag === undefined ? 0 : this.data.optSel.ptag];
if (this.data.saving) return;
this.setData({ saving: true });
try {
// 去掉发布身份,统一用发布者昵称(后端按 user 取昵称)
const post = await api.createPost({
pet_id: identity === 'petName' ? store.currentPetId() : null,
identity,
identity: 'user',
content,
tags: [tag],
image_file_ids: this.data.postImages.map((i) => i.id),