CI/CD Pipeline / Test Shell Guard (Phase 23 Gate) (push) Canceled after 0s
CI/CD Pipeline / Backend Build & Test (push) Canceled after 0s
CI/CD Pipeline / Admin Web Build (push) Canceled after 0s
CI/CD Pipeline / Mini Program Compile Check (push) Canceled after 0s
CI/CD Pipeline / Migration Validation (push) Canceled after 0s
CI/CD Pipeline / UI Contracts (source-structure gates) (push) Canceled after 0s
CI/CD Pipeline / E2E (live stack) (push) Canceled after 0s
77 lines
2.8 KiB
TypeScript
77 lines
2.8 KiB
TypeScript
import { request } from '../../utils/requestPromise'
|
|
const app = getApp<{ globalData: { apiBase: string; uploadBase: 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 request<any>({
|
|
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 request<any>({
|
|
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 request<any>({
|
|
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' });
|
|
}
|
|
} catch (e) { wx.showToast({ title: '操作失败', icon: 'none' }); }
|
|
},
|
|
|
|
async onDecline() {
|
|
try {
|
|
await request<any>({
|
|
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' }); }
|
|
},
|
|
|
|
});
|