chore: establish V1.1 recovery baseline
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
// pages/activity-mutual-waiting/activity-mutual-waiting.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"usingComponents": {},
|
||||
"navigationBarTitleText": "等待确认"
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
const app = getApp<{ globalData: { apiBase: string; token: string } }>();
|
||||
|
||||
Page({
|
||||
data: {
|
||||
activityId: '', partnerId: '',
|
||||
partnerName: '', partnerAvatar: '',
|
||||
myConfirmed: false, bothConfirmed: false, partnerDeclined: false
|
||||
},
|
||||
|
||||
onLoad(options: any) {
|
||||
this.setData({ activityId: options.activityId, partnerId: options.partnerId });
|
||||
this.loadStatus();
|
||||
},
|
||||
|
||||
async loadStatus() {
|
||||
try {
|
||||
const res = await wx.request({
|
||||
url: `${app.globalData.apiBase}/activities/${this.data.activityId}/mutual/status/${this.data.partnerId}`,
|
||||
header: { 'Authorization': `Bearer ${app.globalData.token}` }
|
||||
});
|
||||
if (res.statusCode === 200 && res.data.success) {
|
||||
const d = res.data.data;
|
||||
this.setData({
|
||||
myConfirmed: d.myStatus === 'accepted',
|
||||
bothConfirmed: d.bothConfirmed,
|
||||
partnerDeclined: d.partnerStatus === 'declined'
|
||||
});
|
||||
}
|
||||
// 加载对方信息
|
||||
this.loadPartnerInfo();
|
||||
} catch (e) { console.error(e); }
|
||||
},
|
||||
|
||||
async loadPartnerInfo() {
|
||||
try {
|
||||
const res = await wx.request({
|
||||
url: `${app.globalData.apiBase}/profiles/${this.data.partnerId}`,
|
||||
header: { 'Authorization': `Bearer ${app.globalData.token}` }
|
||||
});
|
||||
if (res.statusCode === 200 && res.data.success) {
|
||||
this.setData({ partnerName: res.data.data?.displayName || '新朋友',
|
||||
partnerAvatar: res.data.data?.avatarFileId ? `${app.globalData.uploadBase}/files/${res.data.data.avatarFileId}` : '' });
|
||||
}
|
||||
} catch (e) { /* ignore */ }
|
||||
},
|
||||
|
||||
async onConfirm() {
|
||||
try {
|
||||
const res = await wx.request({
|
||||
url: `${app.globalData.apiBase}/activities/${this.data.activityId}/mutual/confirm`,
|
||||
method: 'POST',
|
||||
header: { 'Authorization': `Bearer ${app.globalData.token}`, 'Content-Type': 'application/json' },
|
||||
data: { partnerId: this.data.partnerId }
|
||||
});
|
||||
if (res.statusCode === 200 && res.data.success) {
|
||||
this.setData({ myConfirmed: true, bothConfirmed: res.data.data.bothConfirmed });
|
||||
if (res.data.data.bothConfirmed) {
|
||||
wx.showToast({ title: '双方已确认!', icon: 'success' });
|
||||
setTimeout(() => this.openChat(), 1500);
|
||||
}
|
||||
}
|
||||
} catch (e) { wx.showToast({ title: '操作失败', icon: 'none' }); }
|
||||
},
|
||||
|
||||
async onDecline() {
|
||||
try {
|
||||
await wx.request({
|
||||
url: `${app.globalData.apiBase}/activities/${this.data.activityId}/mutual/decline`,
|
||||
method: 'POST',
|
||||
header: { 'Authorization': `Bearer ${app.globalData.token}`, 'Content-Type': 'application/json' },
|
||||
data: { partnerId: this.data.partnerId }
|
||||
});
|
||||
this.setData({ myConfirmed: false, bothConfirmed: false });
|
||||
wx.navigateBack();
|
||||
} catch (e) { wx.showToast({ title: '操作失败', icon: 'none' }); }
|
||||
},
|
||||
|
||||
openChat() {
|
||||
wx.navigateTo({ url: `/pages/chat/chat?partnerId=${this.data.partnerId}` });
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
<view class="container">
|
||||
<view class="header">
|
||||
<image class="avatar" src="{{partnerAvatar || '/images/default-avatar.png'}}" mode="aspectFill" />
|
||||
<text class="partner-name">{{partnerName || '新朋友'}}</text>
|
||||
</view>
|
||||
|
||||
<view class="status-section" wx:if="{{bothConfirmed}}">
|
||||
<view class="success-icon">✅</view>
|
||||
<text class="success-title">双方已确认!</text>
|
||||
<text class="success-hint">你们可以开始聊天了</text>
|
||||
<button class="chat-btn" bindtap="openChat">开启聊天</button>
|
||||
</view>
|
||||
|
||||
<view class="status-section" wx:elif="{{myConfirmed}}">
|
||||
<view class="waiting-icon">⏳</view>
|
||||
<text class="waiting-title">已发送邀请</text>
|
||||
<text class="waiting-hint">对方确认后你们可以开始聊天</text>
|
||||
<button class="decline-btn" bindtap="onDecline">暂不联系</button>
|
||||
</view>
|
||||
|
||||
<view class="status-section" wx:else>
|
||||
<view class="pending-icon">💬</view>
|
||||
<text class="pending-title">向Ta表达兴趣</text>
|
||||
<text class="pending-hint">双方确认后才能开启线上沟通</text>
|
||||
<button class="confirm-btn" bindtap="onConfirm">确认开启沟通</button>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,10 @@
|
||||
.container { padding: 40rpx 24rpx; min-height: 100vh; background: #f5f5f5; display: flex; flex-direction: column; align-items: center; }
|
||||
.header { text-align: center; margin-bottom: 40rpx; }
|
||||
.avatar { width: 120rpx; height: 120rpx; border-radius: 60rpx; background: #eee; }
|
||||
.partner-name { font-size: 36rpx; font-weight: bold; color: #333; display: block; margin-top: 16rpx; }
|
||||
.status-section { background: #fff; border-radius: 20rpx; padding: 48rpx 40rpx; width: 100%; text-align: center; box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06); }
|
||||
.success-icon, .waiting-icon, .pending-icon { font-size: 72rpx; margin-bottom: 20rpx; }
|
||||
.success-title, .waiting-title, .pending-title { font-size: 34rpx; font-weight: bold; color: #333; display: block; margin-bottom: 12rpx; }
|
||||
.success-hint, .waiting-hint, .pending-hint { font-size: 26rpx; color: #888; display: block; margin-bottom: 32rpx; }
|
||||
.chat-btn, .confirm-btn { background: linear-gradient(135deg, #FF6B6B, #EE5A24); color: #fff; border: none; border-radius: 44rpx; font-size: 30rpx; padding: 16rpx 60rpx; }
|
||||
.decline-btn { background: #f5f5f5; color: #999; border: none; border-radius: 44rpx; font-size: 28rpx; padding: 16rpx 60rpx; margin-top: 20rpx; }
|
||||
Reference in New Issue
Block a user