chore: establish V1.1 recovery baseline
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
* 活动反馈页 U32
|
||||
* 活动结束后开放,用户评价 + 表达进一步了解意向
|
||||
*/
|
||||
const api = require('../../utils/api');
|
||||
|
||||
Page({
|
||||
data: {
|
||||
activityId: '',
|
||||
activityTitle: '',
|
||||
activityEndAt: '',
|
||||
overallExperience: '', // very_satisfied / satisfied / normal / dissatisfied
|
||||
willingNextTime: '', // willing / maybe / not_now
|
||||
metSomeoneInteresting: null, // true / false / null
|
||||
otherParticipants: [],
|
||||
selectedInterests: [],
|
||||
submitting: false,
|
||||
feedbackSubmitted: false
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
if (options.id) {
|
||||
this.setData({ activityId: options.id });
|
||||
this.loadData();
|
||||
}
|
||||
},
|
||||
|
||||
async loadData() {
|
||||
try {
|
||||
const token = wx.getStorageSync('accessToken');
|
||||
// 加载活动信息
|
||||
const activityRes = await api.get(`/activities/${this.data.activityId}`, {}, {
|
||||
Authorization: `Bearer ${token}`
|
||||
});
|
||||
this.setData({
|
||||
activityTitle: activityRes.title,
|
||||
activityEndAt: activityRes.endAt
|
||||
});
|
||||
|
||||
// 加载同活动已签到用户列表(仅用于选择意向对象)
|
||||
const partsRes = await api.get(`/activities/${this.data.activityId}/participants`, {}, {
|
||||
Authorization: `Bearer ${token}`
|
||||
});
|
||||
this.setData({
|
||||
otherParticipants: (partsRes || []).filter(p => p.userId !== wx.getStorageSync('userId'))
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('加载失败', err);
|
||||
}
|
||||
},
|
||||
|
||||
onOverallChange(e) {
|
||||
this.setData({ overallExperience: e.currentTarget.dataset.value });
|
||||
},
|
||||
|
||||
onWillingChange(e) {
|
||||
this.setData({ willingNextTime: e.currentTarget.dataset.value });
|
||||
},
|
||||
|
||||
onMetSomeoneChange(e) {
|
||||
this.setData({ metSomeoneInteresting: e.currentTarget.dataset.value === 'yes' ? true : false });
|
||||
},
|
||||
|
||||
toggleInterest(userId) {
|
||||
const selected = this.data.selectedInterests;
|
||||
const idx = selected.indexOf(userId);
|
||||
if (idx >= 0) {
|
||||
selected.splice(idx, 1);
|
||||
} else {
|
||||
selected.push(userId);
|
||||
}
|
||||
this.setData({ selectedInterests: selected });
|
||||
},
|
||||
|
||||
async submitFeedback() {
|
||||
const { overallExperience, willingNextTime, metSomeoneInteresting, selectedInterests, activityId } = this.data;
|
||||
|
||||
if (!overallExperience || !willingNextTime) {
|
||||
wx.showToast({ title: '请填写必填项', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
this.setData({ submitting: true });
|
||||
try {
|
||||
const token = wx.getStorageSync('accessToken');
|
||||
const body = {
|
||||
overallExperience,
|
||||
willingNextTime,
|
||||
metSomeoneInteresting,
|
||||
interestTargetUserIds: selectedInterests
|
||||
};
|
||||
const res = await api.post(`/activities/${activityId}/feedback`, body, {
|
||||
Authorization: `Bearer ${token}`
|
||||
});
|
||||
this.setData({ feedbackSubmitted: true, submitting: false });
|
||||
if ((res.newMutuals || []).length > 0) {
|
||||
wx.showModal({
|
||||
title: '双向匹配成功!',
|
||||
content: `您与${res.newMutuals.length}位朋友互相表达了进一步了解意愿,快去缘分中心看看吧`,
|
||||
showCancel: false,
|
||||
success: () => {
|
||||
wx.switchTab({ url: '/pages/fate-center/fate-center' });
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
wx.showToast({ title: err.message || '提交失败', icon: 'none' });
|
||||
this.setData({ submitting: false });
|
||||
}
|
||||
},
|
||||
|
||||
skipFeedback() {
|
||||
wx.navigateBack();
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user