同步小程序与管理端更新,完善抽烟记录和解绑冷静期

This commit is contained in:
2026-10-09 22:15:51 +08:00
parent a68a4ef411
commit b10fc3c4ac
149 changed files with 3794 additions and 589 deletions
+9 -13
View File
@@ -1,9 +1,10 @@
const { withDataCache } = require('../../utils/page-cache');
const { getLayout } = require('../../utils/layout');
// Diary journal with server pagination.
const { api, getImageUrl } = require('../../utils/request');
const { diaryEntry } = require('../../utils/journal');
const { saveScrollPosition, getScrollPosition } = require('../../utils/scroll-pos');
Page({
Page(withDataCache({
onResize: function() { this.setData(getLayout()); },
data: {
loading: true, loadError: false,
@@ -22,18 +23,13 @@ Page({
this.setData({ scrollTop: getScrollPosition('diary') });
},
onShow: function() {
var self = this;
var savedTop = getScrollPosition('diary');
this.setData({ scrollTop: savedTop });
setTimeout(function() {
self.setData({ scrollTop: savedTop });
}, 100);
this.loadData();
},
// 收藏 tab 切换已移除
onScroll: function(e) {
this._scrollTop = e.detail.scrollTop;
saveScrollPosition('diary', e.detail.scrollTop);
},
@@ -58,7 +54,7 @@ Page({
loadData: async function() {
if (this._loading) return;
this._loading = true;
this.setData({ loading: true, loadError: false });
this.setData({ loading: !this._hasCachedData, loadError: false });
try {
var data = await api.diaryList({ page: 1, page_size: this.data.pageSize });
var items = this._formatItems(data.items || []);
@@ -185,17 +181,17 @@ Page({
goToDetail: function(e) {
var id = e.currentTarget.dataset.id;
if (!id) return;
saveScrollPosition('diary', this.data.scrollTop);
saveScrollPosition('diary', this._scrollTop == null ? this.data.scrollTop : this._scrollTop);
wx.navigateTo({ url: '/pages/diary_detail/diary_detail?id=' + id });
},
_savePosBeforeLeave: function() {
saveScrollPosition('diary', this.data.scrollTop);
saveScrollPosition('diary', this._scrollTop == null ? this.data.scrollTop : this._scrollTop);
},
openJournalEntry: function(e) { this.goToDetail(e); },
goToPublish: function() { this._savePosBeforeLeave(); wx.navigateTo({ url: '/pages/publish/publish?type=diary' }); },
goHome: function() { this._savePosBeforeLeave(); wx.redirectTo({ url: '/pages/index/index' }); },
goHome: function() { this._savePosBeforeLeave(); wx.switchTab({ url: '/pages/index/index' }); },
goBack: function() { wx.navigateBack(); },
goProfile: function() { this._savePosBeforeLeave(); wx.redirectTo({ url: '/pages/profile/profile' }); }
});
goProfile: function() { this._savePosBeforeLeave(); wx.switchTab({ url: '/pages/profile/profile' }); }
}, {"loadData": ["diaryList", "coupleInfo"]}));