同步小程序与管理端更新,完善抽烟记录和解绑冷静期
This commit is contained in:
@@ -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' }); },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user