diff --git a/pets-fe/app.json b/pets-fe/app.json index a62a2ad..0698546 100644 --- a/pets-fe/app.json +++ b/pets-fe/app.json @@ -10,16 +10,12 @@ "pages/petform/petform", "pages/idcard/idcard", "pages/report/report", - "pages/community/community", - "pages/comments/comments", "pages/learn/learn", "pages/article/article", "pages/mine/mine", "pages/decorate/decorate", "pages/settings/settings", - "pages/agreement/agreement", - "pages/user/user", - "pages/relations/relations" + "pages/agreement/agreement" ], "window": { "navigationStyle": "custom", @@ -40,10 +36,6 @@ "pagePath": "pages/report/report", "text": "报告" }, - { - "pagePath": "pages/community/community", - "text": "社区" - }, { "pagePath": "pages/mine/mine", "text": "我的" diff --git a/pets-fe/components/bottom-sheet/bottom-sheet.js b/pets-fe/components/bottom-sheet/bottom-sheet.js index 6541fd1..4fcc3a3 100644 --- a/pets-fe/components/bottom-sheet/bottom-sheet.js +++ b/pets-fe/components/bottom-sheet/bottom-sheet.js @@ -17,22 +17,6 @@ function daysLater(n) { // "2026-07-30" → "2026-07-30T12:00:00+08:00" // -// 相对时间。社区里关心的是「多久以前发的」,精确到秒没意义 -function fmtAgo(iso) { - if (!iso) return ''; - const d = new Date(iso); - if (isNaN(d.getTime())) return ''; - const min = Math.floor((Date.now() - d.getTime()) / 60000); - if (min < 1) return '刚刚'; - if (min < 60) return min + ' 分钟前'; - if (min < 60 * 24) return Math.floor(min / 60) + ' 小时前'; - if (min < 60 * 24 * 7) return Math.floor(min / 1440) + ' 天前'; - const p = (n) => (n < 10 ? '0' + n : '' + n); - const sameYear = d.getFullYear() === new Date().getFullYear(); - return (sameYear ? '' : d.getFullYear() + '-') + p(d.getMonth() + 1) + '-' + p(d.getDate()); -} - - // 提醒类型(与后端 model.Reminder* 常量对应) const REMINDER_TYPES = [ { key: 'vaccine', label: '疫苗' }, @@ -43,9 +27,6 @@ const REMINDER_TYPES = [ const REMINDER_LABELS = REMINDER_TYPES.map((t) => t.label); -// 标签和社区顶部筛选保持一致(晒宠 / 新手求助 / 经验) -const PTAG = ['晒宠', '新手求助', '经验']; - Component({ options: { addGlobalClass: true }, properties: { @@ -58,11 +39,6 @@ Component({ innerType: '', pet: {}, segSel: {}, - optSel: {}, - // 通用简易记录(洗护/清洁那 15 种共用) - postContent: '', - pfFocus: false, // 发帖内容框聚焦标记(点整块 field 聚焦用) - postImages: [], remForm: { id: '', typeIdx: 0, title: '', date: '', freq: '' }, remTypeLabels: REMINDER_LABELS, myPets: [], @@ -70,21 +46,12 @@ Component({ fbContent: '', fbContact: '', fbDone: false, - commentText: '', - comments: [], reminders: [], poster: null, reportDetail: null, proInfo: null, saving: false, posterSaving: false, - commentImages: [], - replyTo: {}, - cmFocus: false, - composing: false, // 评论输入面板是否展开(收起时只是一条细条) - sendingComment: false, // 发送+审核在途,防连点 - kbHeight: 0, - total: 0, }, observers: { show: function (show) { @@ -107,22 +74,12 @@ Component({ const patch = { innerType: type, pet }; if (fresh) { patch.segSel = {}; - patch.optSel = {}; - patch.postContent = ''; - patch.postImages = []; patch.medDose = ''; patch.remForm = { id: '', typeIdx: 0, title: '', date: '', freq: '' }; patch.exportText = ''; patch.fbContent = ''; patch.fbContact = ''; patch.fbDone = false; - patch.commentText = ''; - patch.commentImages = []; - patch.replyTo = {}; - patch.cmFocus = false; - patch.composing = false; - patch.sendingComment = false; - patch.kbHeight = 0; patch.saving = false; } this.setData(patch); @@ -138,8 +95,6 @@ Component({ this.loadMyPets(); } else if (type === 'exportData') { this.buildExport(); - } else if (type === 'comments' && this.data.postId) { - this.loadComments(); } else if (type === 'reminders' && id) { this.loadReminders(); } else if (type === 'poster' && id) { @@ -357,54 +312,6 @@ Component({ const segSel = Object.assign({}, this.data.segSel, { [group]: Number(index) }); this.setData({ segSel }); }, - onOpt(e) { - const { group, index } = e.currentTarget.dataset; - const optSel = Object.assign({}, this.data.optSel, { [group]: Number(index) }); - 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) - .then((page) => - this.setData({ - total: page.total || 0, - comments: (page.list || []).map((c) => ({ - ...c, - timeText: fmtAgo(c.created_at), - // 没有头像字段,用昵称首字做个色块,比一律显示同一个 emoji 强 - initial: (c.author_name || '?').slice(0, 1), - imgs: Array.isArray(c.images) ? c.images : [], - replies: (c.replies || []).map((r) => ({ - ...r, - timeText: fmtAgo(r.created_at), - initial: (r.author_name || '?').slice(0, 1), - })), - })), - }), - ) - .catch(() => {}); - }, - // 长按删除自己的评论 - onDeleteComment(e) { - const { id, self } = e.currentTarget.dataset; - if (!id || !self) return; - const c = { id }; - wx.showModal({ - title: '删除评论', - content: '确定删除这条评论?', - confirmColor: '#D9534F', - success: (res) => { - if (!res.confirm) return; - api.deleteComment(c.id) - .then(() => { this.loadComments(); this.triggerEvent('commented'); }) - .catch((err) => wx.showToast({ title: err.message || '删除失败', icon: 'none' })); - }, - }); - }, // ---- 多宠物管理 ---- loadMyPets() { const cur = store.currentPetId(); @@ -559,33 +466,11 @@ Component({ if (!id) return; api.getTasks(id).then((tasks) => this.setData({ manageTasks: tasks || [] })).catch(() => {}); }, - onPickPostImages() { - 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) })) - .catch((e) => { - if (e && e.canceled) return; - wx.showToast({ title: (e && e.message) || '上传失败', icon: 'none' }); - }); - }, - onRemovePostImage(e) { - const i = e.currentTarget.dataset.index; - const arr = this.data.postImages.slice(); - arr.splice(i, 1); - this.setData({ postImages: arr }); - }, - onCommentInput(e) { this.setData({ commentText: e.detail.value }); }, segIdx(group) { const v = this.data.segSel[group]; return v === undefined ? 0 : v; }, - optIdx(group) { - const v = this.data.optSel[group]; - return v === undefined ? 0 : v; - }, // 记录表单整体搬去 pages/addrecord 之后,这里只剩「生成就医前摘要」 // 会往 health_records 写一条 note —— 它是个动作留痕,不是用户填的表单 buildRecord() { @@ -622,139 +507,6 @@ Component({ onSave() { this.createAndClose(this.buildRecord()); }, - async onCreatePost() { - const content = (this.data.postContent || '').trim(); - if (!content) return wx.showToast({ title: '写点什么吧', icon: 'none' }); - 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({ - identity: 'user', - content, - tags: [tag], - image_file_ids: this.data.postImages.map((i) => i.id), - }); - this.triggerEvent('posted'); - this.close(); - // 内容安全审核:没直接过审的,明确告诉用户在审核,别以为发失败/是 bug - if (post && post.status && post.status !== 'published') { - wx.showModal({ - title: '发布成功,审核中', - content: '内容需要通过安全审核后才会出现在社区。可在「我的 → 我的帖子」查看审核状态。', - showCancel: false, - confirmText: '知道了', - }); - } else { - wx.showToast({ title: '已发布', icon: 'success' }); - } - } catch (e) { - wx.showToast({ title: e.message || '发布失败', icon: 'none' }); - this.setData({ saving: false }); - } - }, - - // 评论 - async onSendComment() { - if (this.data.sendingComment) return; // 防连点:审核请求在途时忽略后续点击 - const text = (this.data.commentText || '').trim(); - // 原来空评论会直接把弹层关掉,看起来像发成功了。改成明确提示 - if (!text) return wx.showToast({ title: '写点什么再发', icon: 'none' }); - if (!this.data.postId) return this.close(); - this.setData({ sendingComment: true }); - wx.showLoading({ title: '审核中…', mask: true }); - try { - const res = await api.createComment( - this.data.postId, - text, - this.data.commentImages.map((i) => i.url), - this.data.replyTo.id || '', - ); - wx.hideLoading(); - this.setData({ - commentText: '', commentImages: [], replyTo: {}, - composing: false, cmFocus: false, kbHeight: 0, sendingComment: false, - }); - // 过审即时展示;否则挂在人工/异步图片审核,通过后才出现 - if (res && res.status === 'published') { - this.loadComments(); - this.triggerEvent('commented'); - wx.showToast({ title: '评论成功', icon: 'success' }); - } else { - wx.showToast({ title: '已提交,审核通过后展示', icon: 'none' }); - } - } catch (e) { - wx.hideLoading(); - this.setData({ sendingComment: false }); - // 违规内容后端直接拒收,这里把原因透出来 - wx.showToast({ title: (e && e.message) || '评论失败', icon: 'none' }); - } - }, - - // 评论配图:只允许 1 张 - onPickCommentImages() { - if (this.data.commentImages.length >= 1) { - return wx.showToast({ title: '评论只能配 1 张图', icon: 'none' }); - } - upload - .chooseAndUploadImages(1) - .then((files) => this.setData({ commentImages: (files || []).slice(0, 1) })) - .catch((e) => { - if (e && e.canceled) return; - wx.showToast({ title: (e && e.message) || '上传失败', icon: 'none' }); - }); - }, - // 回复某条评论:输入区顶部显示「回复 xxx」,发送时带上 parent_id - // 小红书那套:点任意一条评论/回复,直接把输入框激活并填上「回复 @xxx」, - // 不用再去底部找输入框、也不用单独点一个「回复」按钮 - onReplyTo(e) { - const { id, name } = e.currentTarget.dataset; - if (!id) return; - // 输入框常驻、属性不变,直接置 focus 拉键盘即可;只填「回复对象」这一个横幅 - this.setData({ replyTo: { id, name }, cmFocus: true }); - }, - onCommentFocus() { - // 只复位一次性 focus 开关。键盘高度交给 onKbChange,用 transform 平移弹层来避让 - this.setData({ cmFocus: false }); - }, - // 键盘高度变化(真机可靠来源)。把高度写进 data, - // wxml 里只用它算 transform 平移量 —— 纯合成层操作,不 reflow、不抖焦点 - onKbChange(e) { - this.setData({ kbHeight: (e.detail && e.detail.height) || 0 }); - }, - onCommentBlur() { - // 失焦不主动清 kbHeight:键盘真正收起时 onKbChange 会回调 0,避免和收键盘动画抢 - this.setData({ cmFocus: false }); - }, - onCancelReply() { - this.setData({ replyTo: {} }); - }, - // 一级评论默认只带 3 条回复,点开拉全量 - onExpandReplies(e) { - const { id, index } = e.currentTarget.dataset; - api - .listReplies(id) - .then((list) => - this.setData({ - [`comments[${index}].replies`]: (list || []).map((r) => ({ - ...r, - timeText: fmtAgo(r.created_at), - initial: (r.author_name || '?').slice(0, 1), - })), - }), - ) - .catch((err) => wx.showToast({ title: (err && err.message) || '加载失败', icon: 'none' })); - }, - onPreviewCommentImage(e) { - const { urls, cur } = e.currentTarget.dataset; - if (urls && urls.length) wx.previewImage({ urls, current: cur }); - }, - onRemoveCommentImage(e) { - const list = this.data.commentImages.slice(); - list.splice(e.currentTarget.dataset.index, 1); - this.setData({ commentImages: list }); - }, }, }); diff --git a/pets-fe/components/bottom-sheet/bottom-sheet.wxml b/pets-fe/components/bottom-sheet/bottom-sheet.wxml index efbf0c5..9f4e5c9 100644 --- a/pets-fe/components/bottom-sheet/bottom-sheet.wxml +++ b/pets-fe/components/bottom-sheet/bottom-sheet.wxml @@ -7,102 +7,10 @@ module.exports.sel = function (map, key, index, def) { - - + - - - 共 {{total}} 条评论 - - - - {{item.initial}} - - {{item.author_name}} - {{item.content}} - - - - - {{item.timeText}} - 回复 - 删除 - - - - - - {{r.initial}} - - - {{r.author_name}} - 回复 {{r.reply_to_name}} - - {{r.content}} - - {{r.timeText}} - 回复 - 删除 - - - - - — 展开全部 {{item.reply_n}} 条回复 - - - - - - - - 还没有评论 - 来抢个沙发,说点什么吧~ - - - - - - - 回复 {{replyTo.name}} - - - - - - - - - - - - {{commentText.length}}/500 - {{sendingComment ? '审核中…' : '发送'}} - - 评论通过安全审核后才会公开显示,配图最多 1 张 - - - - - + - - - 发布图文 - 用你的昵称分享养宠日常。 - - - - - 晒宠 - 新手求助 - 经验 - - - - - - - - - - - - - diff --git a/pets-fe/components/profile-head/index.js b/pets-fe/components/profile-head/index.js index 621aff0..fb53a15 100644 --- a/pets-fe/components/profile-head/index.js +++ b/pets-fe/components/profile-head/index.js @@ -8,9 +8,7 @@ Component({ // 装扮页的实时预览:只看效果,不要底部那排按钮 preview: { type: Boolean, value: false }, hideWall: { type: Boolean, value: false }, // 「我的」页藏掉社交宠物墙,避免和「我的毛孩子」卡重复 - // 关注/粉丝数字是否可点开列表。别人主页设 false:从关注/粉丝列表点进对方主页后, - // 不再允许打开对方的关注/粉丝,否则会无限套娃 - relationsClickable: { type: Boolean, value: true }, + hideSocial: { type: Boolean, value: false }, // 兼容旧调用,社区下线后无实际作用 }, data: { initial: '', theme: 'warm' }, observers: { @@ -24,16 +22,9 @@ Component({ }, }, methods: { - onFollow() { - this.triggerEvent('follow'); - }, onDecorate() { this.triggerEvent('decorate'); }, - onRelations(e) { - if (!this.data.relationsClickable) return; // 别人主页:只看数字,不给点开列表 - this.triggerEvent('relations', { kind: e.currentTarget.dataset.kind }); - }, onPet(e) { this.triggerEvent('pet', { id: e.currentTarget.dataset.id }); }, diff --git a/pets-fe/components/profile-head/index.wxml b/pets-fe/components/profile-head/index.wxml index 8028bc3..414f06b 100644 --- a/pets-fe/components/profile-head/index.wxml +++ b/pets-fe/components/profile-head/index.wxml @@ -15,13 +15,6 @@ - - - {{card.post_count || 0}}帖子 - {{card.following_count || 0}}关注 - {{card.follower_count || 0}}粉丝 - - {{card.stats.days || 0}}养宠天数 @@ -42,9 +35,5 @@ - - - {{card.followed ? '已关注' : '关注 TA'}} - diff --git a/pets-fe/pages/comments/comments.js b/pets-fe/pages/comments/comments.js deleted file mode 100644 index 0bb237f..0000000 --- a/pets-fe/pages/comments/comments.js +++ /dev/null @@ -1,178 +0,0 @@ -const api = require('../../utils/api.js'); -const upload = require('../../utils/upload.js'); - -// 相对时间:社区里关心「多久以前」,精确到秒没意义 -function fmtAgo(iso) { - if (!iso) return ''; - const d = new Date(iso); - if (isNaN(d.getTime())) return ''; - const min = Math.floor((Date.now() - d.getTime()) / 60000); - if (min < 1) return '刚刚'; - if (min < 60) return min + ' 分钟前'; - if (min < 60 * 24) return Math.floor(min / 60) + ' 小时前'; - if (min < 60 * 24 * 7) return Math.floor(min / 1440) + ' 天前'; - const p = (n) => (n < 10 ? '0' + n : '' + n); - const sameYear = d.getFullYear() === new Date().getFullYear(); - return (sameYear ? '' : d.getFullYear() + '-') + p(d.getMonth() + 1) + '-' + p(d.getDate()); -} - -Page({ - data: { - postId: '', - total: 0, - comments: [], - commentText: '', - commentImages: [], - replyTo: {}, - cmFocus: false, - sendingComment: false, - kbHeight: 0, - }, - - onLoad(query) { - this.setData({ postId: query.postId || '' }); - this.loadComments(); - }, - - // 把当前已发布评论数回传给社区列表,卡片上的评论数实时跟着变 - syncCountBack() { - const ch = this.getOpenerEventChannel && this.getOpenerEventChannel(); - if (ch && ch.emit) ch.emit('commentChanged', { postId: this.data.postId, count: this.data.total }); - }, - - loadComments() { - if (!this.data.postId) return; - api - .listComments(this.data.postId) - .then((page) => { - this.setData({ - total: page.total || 0, - comments: (page.list || []).map((c) => ({ - ...c, - timeText: fmtAgo(c.created_at), - initial: (c.author_name || '?').slice(0, 1), - imgs: Array.isArray(c.images) ? c.images : [], - replies: (c.replies || []).map((r) => ({ - ...r, - timeText: fmtAgo(r.created_at), - initial: (r.author_name || '?').slice(0, 1), - })), - })), - }); - this.syncCountBack(); - }) - .catch(() => {}); - }, - - onCommentInput(e) { - this.setData({ commentText: e.detail.value }); - }, - - // 点任意评论/回复:底部输入条切到「回复 xxx」并聚焦 - onReplyTo(e) { - const { id, name } = e.currentTarget.dataset; - if (!id) return; - this.setData({ replyTo: { id, name }, cmFocus: true }); - }, - onCancelReply() { - this.setData({ replyTo: {} }); - }, - - // 键盘高度变化:微信为「自定义输入条跟随键盘」提供的事件。只改输入条的 bottom(inline), - // 评论列表完全不动。注意:聚焦期间除了这个 bottom,绝不 setData 碰输入框本身 - // (不设 cmFocus:false、不改它的布局),否则原生 textarea 会被抖失焦、键盘弹一下就收。 - onKbChange(e) { - this.setData({ kbHeight: (e.detail && e.detail.height) || 0 }); - }, - onCommentBlur() { - // 失焦:收起键盘时把输入条放回底部;cmFocus 复位好让下次回复能重新拉键盘 - this.setData({ cmFocus: false, kbHeight: 0 }); - }, - - // 配图:评论只允许 1 张 - onPickCommentImages() { - if (this.data.commentImages.length >= 1) { - return wx.showToast({ title: '评论只能配 1 张图', icon: 'none' }); - } - upload - .chooseAndUploadImages(1) - .then((files) => this.setData({ commentImages: (files || []).slice(0, 1) })) - .catch((e) => { - if (e && e.canceled) return; - wx.showToast({ title: (e && e.message) || '上传失败', icon: 'none' }); - }); - }, - onRemoveCommentImage(e) { - const list = this.data.commentImages.slice(); - list.splice(e.currentTarget.dataset.index, 1); - this.setData({ commentImages: list }); - }, - onPreviewCommentImage(e) { - const { urls, cur } = e.currentTarget.dataset; - if (urls && urls.length) wx.previewImage({ urls, current: cur }); - }, - - async onSendComment() { - if (this.data.sendingComment) return; // 防连点 - const text = (this.data.commentText || '').trim(); - if (!text) return wx.showToast({ title: '写点什么再发', icon: 'none' }); - if (!this.data.postId) return; - this.setData({ sendingComment: true }); - wx.showLoading({ title: '审核中…', mask: true }); - try { - const res = await api.createComment( - this.data.postId, - text, - this.data.commentImages.map((i) => i.url), - this.data.replyTo.id || '', - ); - wx.hideLoading(); - this.setData({ commentText: '', commentImages: [], replyTo: {}, cmFocus: false, sendingComment: false }); - if (res && res.status === 'published') { - this.loadComments(); - wx.showToast({ title: '评论成功', icon: 'success' }); - } else { - wx.showToast({ title: '已提交,审核通过后展示', icon: 'none' }); - } - } catch (e) { - wx.hideLoading(); - this.setData({ sendingComment: false }); - wx.showToast({ title: (e && e.message) || '评论失败', icon: 'none' }); - } - }, - - // 长按删除自己的评论 - onDeleteComment(e) { - const { id, self } = e.currentTarget.dataset; - if (!id || !self) return; - wx.showModal({ - title: '删除评论', - content: '确定删除这条评论?', - confirmColor: '#D9534F', - success: (r) => { - if (!r.confirm) return; - api - .deleteComment(id) - .then(() => this.loadComments()) - .catch((err) => wx.showToast({ title: (err && err.message) || '删除失败', icon: 'none' })); - }, - }); - }, - - // 一级评论默认只带 3 条回复,点开拉全量 - onExpandReplies(e) { - const { id, index } = e.currentTarget.dataset; - api - .listReplies(id) - .then((list) => - this.setData({ - [`comments[${index}].replies`]: (list || []).map((r) => ({ - ...r, - timeText: fmtAgo(r.created_at), - initial: (r.author_name || '?').slice(0, 1), - })), - }), - ) - .catch((err) => wx.showToast({ title: (err && err.message) || '加载失败', icon: 'none' })); - }, -}); diff --git a/pets-fe/pages/comments/comments.json b/pets-fe/pages/comments/comments.json deleted file mode 100644 index 6594cd8..0000000 --- a/pets-fe/pages/comments/comments.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "usingComponents": { - "nav-bar": "/components/nav-bar/nav-bar", - "pt-icon": "/components/pt-icon/index" - } -} diff --git a/pets-fe/pages/comments/comments.wxml b/pets-fe/pages/comments/comments.wxml deleted file mode 100644 index 7473224..0000000 --- a/pets-fe/pages/comments/comments.wxml +++ /dev/null @@ -1,82 +0,0 @@ - - - - 共 {{total}} 条评论 - - - {{item.initial}} - - {{item.author_name}} - {{item.content}} - - - - - {{item.timeText}} - 回复 - 删除 - - - - - {{r.initial}} - - - {{r.author_name}} - 回复 {{r.reply_to_name}} - - {{r.content}} - - {{r.timeText}} - 回复 - 删除 - - - - - — 展开全部 {{item.reply_n}} 条回复 - - - - - - - - 还没有评论 - 来抢个沙发,说点什么吧~ - - - - - - - - 回复 {{replyTo.name}} - - - - - - - - - - - - {{sendingComment ? '审核中…' : '发送'}} - - 评论通过安全审核后才会公开显示,配图最多 1 张 - diff --git a/pets-fe/pages/comments/comments.wxss b/pets-fe/pages/comments/comments.wxss deleted file mode 100644 index 1d5d1e0..0000000 --- a/pets-fe/pages/comments/comments.wxss +++ /dev/null @@ -1,88 +0,0 @@ -/* flex 列 + 整页 overflow:hidden:页面本身不滚(adjust-position=false 时列表纹丝不动), - 列表在内层 scroll-view 里滚,底部输入条 fixed 覆在最下面 */ -page{display:flex;flex-direction:column;height:100vh;overflow:hidden;background:var(--bg)} - -/* 底部留白 = 输入条高度,最后几条评论不被固定输入条盖住 */ -.cm-scroll{flex:1;min-height:0;padding:0 var(--sp-5) 200rpx} -.cm-count-head{ - padding:var(--sp-3) 0;font-size:var(--fs-md);font-weight:var(--fw-b); - color:var(--text);border-bottom:1rpx solid var(--line); -} - -/* 空态 */ -.cmp-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:160rpx 0;color:var(--muted)} -.cmp-empty-ic{ - width:140rpx;height:140rpx;border-radius:50%;margin-bottom:var(--sp-4); - display:flex;align-items:center;justify-content:center; - background:var(--primary-soft);color:var(--primary); -} -.cmp-empty-t{font-size:var(--fs-lg);font-weight:var(--fw-b);color:var(--text-2)} -.cmp-empty-p{margin-top:var(--sp-1);font-size:var(--fs-sm);color:var(--muted2)} - -/* 评论行 */ -.cm{display:flex;gap:var(--sp-3);padding:var(--sp-3) 0} -.cm-av{ - width:64rpx;height:64rpx;border-radius:50%;flex:none; - display:flex;align-items:center;justify-content:center; - background:var(--primary-soft);color:var(--primary-ink); - font-size:var(--fs-md);font-weight:var(--fw-b); -} -.cm-av-sm{width:48rpx;height:48rpx;font-size:var(--fs-sm)} -.cm-body{flex:1;min-width:0} -.cm-name{font-size:var(--fs-sm);color:var(--muted)} -.cm-at{color:var(--muted2)} -.cm-text{margin-top:6rpx;font-size:var(--fs-md);line-height:1.55;word-break:break-word} -.cm-imgs{display:flex;flex-wrap:wrap;gap:var(--sp-1);margin-top:var(--sp-2)} -.cm-img{width:150rpx;height:150rpx;border-radius:var(--r-sm)} -.cm-meta{display:flex;align-items:center;gap:var(--sp-4);margin-top:var(--sp-2);font-size:var(--fs-cap);color:var(--muted2)} -.cm-reply-btn{color:var(--muted)} -.cm-del{color:var(--red-ink)} -.cm-replies{margin-top:var(--sp-2)} -.cm-reply{display:flex;gap:var(--sp-2);padding:var(--sp-2) 0} -.cm-more{margin-top:4rpx;font-size:var(--fs-cap);color:var(--muted)} -.mine-tag{ - margin-left:var(--sp-1);font-size:var(--fs-cap);font-weight:var(--fw-b); - color:var(--primary-ink);background:var(--primary-soft);padding:2rpx var(--sp-1);border-radius:var(--r-full); -} - -/* 底部输入条:固定在底部,键盘弹起时 inline 的 bottom 会被抬到键盘上方(列表不动) */ -.cm-bar{ - position:fixed;left:0;right:0;bottom:0;z-index:50; - background:#fff;border-top:1rpx solid var(--line); - padding:var(--sp-3) var(--sp-5) calc(16rpx + env(safe-area-inset-bottom)); - transition:bottom .15s ease; -} -.cm-replying{ - display:inline-flex;align-items:center;gap:var(--sp-2);margin-bottom:var(--sp-2); - padding:4rpx var(--sp-3);border-radius:var(--r-full); - background:var(--primary-soft);color:var(--primary-ink);font-size:var(--fs-cap); -} -.cm-cancel{display:flex;align-items:center} -.cm-bar-row{display:flex;align-items:flex-end;gap:var(--sp-3)} -/* 起始就是单行高度(显式 height 盖掉全局 textarea 的 88rpx,避免「先高一下再缩成单行」的抖动), - auto-height 只在文字换行时把它顶高;超过 max 就内部滚动 */ -.cm-ta{ - flex:1;min-width:0;box-sizing:border-box; - height:72rpx;min-height:72rpx;max-height:280rpx; - padding:16rpx var(--sp-4);background:var(--surface-2);border-radius:var(--r-md); - font-size:var(--fs-md);line-height:1.4; -} -.cm-pic{flex:none;display:flex;align-items:center;color:var(--muted);height:72rpx} -.cm-pic.disabled{opacity:.35} -.cm-send{ - flex:none;height:72rpx;padding:0 var(--sp-6);border-radius:var(--r-full); - display:flex;align-items:center;justify-content:center; - background:var(--line);color:#fff;font-size:var(--fs-md);font-weight:var(--fw-b);transition:.16s ease; -} -.cm-send.on{background:var(--cta)} -.cm-tip{margin-top:var(--sp-2);color:var(--muted2);font-size:var(--fs-cap);line-height:1.5} - -/* 配图预览 */ -.img-picker{display:flex;flex-wrap:wrap;gap:var(--sp-3);margin-bottom:var(--sp-2)} -.img-thumb{position:relative;width:160rpx;height:160rpx;border-radius:var(--r-sm);overflow:hidden} -.img-thumb image{width:100%;height:100%} -.img-del{ - position:absolute;top:0;right:0;width:44rpx;height:44rpx; - display:flex;align-items:center;justify-content:center; - background:rgba(0,0,0,.55);color:#fff;border-radius:0 var(--r-sm) 0 var(--r-sm); -} diff --git a/pets-fe/pages/community/community.js b/pets-fe/pages/community/community.js deleted file mode 100644 index 9b8dbb8..0000000 --- a/pets-fe/pages/community/community.js +++ /dev/null @@ -1,204 +0,0 @@ -const store = require('../../utils/store.js'); -const api = require('../../utils/api.js'); -const { toastErr } = require('../../utils/ui.js'); -const { syncTabBar } = require('../../utils/tabbar.js'); - -// 相对时间。社区里关心的是「多久以前发的」,精确到秒没意义 -function fmtAgo(iso) { - if (!iso) return ''; - const d = new Date(iso); - if (isNaN(d.getTime())) return ''; - const min = Math.floor((Date.now() - d.getTime()) / 60000); - if (min < 1) return '刚刚'; - if (min < 60) return min + ' 分钟前'; - if (min < 60 * 24) return Math.floor(min / 60) + ' 小时前'; - if (min < 60 * 24 * 7) return Math.floor(min / 1440) + ' 天前'; - const p = (n) => (n < 10 ? '0' + n : '' + n); - const sameYear = d.getFullYear() === new Date().getFullYear(); - return (sameYear ? '' : d.getFullYear() + '-') + p(d.getMonth() + 1) + '-' + p(d.getDate()); -} - -const TAG_CLASS = { 求助: 'warn', 经验: 'blue', 精选: 'purple', 避坑: 'red', 晒宠: '' }; - -function mapPost(p) { - const tags = p.tags || []; - const tag = tags[0] || ''; - return { - id: p.id, - author_name: p.author_name, - author_emoji: p.author_emoji || '🐾', - content: p.content, - images: p.images || [], - like_count: p.like_count, - comment_count: p.comment_count, - liked: false, - tag, - tagClass: TAG_CLASS[tag] || '', - is_ai: !!p.is_ai, - user_id: p.user_id, - followed: !!p.followed, - is_self: !!p.is_self, - timeText: fmtAgo(p.created_at), - }; -} - -Page({ - data: { - pet: {}, - // 评论功能暂时下线:入口隐藏,comments 页面与 openComments 等代码全部保留, - // 需要恢复时把这里改回 true 即可 - commentsEnabled: false, - feedTabs: ['推荐', '关注', '新手求助', '晒宠', '经验'], - feedIdx: 0, - posts: [], - sheetShow: false, - sheetType: '', - sheetPostId: '', - loaded: false, - loadErr: '', - intoView: '', - }, - onLoad() { - this._unsub = store.subscribe((pet) => this.setData({ pet })); - }, - onUnload() { - if (this._unsub) this._unsub(); - }, - onShow() { - syncTabBar(this); - store - .ready() - .then(() => { - this.setData({ pet: store.getPet() }); - this.loadPosts(); - }) - .catch((e) => wx.showToast({ title: e.message || '加载失败', icon: 'none' })); - }, - loadPosts() { - const tab = this.data.feedTabs[this.data.feedIdx]; - this.setData({ loadErr: '' }); - api - .listPosts(tab, 1) - .then((page) => this.setData({ posts: (page.list || []).map(mapPost), loaded: true })) - .catch((e) => { - // 不能让「加载失败」显示成「还没有帖子」,那是在骗用户 - this.setData({ loadErr: e.message || '加载失败', loaded: true }); - toastErr(e); - }); - }, - // 来自 seg-tabs 的 change 事件 - switchFeedTab(e) { - // 切分类必须回到顶部:不然从「推荐」滚到一半切到「关注」, - // 看到的是新列表的中间,会以为内容错乱了 - this.setData({ feedIdx: Number(e.detail.index), intoView: 'feed-top' }); - this.loadPosts(); - }, - // 滚动时清掉锚点,否则下次再设同一个值不会触发 - onFeedScroll() { - if (this.data.intoView) this.setData({ intoView: '' }); - }, - likePost(e) { - const i = e.currentTarget.dataset.index; - const post = this.data.posts[i]; - api - .likePost(post.id) - .then((res) => { - this.setData({ [`posts[${i}].like_count`]: res.like_count, [`posts[${i}].liked`]: true }); - }) - .catch((e) => toastErr(e, '点赞失败')); - }, - openComments(e) { - const id = e.currentTarget.dataset.id; - if (!id) return; - // 评论改成独立二级页面。原来套在 fixed 弹层里,输入框被键盘遮挡且无法可靠避让; - // 普通页面里的 fixed 输入条用 transform 平移就能稳稳浮在键盘上方 - wx.navigateTo({ - url: `/pages/comments/comments?postId=${id}`, - events: { - // 评论页把「已发布评论数」回传,卡片上的数字实时更新 - commentChanged: (d) => { - if (!d || !d.postId) return; - const idx = this.data.posts.findIndex((p) => p.id === d.postId); - if (idx >= 0) this.setData({ [`posts[${idx}].comment_count`]: d.count }); - }, - }, - }); - }, - openSheet(e) { - this.setData({ sheetType: e.currentTarget.dataset.type, sheetPostId: '', sheetShow: true }); - }, - closeSheet() { - this.setData({ sheetShow: false }); - }, - onPosted() { - this.setData({ sheetShow: false }); - this.loadPosts(); - }, - onCommented() { - this.loadPosts(); - }, - // 点头像或昵称进 TA 的主页。关注做了却没有主页,关注完就石沉大海 - goUser(e) { - const id = e.currentTarget.dataset.id; - if (id) wx.navigateTo({ url: `/pages/user/user?id=${id}` }); - }, - goLearn() { - wx.navigateTo({ url: '/pages/learn/learn' }); - }, - // 社区的悬浮键本来就该是发帖,不是记录(原来它跳 AI 聊天页) - onCreatePost() { - this.setData({ sheetType: 'createPost', sheetShow: true }); - }, - // 点缩略图放大预览。只取 http 图(机器人帖的 emoji 占位不参与) - onPreviewImage(e) { - const { urls, cur } = e.currentTarget.dataset; - const list = (urls || []).filter((u) => typeof u === 'string' && u.indexOf('http') === 0); - if (!list.length) return; - wx.previewImage({ current: cur, urls: list }); - }, - // 长按自己的帖子可删除 - onLongPressPost(e) { - const p = this.data.posts[e.currentTarget.dataset.index]; - if (!p || !p.is_self) return; - wx.showModal({ - title: '删除帖子', - content: '确定删除这条帖子?删除后其他人将看不到。', - confirmColor: '#D9534F', - success: (res) => { - if (!res.confirm) return; - api.deletePost(p.id) - .then(() => { wx.showToast({ title: '已删除', icon: 'success' }); this.loadPosts(); }) - .catch((err) => wx.showToast({ title: err.message || '删除失败', icon: 'none' })); - }, - }); - }, - // 关注 / 取关帖子作者 - toggleFollow(e) { - const i = e.currentTarget.dataset.index; - const p = this.data.posts[i]; - if (!p || !p.user_id || p.is_self) return; - const fn = p.followed ? api.unfollowUser : api.followUser; - fn(p.user_id) - .then(() => { - // 同一作者的所有帖子一起更新状态 - const posts = this.data.posts.map((x) => - x.user_id === p.user_id ? { ...x, followed: !p.followed } : x, - ); - this.setData({ posts }); - wx.showToast({ title: p.followed ? '已取消关注' : '已关注', icon: 'none' }); - if (this.data.feedTabs[this.data.feedIdx] === '关注') this.loadPosts(); - }) - .catch((err) => wx.showToast({ title: err.message || '操作失败', icon: 'none' })); - }, - onShareAppMessage(e) { - // 从帖子上的分享按钮转发:带上该帖内容做标题 - if (e && e.from === 'button') { - const c = (e.target.dataset.content || '').slice(0, 40); - return { title: c ? '宠友圈:' + c : '来宠友圈看看大家的毛孩子', path: '/pages/community/community' }; - } - return { title: '宠友圈 · 和铲屎官们交流养宠经验', path: '/pages/community/community' }; - }, - onShareTimeline() { - return { title: '宠友圈 · 和铲屎官们交流养宠经验' }; - }, -}); diff --git a/pets-fe/pages/community/community.json b/pets-fe/pages/community/community.json deleted file mode 100644 index 7f17b0c..0000000 --- a/pets-fe/pages/community/community.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "usingComponents": { - "nav-bar": "/components/nav-bar/nav-bar", - "bottom-sheet": "/components/bottom-sheet/bottom-sheet", - "fab": "/components/fab/fab", - "pt-icon": "/components/pt-icon/index", - "seg-tabs": "/components/seg-tabs/index" - } -} diff --git a/pets-fe/pages/community/community.wxml b/pets-fe/pages/community/community.wxml deleted file mode 100644 index f5c6055..0000000 --- a/pets-fe/pages/community/community.wxml +++ /dev/null @@ -1,63 +0,0 @@ - -module.exports.isUrl = function (s) { return s && s.indexOf('http') === 0; } - - - - - - - - - - - - - - {{item.author_emoji}} - - {{item.author_name}}AI - {{item.timeText}} - - - {{item.tag}} - - {{item.content}} - - - - {{img}} - - - - - - {{item.like_count || '点赞'}} - - - - - {{item.comment_count || '评论'}} - - - - - - - {{loadErr}} - 点击重试 - - - {{feedTabs[feedIdx] === '关注' ? '还没有关注的人,去「推荐」里关注几个宠友吧 🐾' : '还没有帖子,来发第一条吧 🐾'}} - - - - - - diff --git a/pets-fe/pages/community/community.wxss b/pets-fe/pages/community/community.wxss deleted file mode 100644 index 23a07b2..0000000 --- a/pets-fe/pages/community/community.wxss +++ /dev/null @@ -1,19 +0,0 @@ -.compose-card{margin-bottom:var(--sp-4)} - - -/* 关注按钮 */ - -.retry-btn{ - margin-top:var(--sp-3);display:inline-block;padding:var(--sp-2) var(--sp-6);border-radius:var(--r-full); - background:var(--primary-soft);color:var(--primary-dark);font-weight:var(--fw-b);font-size:var(--fs-sm); -} - -/* 分类标签吸顶,发布按钮收进同一条:原来那个大黑按钮独占 124rpx, - 而它是低频操作,不该在每屏都占着首屏 */ -.feed-bar{display:flex;align-items:flex-start;gap:var(--sp-3)} -.feed-bar .st{flex:1;min-width:0} -.feed-post{ - flex:none;display:flex;align-items:center;gap:4rpx; - height:var(--h-sm);padding:0 var(--sp-3);border-radius:var(--r-full); - background:var(--cta);color:#fff;font-size:var(--fs-sm);font-weight:var(--fw-b); -} diff --git a/pets-fe/pages/mine/mine.js b/pets-fe/pages/mine/mine.js index 9b41413..c001699 100644 --- a/pets-fe/pages/mine/mine.js +++ b/pets-fe/pages/mine/mine.js @@ -34,25 +34,9 @@ Page({ .then((card) => this.setData({ card })) .catch(() => {}); }, - // 看自己的公开主页,和别人看到的是同一个页面、同一套渲染 - previewPublic() { - const uid = this.data.user && this.data.user.id; - if (uid) wx.navigateTo({ url: `/pages/user/user?id=${uid}` }); - }, - // 我的帖子:进自己的主页,能看到待审核/未通过的帖子及状态 - goMyPosts() { - const uid = this.data.user && this.data.user.id; - if (!uid) return wx.showToast({ title: '请先登录', icon: 'none' }); - wx.navigateTo({ url: '/pages/user/user?id=' + uid }); - }, goSettings() { wx.navigateTo({ url: '/pages/settings/settings' }); }, - goRelations(e) { - const uid = (this.data.user && this.data.user.id) || ''; - if (!uid) return wx.showToast({ title: '登录信息还没就绪', icon: 'none' }); - wx.navigateTo({ url: `/pages/relations/relations?id=${uid}&kind=${e.detail.kind}` }); - }, // 宠物档案:当前这只的编辑页 goPetForm() { const id = store.currentPetId(); diff --git a/pets-fe/pages/mine/mine.wxml b/pets-fe/pages/mine/mine.wxml index 153e0de..85ae4cf 100644 --- a/pets-fe/pages/mine/mine.wxml +++ b/pets-fe/pages/mine/mine.wxml @@ -2,18 +2,13 @@ - - - 装扮主页 - - 别人眼里的我 - @@ -37,13 +32,6 @@ - 设置 diff --git a/pets-fe/pages/relations/relations.js b/pets-fe/pages/relations/relations.js deleted file mode 100644 index 6cb5c7f..0000000 --- a/pets-fe/pages/relations/relations.js +++ /dev/null @@ -1,43 +0,0 @@ -const api = require('../../utils/api.js'); -const { toastErr } = require('../../utils/ui.js'); - -Page({ - data: { uid: '', kind: 'following', title: '关注', list: [], page: 1, hasMore: false, loaded: false }, - onLoad(q) { - const kind = q && q.kind === 'followers' ? 'followers' : 'following'; - this.setData({ uid: (q && q.id) || '', kind, title: kind === 'followers' ? '粉丝' : '关注' }); - this.load(1); - }, - load(page) { - api - .relations(this.data.uid, this.data.kind, page) - .then((res) => { - // WXML 表达式不支持字符串下标,首字母得在这里算好 - const list = (res.list || []).map((u) => ({ ...u, initial: (u.nickname || '?').slice(0, 1) })); - const merged = page === 1 ? list : this.data.list.concat(list); - this.setData({ list: merged, page, loaded: true, hasMore: merged.length < (res.total || 0) }); - }) - .catch((e) => { - this.setData({ loaded: true }); - toastErr(e); - }); - }, - loadMore() { - if (this.data.hasMore) this.load(this.data.page + 1); - }, - goUser(e) { - wx.navigateTo({ url: `/pages/user/user?id=${e.currentTarget.dataset.id}` }); - }, - // 同样先本地翻转再发请求,失败回滚 - toggleFollow(e) { - const i = e.currentTarget.dataset.index; - const u = this.data.list[i]; - if (!u || u.is_self) return; - const next = !u.followed; - this.setData({ [`list[${i}].followed`]: next }); - (next ? api.followUser(u.id) : api.unfollowUser(u.id)).catch((err) => { - this.setData({ [`list[${i}].followed`]: !next }); - toastErr(err, '操作失败'); - }); - }, -}); diff --git a/pets-fe/pages/relations/relations.json b/pets-fe/pages/relations/relations.json deleted file mode 100644 index 6594cd8..0000000 --- a/pets-fe/pages/relations/relations.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "usingComponents": { - "nav-bar": "/components/nav-bar/nav-bar", - "pt-icon": "/components/pt-icon/index" - } -} diff --git a/pets-fe/pages/relations/relations.wxml b/pets-fe/pages/relations/relations.wxml deleted file mode 100644 index 09f45b3..0000000 --- a/pets-fe/pages/relations/relations.wxml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - {{item.initial}} - - {{item.nickname}}AI - - - - - {{kind === 'followers' ? '还没有人关注 TA' : '还没有关注任何人,去宠友圈逛逛'}} - - - diff --git a/pets-fe/pages/relations/relations.wxss b/pets-fe/pages/relations/relations.wxss deleted file mode 100644 index 1ac6fad..0000000 --- a/pets-fe/pages/relations/relations.wxss +++ /dev/null @@ -1,12 +0,0 @@ -.rel{ - display:flex;align-items:center;gap:var(--sp-3); - background:#fff;border-radius:var(--r-md);box-shadow:var(--sd-1); - padding:var(--sp-3) var(--sp-4);margin-bottom:var(--sp-2); -} -.rel-av{ - width:80rpx;height:80rpx;border-radius:50%;flex:none;overflow:hidden; - display:flex;align-items:center;justify-content:center; - background:var(--primary-soft);color:var(--primary-ink);font-size:var(--fs-lg);font-weight:var(--fw-b); -} -.rel-av-img{width:100%;height:100%} -.rel-name{flex:1;min-width:0;font-size:var(--fs-md);font-weight:var(--fw-b)} diff --git a/pets-fe/pages/settings/settings.js b/pets-fe/pages/settings/settings.js index 0c207aa..030a50d 100644 --- a/pets-fe/pages/settings/settings.js +++ b/pets-fe/pages/settings/settings.js @@ -55,12 +55,6 @@ Page({ wx.navigateTo({ url: '/pages/agreement/agreement?type=privacy' }); } }, - // 自己的关注/粉丝。之前只有帖子上的「+关注」按钮,关注完没有任何地方能看 - goRelations(e) { - const uid = (this.data.user && this.data.user.id) || ''; - if (!uid) return wx.showToast({ title: '登录信息还没就绪', icon: 'none' }); - wx.navigateTo({ url: `/pages/relations/relations?id=${uid}&kind=${e.currentTarget.dataset.kind}` }); - }, goRecord() { wx.navigateTo({ url: '/pages/record/record' }); }, diff --git a/pets-fe/pages/user/user.js b/pets-fe/pages/user/user.js deleted file mode 100644 index a4da6c5..0000000 --- a/pets-fe/pages/user/user.js +++ /dev/null @@ -1,101 +0,0 @@ -const api = require('../../utils/api.js'); -const store = require('../../utils/store.js'); -const { toastErr } = require('../../utils/ui.js'); - -const TAG_CLASS = { 求助: 'warn', 经验: 'blue', 精选: 'purple', 避坑: 'red', 晒宠: '' }; -// 审核状态 → 展示文案(只在看自己主页时出现) -const STATUS_TEXT = { pending: '审核中', rejected: '未通过' }; - -function fmtAgo(iso) { - if (!iso) return ''; - const d = new Date(iso); - if (isNaN(d.getTime())) return ''; - const min = Math.floor((Date.now() - d.getTime()) / 60000); - if (min < 1) return '刚刚'; - if (min < 60) return min + ' 分钟前'; - if (min < 60 * 24) return Math.floor(min / 60) + ' 小时前'; - if (min < 60 * 24 * 7) return Math.floor(min / 1440) + ' 天前'; - const p = (n) => (n < 10 ? '0' + n : '' + n); - return p(d.getMonth() + 1) + '-' + p(d.getDate()); -} - -Page({ - data: { uid: '', card: null, posts: [], page: 1, hasMore: false, loading: true }, - onLoad(q) { - const uid = q && q.id; - if (!uid) return wx.showToast({ title: '缺少用户', icon: 'none' }); - this.setData({ uid }); - this.loadCard(); - this.loadPosts(1); - }, - loadCard() { - api - .userCard(this.data.uid) - .then((card) => this.setData({ card, loading: false })) - .catch((e) => { - this.setData({ loading: false }); - toastErr(e); - }); - }, - loadPosts(page) { - api - .userPosts(this.data.uid, page) - .then((res) => { - const list = (res.list || []).map((p) => { - const tag = (p.tags || [])[0] || ''; - return { - ...p, - timeText: fmtAgo(p.created_at), - author_emoji: p.author_emoji || '🐾', - tag, - tagClass: TAG_CLASS[tag] || '', - // 只有看自己主页才会拿到非「已发布」的帖子,给个审核状态标 - statusText: STATUS_TEXT[p.status] || '', - }; - }); - const merged = page === 1 ? list : this.data.posts.concat(list); - this.setData({ posts: merged, page, hasMore: merged.length < (res.total || 0) }); - }) - .catch(() => {}); - }, - loadMore() { - if (this.data.hasMore) this.loadPosts(this.data.page + 1); - }, - // 关注状态先本地翻转,请求失败再翻回去——等接口返回按钮才变会显得很迟钝 - toggleFollow() { - const c = this.data.card; - if (!c || c.is_self) return; - const next = !c.followed; - this.setData({ - 'card.followed': next, - 'card.follower_count': Math.max(0, c.follower_count + (next ? 1 : -1)), - }); - (next ? api.followUser(c.id) : api.unfollowUser(c.id)).catch((e) => { - this.setData({ 'card.followed': !next, 'card.follower_count': c.follower_count }); - toastErr(e, '操作失败'); - }); - }, - goRelations(e) { - const kind = e.detail.kind; - wx.navigateTo({ url: `/pages/relations/relations?id=${this.data.uid}&kind=${kind}` }); - }, - // 自己看自己的主页时,头部按钮是「装扮」而不是「关注」 - goDecorate() { - wx.navigateTo({ url: '/pages/decorate/decorate' }); - }, - // 别人的宠物只是名片,点了不跳;自己的才切过去看 - goPet(e) { - const c = this.data.card; - if (!c || !c.is_self) return; - store.switchPet(e.detail.id); - wx.switchTab({ url: '/pages/home/home' }); - }, - previewImage(e) { - const { urls, cur } = e.currentTarget.dataset; - if (urls && urls.length) wx.previewImage({ urls, current: cur }); - }, - onShareAppMessage() { - const n = (this.data.card && this.data.card.nickname) || '宠友'; - return { title: `${n} 的主页`, path: `/pages/user/user?id=${this.data.uid}` }; - }, -}); diff --git a/pets-fe/pages/user/user.json b/pets-fe/pages/user/user.json deleted file mode 100644 index b4ba05a..0000000 --- a/pets-fe/pages/user/user.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "usingComponents": { - "nav-bar": "/components/nav-bar/nav-bar", - "pt-icon": "/components/pt-icon/index", - "profile-head": "/components/profile-head/index" - } -} diff --git a/pets-fe/pages/user/user.wxml b/pets-fe/pages/user/user.wxml deleted file mode 100644 index 74772ed..0000000 --- a/pets-fe/pages/user/user.wxml +++ /dev/null @@ -1,46 +0,0 @@ - -module.exports.isUrl = function (s) { return s && s.indexOf('http') === 0; } - - - - - - 加载中… - - - - - - - - {{item.author_emoji}} - - {{item.author_name}} - {{item.timeText}} - - {{item.statusText}} - {{item.tag}} - - 内容审核中,通过后其他人才能看到 - 未通过内容安全审核,仅你可见 - {{item.content}} - - - - {{img}} - - - - {{item.like_count || 0}} - {{item.comment_count || 0}} - - - - TA 还没有发过帖子 - - - diff --git a/pets-fe/pages/user/user.wxss b/pets-fe/pages/user/user.wxss deleted file mode 100644 index 3e9ff8c..0000000 --- a/pets-fe/pages/user/user.wxss +++ /dev/null @@ -1,15 +0,0 @@ -/* 头部整块(头像/昵称/签名/计数/养宠数据/宠物墙)已抽成 components/profile-head, - 帖子卡走 app.wxss 的 .post-card。这里没有页面独有样式了。 */ - -/* 审核状态标(只在看自己主页出现) */ -.post-status{ - padding:2rpx var(--sp-2);border-radius:var(--r-full); - font-size:var(--fs-cap);font-weight:var(--fw-b);margin-right:var(--sp-2); -} -.post-status.st-pending{background:#FDECC8;color:#B26A00} -.post-status.st-rejected{background:var(--red-soft);color:var(--red-ink)} -.status-note{ - margin:0 0 var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--r-sm); - background:var(--surface-2);color:var(--muted);font-size:var(--fs-cap);line-height:1.5; -} -.status-note.st-note-red{background:var(--red-soft);color:var(--red-ink)} diff --git a/pets-fe/utils/api.js b/pets-fe/utils/api.js index 4a90407..8a0543f 100644 --- a/pets-fe/utils/api.js +++ b/pets-fe/utils/api.js @@ -125,27 +125,8 @@ const api = { healthSummary: (id) => request({ url: `/api/pets/${id}/health-summary` }), getPoster: (id) => request({ url: `/api/pets/${id}/poster` }), - // 社区 - listPosts: (tab, page) => - request({ url: `/api/posts?tab=${encodeURIComponent(tab || '')}&page=${page || 1}&page_size=10` }), - createPost: (body) => request({ url: '/api/posts', method: 'POST', data: body }), - likePost: (id) => request({ url: `/api/posts/${id}/like`, method: 'POST' }), + // 个人主页卡片(「我的」页头部用;社区/关注已下线) userCard: (userId) => request({ url: `/api/users/${userId}/profile` }), - userPosts: (userId, page) => request({ url: `/api/users/${userId}/posts?page=${page || 1}&page_size=10` }), - relations: (userId, kind, page) => - request({ url: `/api/users/${userId}/relations?kind=${kind}&page=${page || 1}&page_size=20` }), - followUser: (userId) => request({ url: `/api/users/${userId}/follow`, method: 'POST' }), - unfollowUser: (userId) => request({ url: `/api/users/${userId}/follow`, method: 'DELETE' }), - deletePost: (id) => request({ url: `/api/posts/${id}`, method: 'DELETE' }), - deleteComment: (id) => request({ url: `/api/comments/${id}`, method: 'DELETE' }), - listComments: (id) => request({ url: `/api/posts/${id}/comments` }), - createComment: (id, content, images, parentId) => - request({ - url: `/api/posts/${id}/comments`, - method: 'POST', - data: { content, images: images || [], parent_id: parentId || '' }, - }), - listReplies: (commentId) => request({ url: `/api/comments/${commentId}/replies` }), // 文章 listArticles: () => request({ url: '/api/articles' }),