init: initial commit

This commit is contained in:
2026-10-07 09:28:43 +08:00
commit a68a4ef411
251 changed files with 38279 additions and 0 deletions
+209
View File
@@ -0,0 +1,209 @@
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: '',
_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,
});
if (!self._visible) return;
// 清除之前的轮询
if (self.data._pollTimer) {
clearInterval(self.data._pollTimer);
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);
return;
}
// 启动倒计时
if (status === 'pending' && 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);
}
}
}).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.data._remaining = seconds;
self.data._timer = setInterval(function() {
self.data._remaining--;
if (self.data._remaining <= 0) {
clearInterval(self.data._timer);
self.setData({ status: 'expired', timerText: '已过期' });
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: '确定同意解除情侣绑定吗?\n\n确认后所有情侣记录(记忆日、日记、相册、歌曲、打卡)将被永久删除,且不可恢复!\n\n仅保留双方的个人资料。',
cancelText: '再想想',
confirmText: '确认解绑',
confirmColor: '#FF4757',
success: function(res) {
if (res.confirm) {
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);
}).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.setData({ status: 'cancelled' });
}).catch(function(err) {
wx.hideLoading();
wx.showToast({ title: err.error || '操作失败', icon: 'none' });
});
}
}
});
},
goBack: function() { wx.navigateBack(); },
goHome: function() { wx.reLaunch({ url: '/pages/index/index' }); },
goToProfile: function() { wx.reLaunch({ url: '/pages/profile/profile' }); },
});
+8
View File
@@ -0,0 +1,8 @@
{
"navigationBarTitleText": "解除绑定",
"navigationStyle": "custom",
"usingComponents": {
"app-nav": "/components/app-nav/app-nav",
"page-state": "/components/page-state/page-state"
}
}
+103
View File
@@ -0,0 +1,103 @@
<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>⚠️ 确认解绑后,所有情侣记录将被永久删除</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 == 'agreed'}}">
<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="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>
+87
View File
@@ -0,0 +1,87 @@
/* pages/unbind/unbind.wxss - 情侣解绑确认页 */
@import '../../styles/common.wxss';
page { background: linear-gradient(180deg, #F4E2E3 0%, #FAF5EE 55%, #FAF5EE 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';