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

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
+23 -2
View File
@@ -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 });
},
// ===== 自动定位(日记 / 相册发布时自动获取经纬度)=====
+9 -9
View File
@@ -9,7 +9,7 @@
<block wx:if="{{type == 'timeline' || type == 'checkin' || type == 'album'}}">
<view class="input-group">
<label>{{type == 'album' ? '相册名称' : (type == 'timeline' ? '事件内容' : '标题')}}</label>
<input class="input" placeholder="{{type == 'album' ? '例如:我们的旅行' : (type == 'checkin' ? '例如:吃饭、睡觉、运动' : '例如:第一次约会')}}" value="{{form.title}}" bindinput="onTitleInput" />
<input placeholder-class="handwritten-placeholder" class="input" placeholder="{{type == 'album' ? '例如:我们的旅行' : (type == 'checkin' ? '例如:吃饭、睡觉、运动' : '例如:第一次约会')}}" value="{{form.title}}" bindinput="onTitleInput" />
</view>
</block>
@@ -44,11 +44,11 @@
<block wx:if="{{type == 'timeline'}}">
<view class="input-group">
<label>事件地点(选填)</label>
<input class="input" placeholder="例如:西湖边" value="{{form.location}}" bindinput="onLocationInput" />
<input placeholder-class="handwritten-placeholder" class="input" placeholder="例如:西湖边" value="{{form.location}}" bindinput="onLocationInput" />
</view>
<view class="input-group">
<label>备注(选填)</label>
<textarea class="input textarea" placeholder="记录一些想说的话..." value="{{form.content}}" bindinput="onContentInput" auto-height maxlength="500" />
<textarea placeholder-class="handwritten-placeholder" class="input textarea" placeholder="记录一些想说的话..." value="{{editorContent}}" bindinput="onContentInput" auto-height maxlength="500" />
</view>
<view class="input-group">
<label>重复选项(选填)</label>
@@ -72,7 +72,7 @@
<!-- ===== 相册(描述 + 封面)===== -->
<view class="input-group" wx:if="{{type == 'album'}}">
<label>描述</label>
<input class="input" placeholder="简单描述一下这个相册" value="{{form.desc}}" bindinput="onDescInput" />
<input placeholder-class="handwritten-placeholder" class="input" placeholder="简单描述一下这个相册" value="{{form.desc}}" bindinput="onDescInput" />
</view>
<view class="input-group" wx:if="{{type == 'album'}}">
<label>封面图片</label>
@@ -92,7 +92,7 @@
<!-- 标题 -->
<view class="input-group">
<label>标题(选填)</label>
<input class="input diary-title-input" placeholder="给日记起个标题..." value="{{form.title}}" bindinput="onTitleInput" maxlength="100" />
<input placeholder-class="handwritten-placeholder" class="input diary-title-input" placeholder="给日记起个标题..." value="{{form.title}}" bindinput="onTitleInput" maxlength="100" />
</view>
<!-- 内容编辑器(支持换行) -->
@@ -101,7 +101,7 @@
<label>内容</label>
<text class="char-count {{contentLength > 5000 ? 'char-warn' : ''}}">{{contentLength}}/5000</text>
</view>
<textarea class="input textarea diary-editor" placeholder="今天发生了什么有趣的事呢?&#10;写下你的心情和感受吧..." value="{{form.content}}" bindinput="onContentInput" maxlength="5000" auto-height />
<textarea placeholder-class="handwritten-placeholder" class="input textarea diary-editor" placeholder="今天发生了什么有趣的事呢?写下你的心情和感受吧…" value="{{editorContent}}" bindinput="onContentInput" maxlength="{{5000}}" auto-height="{{false}}" cursor-spacing="24" />
</view>
<!-- 图片选择(可删除) -->
@@ -129,15 +129,15 @@
<block wx:if="{{type == 'song'}}">
<view class="input-group">
<label>歌曲名</label>
<input class="input" placeholder="例如:小幸运" value="{{form.song_name}}" bindinput="onTitleInput" />
<input placeholder-class="handwritten-placeholder" class="input" placeholder="例如:小幸运" value="{{form.song_name}}" bindinput="onTitleInput" />
</view>
<view class="input-group">
<label>歌手</label>
<input class="input" placeholder="例如:田馥甄" value="{{form.artist}}" bindinput="onArtistInput" />
<input placeholder-class="handwritten-placeholder" class="input" placeholder="例如:田馥甄" value="{{form.artist}}" bindinput="onArtistInput" />
</view>
<view class="input-group">
<label>备注(选填)</label>
<input class="input" placeholder="一句话,限60字" maxlength="60" value="{{form.note}}" bindinput="onNoteInput" />
<input placeholder-class="handwritten-placeholder" class="input" placeholder="一句话,限60字" maxlength="60" value="{{form.note}}" bindinput="onNoteInput" />
</view>
</block>
+8 -1
View File
@@ -2,7 +2,7 @@
@import '../../styles/common.wxss';
.container { padding: 84rpx 32rpx 300rpx; }
page { background: linear-gradient(180deg, #F4E2E3 0%, #FAF5EE 55%, #FAF5EE 100%); height: 100vh; overflow: hidden; }
page { background: linear-gradient(180deg, #FDE4EC 0%, #FFF0F5 48%, #FFF7FA 100%); height: 100vh; overflow: hidden; }
/* ===== 输入框美化 ===== */
.input-group { margin-bottom: 36rpx; }
@@ -206,3 +206,10 @@ page { background: linear-gradient(180deg, #F4E2E3 0%, #FAF5EE 55%, #FAF5EE 100%
@import '../../styles/design.wxss';
@import '../../styles/journal.wxss';
/* 长正文在输入框内滚动,避免输入时整页不断增高。 */
textarea.diary-editor { height:420rpx; min-height:420rpx; box-sizing:border-box; }
@import '../../styles/button-theme.wxss';
@import '../../styles/typography.wxss';