From a0f7a758eb96feac0aa1864ac100b4bcf27579be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=AD=A3=E8=88=AA?= <1915581435@qq.com> Date: Thu, 14 May 2026 21:20:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=A6=96=E9=A1=B5=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=91=E5=B8=83=E7=B1=BB=E5=9E=8B=E9=80=89?= =?UTF-8?q?=E6=8B=A9=EF=BC=88=E5=85=AC=E5=BC=80/=E7=A7=81=E6=9C=89/?= =?UTF-8?q?=E7=A7=81=E4=BF=A1=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 --- miniprogram/pages/home/index.js | 37 ++++++++++++++++++++++++++++--- miniprogram/pages/home/index.wxml | 16 ++++++++++++- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/miniprogram/pages/home/index.js b/miniprogram/pages/home/index.js index 38a19e6..32f3ff1 100644 --- a/miniprogram/pages/home/index.js +++ b/miniprogram/pages/home/index.js @@ -7,13 +7,23 @@ const QUICK_TEXTS = [ '高薪兼职日结,扫码进群立刻赚钱。' ] +const VISIBILITY_OPTIONS = [ + { value: 'public', label: '公开信息发布' }, + { value: 'private', label: '私有信息发布' }, + { value: 'direct', label: '用户私信发布' } +] + Page({ data: { loading: false, user: null, text: '', result: null, - quickTexts: QUICK_TEXTS + quickTexts: QUICK_TEXTS, + visibilityOptions: VISIBILITY_OPTIONS, + visibilityIndex: 0, + visibility: 'public', + recipientUsername: '' }, onShow() { @@ -43,13 +53,20 @@ Page({ }, onInput(e) { - this.setData({ text: e.detail.value || '' }) + const field = e.currentTarget.dataset.field || 'text' + this.setData({ [field]: e.detail.value || '' }) }, fillQuick(e) { this.setData({ text: e.currentTarget.dataset.text || '' }) }, + onVisibilityChange(e) { + const idx = Number(e.detail.value) + const row = this.data.visibilityOptions[idx] || this.data.visibilityOptions[0] + this.setData({ visibilityIndex: idx, visibility: row.value }) + }, + async publish() { if (this.data.loading) return const text = (this.data.text || '').trim() @@ -58,12 +75,26 @@ Page({ return } + const payload = { + text, + visibility: this.data.visibility + } + + if (this.data.visibility === 'direct') { + const receiver = (this.data.recipientUsername || '').trim() + if (!receiver) { + wx.showToast({ title: '私信请填写接收人用户名', icon: 'none' }) + return + } + payload.recipient_username = receiver + } + this.setData({ loading: true }) try { const result = await request({ url: '/content/publish', method: 'POST', - data: { text } + data: payload }) this.setData({ diff --git a/miniprogram/pages/home/index.wxml b/miniprogram/pages/home/index.wxml index 08e0d87..476e092 100644 --- a/miniprogram/pages/home/index.wxml +++ b/miniprogram/pages/home/index.wxml @@ -10,10 +10,24 @@ 内容文本 -