603bd5773e
- 发帖后若未直接过审,弹窗明确「审核中,通过后才出现在社区」, 不再让用户以为发失败/是 bug - 后端 ListUserPosts:看自己主页时返回待审核/未通过的帖子(带状态), 看别人仍只返回已发布 - 个人主页帖子加「审核中/未通过」状态标 + 说明 - 我的页加「我的帖子」入口,进自己主页看审核状态 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
88 lines
2.9 KiB
JavaScript
88 lines
2.9 KiB
JavaScript
const store = require('../../utils/store.js');
|
|
const api = require('../../utils/api.js');
|
|
const { toastErr } = require('../../utils/ui.js');
|
|
const { syncTabBar } = require('../../utils/tabbar.js');
|
|
|
|
Page({
|
|
data: { user: {}, pets: [], card: null, sheetShow: false, sheetType: '' },
|
|
onLoad() {
|
|
this._unsub = store.subscribe(() => this.applyUser());
|
|
},
|
|
onUnload() {
|
|
if (this._unsub) this._unsub();
|
|
},
|
|
onShow() {
|
|
syncTabBar(this);
|
|
store
|
|
.ready()
|
|
.then(() => {
|
|
this.applyUser();
|
|
this.loadCard();
|
|
})
|
|
.catch((e) => toastErr(e));
|
|
},
|
|
applyUser() {
|
|
this.setData({ pets: store.getPets(), user: store.getUser() || {} });
|
|
},
|
|
// 头部数据走 /users/:id/profile,和别人看我时是同一个接口——
|
|
// 换成 /user/summary 的话两边字段会对不上,装扮效果也预览不到
|
|
loadCard() {
|
|
const uid = (this.data.user && this.data.user.id) || '';
|
|
if (!uid) return;
|
|
api
|
|
.userCard(uid)
|
|
.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();
|
|
if (!id) return wx.navigateTo({ url: '/pages/petform/petform' });
|
|
wx.navigateTo({ url: '/pages/petform/petform?id=' + id });
|
|
},
|
|
goDecorate() {
|
|
wx.navigateTo({ url: '/pages/decorate/decorate' });
|
|
},
|
|
goPlan() {
|
|
wx.navigateTo({ url: '/pages/plan/plan' });
|
|
},
|
|
// 列表行传 dataset,宠物名片墙传 detail,两边都进这里
|
|
onPickPet(e) {
|
|
const id = (e.detail && e.detail.id) || e.currentTarget.dataset.id;
|
|
if (!id) return;
|
|
store.switchPet(id);
|
|
wx.switchTab({ url: '/pages/home/home' });
|
|
},
|
|
openSheet(e) {
|
|
this.setData({ sheetType: e.currentTarget.dataset.type, sheetShow: true });
|
|
},
|
|
closeSheet() {
|
|
this.setData({ sheetShow: false });
|
|
},
|
|
onAddPet() {
|
|
wx.navigateTo({ url: '/pages/petform/petform' });
|
|
},
|
|
onShareAppMessage() {
|
|
return { title: '肉垫计划 · 每天照顾好毛孩子', path: '/pages/home/home' };
|
|
},
|
|
});
|