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

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
+16 -39
View File
@@ -13,6 +13,7 @@ Page({
timerText: '',
createdTime: '',
respondedTime: '',
completedTime: '',
_timer: null,
},
@@ -57,6 +58,7 @@ Page({
timerText: timerText,
createdTime: createdTime,
respondedTime: respondedTime,
completedTime: res.completed_at ? res.completed_at.substring(0, 16).replace('T', ' ') : '',
});
if (!self._visible) return;
@@ -67,37 +69,14 @@ Page({
self.data._pollTimer = null;
}
// 如果状态为 agreed(双方已同意解绑),清除缓存后跳转到登录页
if (status === 'agreed') {
wx.removeStorageSync('coupleId');
wx.removeStorageSync('petHasPet');
wx.showToast({ title: '情侣关系已解除', icon: 'none' });
setTimeout(function() {
wx.reLaunch({ url: '/pages/index/index' });
}, 2000);
if (status === 'completed') {
wx.removeStorageSync('coupleId'); wx.removeStorageSync('petHasPet');
require('../../utils/data-cache').clear();
return;
}
// 启动倒计时
if (status === 'pending' && remaining > 0) {
if ((status === 'pending' || status === 'cooling') && remaining > 0) {
self.startTimer(remaining);
// 如果是发起方,启动轮询检查对方是否已同意
if (self.data.isRequester) {
self.data._pollTimer = setInterval(function() {
api.unbindStatus().then(function(pollRes) {
if (pollRes.status === 'agreed') {
clearInterval(self.data._pollTimer);
self.data._pollTimer = null;
wx.removeStorageSync('coupleId');
wx.removeStorageSync('petHasPet');
wx.showToast({ title: '对方已同意解绑,正在跳转...', icon: 'none' });
setTimeout(function() {
wx.reLaunch({ url: '/pages/index/index' });
}, 2000);
}
}).catch(function() {});
}, 5000);
}
self.data._pollTimer = setInterval(function() { self.loadStatus(); }, 10000);
}
}).catch(function(err) {
self.setData({ loading: false, loadError:true });
@@ -107,12 +86,13 @@ Page({
startTimer: function(seconds) {
var self = this;
if (self.data._timer) clearInterval(self.data._timer);
self._deadline = Date.now() + seconds * 1000;
self.data._remaining = seconds;
self.data._timer = setInterval(function() {
self.data._remaining--;
self.data._remaining = Math.max(0, Math.ceil((self._deadline - Date.now()) / 1000));
if (self.data._remaining <= 0) {
clearInterval(self.data._timer);
self.setData({ status: 'expired', timerText: '已过期' });
self.loadStatus();
return;
}
self.setData({ timerText: self.formatRemaining(self.data._remaining) });
@@ -132,7 +112,7 @@ Page({
var self = this;
wx.showModal({
title: '💔 确认解绑',
content: '确定同意解除情侣绑定吗?\n\n确认后所有情侣记录(记忆日、日记、相册、歌曲、打卡)将被永久删除,且不可恢复!\n\n仅保留双方的个人资料。',
content: '同意后进入72小时冷静期,期间任一方可以取消。到期自动解除关系并永久删除共同数据,个人抽烟记录保留。',
cancelText: '再想想',
confirmText: '确认解绑',
confirmColor: '#FF4757',
@@ -141,11 +121,8 @@ Page({
wx.showLoading({ title: '处理中...' });
api.unbindRespond({ agree: true }).then(function() {
wx.hideLoading();
wx.showToast({ title: '已解除绑定', icon: 'success' });
wx.removeStorageSync('coupleId');
wx.removeStorageSync('petHasPet');
self.setData({ status: 'agreed' });
setTimeout(function() { wx.reLaunch({ url: '/pages/index/index' }); }, 1500);
wx.showToast({ title: '已进入72小时冷静期', icon: 'none' });
self.loadStatus();
}).catch(function(err) {
wx.hideLoading();
wx.showToast({ title: err.error || '操作失败', icon: 'none' });
@@ -193,7 +170,7 @@ Page({
api.unbindCancel().then(function() {
wx.hideLoading();
wx.showToast({ title: '已撤销', icon: 'success' });
self.setData({ status: 'cancelled' });
self.loadStatus();
}).catch(function(err) {
wx.hideLoading();
wx.showToast({ title: err.error || '操作失败', icon: 'none' });
@@ -204,6 +181,6 @@ Page({
},
goBack: function() { wx.navigateBack(); },
goHome: function() { wx.reLaunch({ url: '/pages/index/index' }); },
goToProfile: function() { wx.reLaunch({ url: '/pages/profile/profile' }); },
goHome: function() { wx.switchTab({ url: '/pages/index/index' }); },
goToProfile: function() { wx.switchTab({ url: '/pages/profile/profile' }); },
});
+13 -6
View File
@@ -43,7 +43,7 @@
</view>
<view class="unbind-info">
<text>发起时间:{{createdTime}}</text>
<text>⚠️ 确认解绑后,所有情侣记录将被永久删除</text>
<text>同意后进入72小时冷静期,期间任一方可取消</text>
</view>
<view class="unbind-actions" style="margin-top:32rpx;">
<button class="btn btn-primary" bindtap="agreeUnbind" style="background:#FF4757;">💔 同意解绑</button>
@@ -51,13 +51,20 @@
</view>
</view>
<view class="unbind-card" wx:elif="{{!loading && !loadError && status == 'cooling'}}">
<view class="unbind-icon">⏳</view><text class="unbind-title">72小时冷静期</text>
<text class="unbind-desc">冷静期内关系保留,双方均可撤销解绑;到期自动解绑并永久删除共同数据。个人抽烟记录保留。</text>
<view class="unbind-timer"><text class="timer-label">距正式解绑</text><text class="timer-value">{{timerText}}</text></view>
<button class="btn btn-outline" bindtap="cancelUnbind">撤销解绑,继续保留关系</button>
</view>
<!-- 已同意解绑 -->
<view class="unbind-card" wx:elif="{{!loading && !loadError && status == 'agreed'}}">
<view class="unbind-card" wx:elif="{{!loading && !loadError && status == 'completed'}}">
<view class="unbind-icon">💔</view>
<text class="unbind-title">已同意解绑</text>
<text class="unbind-desc">双方已确认解除情侣绑定,所有情侣数据已被永久删除</text>
<text class="unbind-title">解绑完成</text>
<text class="unbind-desc">冷静期已结束,已解除关系并删除共同数据。个人抽烟记录保留。</text>
<view class="unbind-info">
<text>回应时间:{{respondedTime}}</text>
<text>完成时间:{{completedTime}}</text>
</view>
<button class="btn btn-primary" bindtap="goHome" style="margin-top:32rpx;">返回首页</button>
</view>
@@ -77,7 +84,7 @@
<view class="unbind-card" wx:elif="{{!loading && !loadError && status == 'cancelled'}}">
<view class="unbind-icon">💕</view>
<text class="unbind-title">解绑请求已撤销</text>
<text class="unbind-desc">发起方已撤销了解绑请求</text>
<text class="unbind-desc">解绑已取消,关系继续保留</text>
<view class="unbind-info">
<text>撤销时间:{{respondedTime}}</text>
</view>
+5 -1
View File
@@ -1,6 +1,6 @@
/* pages/unbind/unbind.wxss - 情侣解绑确认页 */
@import '../../styles/common.wxss';
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; }
.container { padding: 24rpx; }
/* 加载状态 */
@@ -85,3 +85,7 @@ page { background: linear-gradient(180deg, #F4E2E3 0%, #FAF5EE 55%, #FAF5EE 100%
@import '../../styles/design.wxss';
@import '../../styles/journal.wxss';
@import '../../styles/button-theme.wxss';
@import '../../styles/typography.wxss';