feat: 完善双端演示注册与红娘服务闭环

This commit is contained in:
WorkBuddy
2026-10-21 23:41:47 +08:00
parent afee993626
commit 39a18a50ee
63 changed files with 1298 additions and 217 deletions
@@ -4,10 +4,13 @@ Page({
data: {
serviceId: '',
detail: null,
source: 'assignment',
statusLabel: '',
followups: [],
followupTypes: ['followup', '需求了解', '候选建议', '活动协助', '其他'],
loading: true,
submitting: false,
changingStatus: false,
form: { followupType: 'followup', content: '', nextFollowupAt: '' },
},
@@ -18,7 +21,7 @@ Page({
wx.navigateBack();
return;
}
this.setData({ serviceId });
this.setData({ serviceId, source: options.source === 'management' ? 'management' : 'assignment' });
this.loadDetail();
},
@@ -34,8 +37,10 @@ Page({
async loadDetail() {
this.setData({ loading: true });
try {
const detail = await api.get(`/operator/matchmaker/services/${this.data.serviceId}`, {}, this.tokenHeaders());
this.setData({ detail: detail || null, followups: (detail && detail.followups) || [] });
const path = this.data.source === 'management' ? '/operator/matchmaker/management/services/' : '/operator/matchmaker/services/';
const detail = await api.get(`${path}${encodeURIComponent(this.data.serviceId)}`, {}, this.tokenHeaders());
const labels = { submitted: '待处理', assigned: '已接单', in_service: '服务中', waiting_user: '待用户确认', completed: '已完成' };
this.setData({ detail: detail || null, statusLabel: labels[detail && detail.status] || (detail && detail.status) || '', followups: (detail && detail.followups) || [] });
} catch (error) {
if (error && (error.code === 'FORBIDDEN' || error.code === 'NOT_FOUND' || error.code === 'DATA_SCOPE_DENIED')) {
wx.showModal({ title: '服务权限已变更', content: '该服务对象已结束或不再属于当前服务范围。', showCancel: false,
@@ -48,6 +53,21 @@ Page({
}
},
async changeStatus(e) {
const action = e.currentTarget.dataset.action;
if (this.data.changingStatus || this.data.source === 'management') return;
this.setData({ changingStatus: true });
try {
await api.post(`/operator/matchmaker/services/${encodeURIComponent(this.data.serviceId)}/${action}`, {}, this.tokenHeaders());
wx.showToast({ title: action === 'start' ? '服务已开始' : '服务已完成', icon: 'success' });
await this.loadDetail();
} catch (err) {
wx.showToast({ title: err.message || '操作失败', icon: 'none' });
} finally {
this.setData({ changingStatus: false });
}
},
onTypeChange(e) { this.setData({ 'form.followupType': this.data.followupTypes[Number(e.detail.value)] || 'followup' }); },
onContentInput(e) { this.setData({ 'form.content': e.detail.value }); },
onNextFollowupInput(e) { this.setData({ 'form.nextFollowupAt': e.detail.value }); },