同步小程序与管理端更新,完善抽烟记录和解绑冷静期
This commit is contained in:
@@ -22,6 +22,7 @@ Page({
|
||||
titleText: '',
|
||||
btnText: '',
|
||||
form: {},
|
||||
editorContent: '',
|
||||
tempImages: [],
|
||||
coverPreview: '',
|
||||
coverPath: '',
|
||||
@@ -95,6 +96,7 @@ Page({
|
||||
}
|
||||
}
|
||||
patch.form = form;
|
||||
patch.editorContent = form.content || '';
|
||||
patch.contentLength = (form.content || '').length;
|
||||
}
|
||||
if (typeof data.repeatOptionIdx === 'number') patch.repeatOptionIdx = data.repeatOptionIdx;
|
||||
@@ -109,8 +111,23 @@ Page({
|
||||
} catch(e) {}
|
||||
},
|
||||
|
||||
// 保存草稿到本地(输入时自动触发)
|
||||
// 连续输入只保留一个草稿写入任务,避免每个按键同步写存储。
|
||||
_saveDraft: function() {
|
||||
this._draftCleared = false;
|
||||
clearTimeout(this._draftTimer);
|
||||
this._draftTimer = setTimeout(() => {
|
||||
this._draftTimer = null;
|
||||
this._persistDraft();
|
||||
}, 500);
|
||||
},
|
||||
_flushDraft: function() {
|
||||
clearTimeout(this._draftTimer);
|
||||
this._draftTimer = null;
|
||||
if (!this._draftCleared) this._persistDraft();
|
||||
},
|
||||
onHide: function() { this._flushDraft(); },
|
||||
onUnload: function() { this._flushDraft(); },
|
||||
_persistDraft: function() {
|
||||
try {
|
||||
var type = this.data.type;
|
||||
if (this.data.editId) return; // 编辑模式不保存草稿
|
||||
@@ -131,6 +148,9 @@ Page({
|
||||
|
||||
// 发布成功后清除草稿
|
||||
_clearDraft: function() {
|
||||
clearTimeout(this._draftTimer);
|
||||
this._draftTimer = null;
|
||||
this._draftCleared = true;
|
||||
try {
|
||||
var type = this.data.type;
|
||||
wx.removeStorageSync('publishDraft_' + type);
|
||||
@@ -166,6 +186,7 @@ Page({
|
||||
}
|
||||
this.setData({
|
||||
form: form,
|
||||
editorContent: form.content || '',
|
||||
repeatOptionIdx: repeatOptionIdx,
|
||||
bgImageUrl: bgUrl,
|
||||
bgImagePath: bgPath
|
||||
@@ -209,7 +230,7 @@ Page({
|
||||
} else {
|
||||
form = { title: '', date: '', location: '', content: '', repeat_interval: 0, repeat_unit: '' };
|
||||
}
|
||||
this.setData({ form: form, tempImages: [], repeatOptionIdx: 0, contentLength: (form.content || '').length });
|
||||
this.setData({ form: form, editorContent: form.content || '', tempImages: [], repeatOptionIdx: 0, contentLength: (form.content || '').length });
|
||||
},
|
||||
|
||||
// ===== 自动定位(日记 / 相册发布时自动获取经纬度)=====
|
||||
|
||||
Reference in New Issue
Block a user