更新最新代码
This commit is contained in:
@@ -0,0 +1,186 @@
|
||||
const { getLayout } = require('../../utils/layout');
|
||||
// pages/unbind/unbind.js - 情侣解绑确认页
|
||||
const { api } = require('../../utils/request');
|
||||
|
||||
Page({
|
||||
onResize: function() { this.setData(getLayout()); },
|
||||
data: {
|
||||
loading: true, loadError: false,
|
||||
status: 'none',
|
||||
isRequester: false,
|
||||
requesterName: '',
|
||||
remaining: 0,
|
||||
timerText: '',
|
||||
createdTime: '',
|
||||
respondedTime: '',
|
||||
completedTime: '',
|
||||
_timer: null,
|
||||
},
|
||||
|
||||
onLoad: function() {
|
||||
this.setData(getLayout());
|
||||
},
|
||||
|
||||
onShow: function() {
|
||||
this._visible = true;
|
||||
// 每次页面显示时重新加载状态(对方可能已经操作了)
|
||||
this.loadStatus();
|
||||
},
|
||||
|
||||
onHide: function() { this._visible = false; this.stopTimers(); },
|
||||
onUnload: function() { this._visible = false; this.stopTimers(); },
|
||||
stopTimers: function() {
|
||||
if (this.data._timer) clearInterval(this.data._timer);
|
||||
if (this.data._pollTimer) clearInterval(this.data._pollTimer);
|
||||
this.data._timer = null;
|
||||
this.data._pollTimer = null;
|
||||
},
|
||||
|
||||
loadStatus: function() {
|
||||
if (this._statusLoading) return;
|
||||
this._statusLoading = true;
|
||||
var self = this;
|
||||
self.stopTimers();
|
||||
self.setData({ loading: true, loadError:false });
|
||||
api.unbindStatus().then(function(res) {
|
||||
var status = res.status || 'none';
|
||||
var remaining = res.remaining_seconds || 0;
|
||||
var timerText = self.formatRemaining(remaining);
|
||||
var createdTime = res.created_at ? res.created_at.substring(0, 16).replace('T', ' ') : '';
|
||||
var respondedTime = res.responded_at ? res.responded_at.substring(0, 16).replace('T', ' ') : '';
|
||||
|
||||
self.setData({
|
||||
loading: false,
|
||||
status: status,
|
||||
isRequester: !!res.is_requester,
|
||||
requesterName: res.requester_name || '对方',
|
||||
remaining: remaining,
|
||||
timerText: timerText,
|
||||
createdTime: createdTime,
|
||||
respondedTime: respondedTime,
|
||||
completedTime: res.completed_at ? res.completed_at.substring(0, 16).replace('T', ' ') : '',
|
||||
});
|
||||
|
||||
if (!self._visible) return;
|
||||
|
||||
// 清除之前的轮询
|
||||
if (self.data._pollTimer) {
|
||||
clearInterval(self.data._pollTimer);
|
||||
self.data._pollTimer = null;
|
||||
}
|
||||
|
||||
if (status === 'completed') {
|
||||
wx.removeStorageSync('coupleId'); wx.removeStorageSync('petHasPet');
|
||||
require('../../utils/data-cache').clear();
|
||||
return;
|
||||
}
|
||||
if ((status === 'pending' || status === 'cooling') && remaining > 0) {
|
||||
self.startTimer(remaining);
|
||||
self.data._pollTimer = setInterval(function() { self.loadStatus(); }, 10000);
|
||||
}
|
||||
}).catch(function(err) {
|
||||
self.setData({ loading: false, loadError:true });
|
||||
}).finally(function() { self._statusLoading = false; });
|
||||
},
|
||||
|
||||
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 = Math.max(0, Math.ceil((self._deadline - Date.now()) / 1000));
|
||||
if (self.data._remaining <= 0) {
|
||||
clearInterval(self.data._timer);
|
||||
self.loadStatus();
|
||||
return;
|
||||
}
|
||||
self.setData({ timerText: self.formatRemaining(self.data._remaining) });
|
||||
}, 1000);
|
||||
},
|
||||
|
||||
formatRemaining: function(seconds) {
|
||||
if (seconds <= 0) return '已过期';
|
||||
var h = Math.floor(seconds / 3600);
|
||||
var m = Math.floor((seconds % 3600) / 60);
|
||||
var s = seconds % 60;
|
||||
return h + '时 ' + m + '分 ' + s + '秒';
|
||||
},
|
||||
|
||||
// 同意解绑
|
||||
agreeUnbind: function() {
|
||||
var self = this;
|
||||
wx.showModal({
|
||||
title: '💔 确认解绑',
|
||||
content: '同意后进入72小时冷静期,期间任一方可以取消。到期自动解除关系并永久删除共同数据,个人抽烟记录保留。',
|
||||
cancelText: '再想想',
|
||||
confirmText: '确认解绑',
|
||||
confirmColor: '#FF4757',
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
wx.showLoading({ title: '处理中...' });
|
||||
api.unbindRespond({ agree: true }).then(function() {
|
||||
wx.hideLoading();
|
||||
wx.showToast({ title: '已进入72小时冷静期', icon: 'none' });
|
||||
self.loadStatus();
|
||||
}).catch(function(err) {
|
||||
wx.hideLoading();
|
||||
wx.showToast({ title: err.error || '操作失败', icon: 'none' });
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 拒绝解绑
|
||||
rejectUnbind: function() {
|
||||
var self = this;
|
||||
wx.showModal({
|
||||
title: '拒绝解绑',
|
||||
content: '确定拒绝对方的解绑请求吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '拒绝解绑',
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
wx.showLoading({ title: '处理中...' });
|
||||
api.unbindRespond({ agree: false }).then(function() {
|
||||
wx.hideLoading();
|
||||
wx.showToast({ title: '已拒绝解绑', icon: 'success' });
|
||||
self.setData({ status: 'rejected' });
|
||||
}).catch(function(err) {
|
||||
wx.hideLoading();
|
||||
wx.showToast({ title: err.error || '操作失败', icon: 'none' });
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 撤销解绑请求
|
||||
cancelUnbind: function() {
|
||||
var self = this;
|
||||
wx.showModal({
|
||||
title: '撤销请求',
|
||||
content: '确定撤销解绑请求吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '撤销',
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
wx.showLoading({ title: '处理中...' });
|
||||
api.unbindCancel().then(function() {
|
||||
wx.hideLoading();
|
||||
wx.showToast({ title: '已撤销', icon: 'success' });
|
||||
self.loadStatus();
|
||||
}).catch(function(err) {
|
||||
wx.hideLoading();
|
||||
wx.showToast({ title: err.error || '操作失败', icon: 'none' });
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
goBack: function() { wx.navigateBack(); },
|
||||
goHome: function() { wx.switchTab({ url: '/pages/index/index' }); },
|
||||
goToProfile: function() { wx.switchTab({ url: '/pages/profile/profile' }); },
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"navigationBarTitleText": "解除绑定",
|
||||
"navigationStyle": "custom",
|
||||
"usingComponents": {
|
||||
"app-nav": "/components/app-nav/app-nav",
|
||||
"page-state": "/components/page-state/page-state"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<view class="app-shell app-shell--secondary" style="{{layoutStyle}}">
|
||||
<launch-transition />
|
||||
<!-- pages/unbind/unbind.wxml - 情侣解绑确认页 -->
|
||||
<app-nav title="解绑" back="{{true}}" />
|
||||
|
||||
<scroll-view class="page-bg" scroll-y show-scrollbar="{{false}}" bounces="{{true}}">
|
||||
<view class="container" style="padding-top:120rpx;">
|
||||
|
||||
<!-- 加载中 -->
|
||||
<page-state wx:if="{{loading}}" kind="loading" title="正在获取解绑状态" /><page-state wx:elif="{{loadError}}" kind="error" title="解绑状态加载失败" action="重试" bind:action="loadStatus" />
|
||||
|
||||
<!-- 无解绑请求 -->
|
||||
<view class="empty-state" wx:elif="{{!loading && !loadError && status == 'none'}}">
|
||||
<text class="empty-icon">💕</text>
|
||||
<text class="empty-title">当前没有解绑请求</text>
|
||||
<text class="empty-desc">在设置页面可以发起解绑</text>
|
||||
</view>
|
||||
|
||||
<!-- 待对方确认(我是发起方) -->
|
||||
<view class="unbind-card" wx:elif="{{!loading && !loadError && status == 'pending' && isRequester}}">
|
||||
<view class="unbind-icon">⏳</view>
|
||||
<text class="unbind-title">解绑请求已发送</text>
|
||||
<text class="unbind-desc">等待对方确认同意解绑</text>
|
||||
<view class="unbind-timer" wx:if="{{remaining > 0}}">
|
||||
<text class="timer-label">剩余时间</text>
|
||||
<text class="timer-value">{{timerText}}</text>
|
||||
</view>
|
||||
<view class="unbind-info">
|
||||
<text>发起时间:{{createdTime}}</text>
|
||||
<text>状态:待对方确认</text>
|
||||
</view>
|
||||
<button class="btn btn-outline" bindtap="cancelUnbind" style="margin-top:32rpx;border-color:#FF4757;color:#FF4757;">撤销解绑请求</button>
|
||||
</view>
|
||||
|
||||
<!-- 待我确认(我是对方) -->
|
||||
<view class="unbind-card" wx:elif="{{!loading && !loadError && status == 'pending' && !isRequester}}">
|
||||
<view class="unbind-icon">💔</view>
|
||||
<text class="unbind-title">{{requesterName}} 发起了解绑请求</text>
|
||||
<text class="unbind-desc">对方希望解除情侣绑定,请确认或拒绝</text>
|
||||
<view class="unbind-timer" wx:if="{{remaining > 0}}">
|
||||
<text class="timer-label">剩余时间</text>
|
||||
<text class="timer-value">{{timerText}}</text>
|
||||
</view>
|
||||
<view class="unbind-info">
|
||||
<text>发起时间:{{createdTime}}</text>
|
||||
<text>同意后进入72小时冷静期,期间任一方可取消</text>
|
||||
</view>
|
||||
<view class="unbind-actions" style="margin-top:32rpx;">
|
||||
<button class="btn btn-primary" bindtap="agreeUnbind" style="background:#FF4757;">💔 同意解绑</button>
|
||||
<button class="btn btn-outline" bindtap="rejectUnbind" style="margin-top:16rpx;">拒绝解绑</button>
|
||||
</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 == 'completed'}}">
|
||||
<view class="unbind-icon">💔</view>
|
||||
<text class="unbind-title">解绑完成</text>
|
||||
<text class="unbind-desc">冷静期已结束,已解除关系并删除共同数据。个人抽烟记录保留。</text>
|
||||
<view class="unbind-info">
|
||||
<text>完成时间:{{completedTime}}</text>
|
||||
</view>
|
||||
<button class="btn btn-primary" bindtap="goHome" style="margin-top:32rpx;">返回首页</button>
|
||||
</view>
|
||||
|
||||
<!-- 已拒绝解绑 -->
|
||||
<view class="unbind-card" wx:elif="{{!loading && !loadError && status == 'rejected'}}">
|
||||
<view class="unbind-icon">💕</view>
|
||||
<text class="unbind-title">解绑请求已被拒绝</text>
|
||||
<text class="unbind-desc">对方拒绝了你的解绑请求</text>
|
||||
<view class="unbind-info">
|
||||
<text>拒绝时间:{{respondedTime}}</text>
|
||||
</view>
|
||||
<button class="btn btn-primary" bindtap="goBack" style="margin-top:32rpx;">返回</button>
|
||||
</view>
|
||||
|
||||
<!-- 已撤销 -->
|
||||
<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>
|
||||
<view class="unbind-info">
|
||||
<text>撤销时间:{{respondedTime}}</text>
|
||||
</view>
|
||||
<button class="btn btn-primary" bindtap="goBack" style="margin-top:32rpx;">返回</button>
|
||||
</view>
|
||||
|
||||
<!-- 已过期 -->
|
||||
<view class="unbind-card" wx:elif="{{!loading && !loadError && status == 'expired'}}">
|
||||
<view class="unbind-icon">⏰</view>
|
||||
<text class="unbind-title">解绑请求已过期</text>
|
||||
<text class="unbind-desc">超过72小时未回应,解绑请求已自动取消</text>
|
||||
<view class="unbind-info">
|
||||
<text>发起时间:{{createdTime}}</text>
|
||||
</view>
|
||||
<button class="btn btn-primary" bindtap="goBack" style="margin-top:32rpx;">返回</button>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
|
||||
|
||||
</view>
|
||||
@@ -0,0 +1,91 @@
|
||||
/* pages/unbind/unbind.wxss - 情侣解绑确认页 */
|
||||
@import '../../styles/common.wxss';
|
||||
page { background: linear-gradient(180deg, #FDE4EC 0%, #FFF0F5 48%, #FFF7FA 100%); height: 100vh; overflow: hidden; }
|
||||
.container { padding: 24rpx; }
|
||||
|
||||
/* 加载状态 */
|
||||
.loading-state { text-align: center; padding: 200rpx 40rpx; }
|
||||
.loading-icon { font-size: 64rpx; display: block; margin-bottom: 16rpx; }
|
||||
.loading-text { font-size: 28rpx; color: #999; }
|
||||
|
||||
/* 空状态 */
|
||||
.empty-state { text-align: center; padding: 200rpx 40rpx; }
|
||||
.empty-icon { font-size: 80rpx; display: block; margin-bottom: 16rpx; }
|
||||
.empty-title { font-size: 30rpx; color: #999; display: block; margin-bottom: 8rpx; }
|
||||
.empty-desc { font-size: 24rpx; color: #bbb; display: block; }
|
||||
|
||||
/* 解绑卡片 */
|
||||
.unbind-card {
|
||||
background: white;
|
||||
border-radius: 28rpx;
|
||||
padding: 48rpx 36rpx;
|
||||
box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.06);
|
||||
text-align: center;
|
||||
margin-top: 60rpx;
|
||||
}
|
||||
|
||||
.unbind-icon { font-size: 80rpx; display: block; margin-bottom: 24rpx; }
|
||||
|
||||
.unbind-title {
|
||||
font-size: 34rpx;
|
||||
font-weight: 700;
|
||||
color: #333;
|
||||
display: block;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.unbind-desc {
|
||||
font-size: 26rpx;
|
||||
color: #888;
|
||||
display: block;
|
||||
line-height: 1.6;
|
||||
margin-bottom: 28rpx;
|
||||
}
|
||||
|
||||
/* 倒计时 */
|
||||
.unbind-timer {
|
||||
background: #FFF8E1;
|
||||
border-radius: 20rpx;
|
||||
padding: 20rpx;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
.timer-label {
|
||||
font-size: 24rpx;
|
||||
color: #FF9800;
|
||||
display: block;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
.timer-value {
|
||||
font-size: 48rpx;
|
||||
font-weight: 800;
|
||||
color: #FF5722;
|
||||
display: block;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* 信息区 */
|
||||
.unbind-info {
|
||||
background: #F9F9F9;
|
||||
border-radius: 16rpx;
|
||||
padding: 20rpx;
|
||||
text-align: left;
|
||||
}
|
||||
.unbind-info text {
|
||||
font-size: 24rpx;
|
||||
color: #888;
|
||||
display: block;
|
||||
margin-bottom: 6rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.unbind-info text:last-child { margin-bottom: 0; }
|
||||
|
||||
/* 按钮区域 */
|
||||
.unbind-actions { display: flex; flex-direction: column; gap: 12rpx; }
|
||||
|
||||
@import '../../styles/design.wxss';
|
||||
|
||||
@import '../../styles/journal.wxss';
|
||||
|
||||
@import '../../styles/button-theme.wxss';
|
||||
|
||||
@import '../../styles/typography.wxss';
|
||||
Reference in New Issue
Block a user