Files
WorkBuddy 3c2b967274
CI/CD Pipeline / UI Contracts (source-structure gates) (push) Canceled after 0s
CI/CD Pipeline / E2E (live stack) (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 / Test Shell Guard (Phase 23 Gate) (push) Canceled after 0s
release: freeze 2026-10-15 validated release baseline
2026-10-15 09:47:31 +08:00

89 lines
2.5 KiB
JavaScript

/**
* 红娘服务进度页 U35
*/
const api = require('../../utils/api');
const { matchmakerService } = require('../../services');
Page({
data: {
service: null,
loading: true,
confirming: false
},
onLoad() {
const lastServiceId = wx.getStorageSync('lastServiceId');
if (lastServiceId) {
this.loadService(lastServiceId);
} else {
this.loadMyServices();
}
},
async loadService(serviceId) {
this.setData({ loading: true });
try {
const token = wx.getStorageSync('accessToken');
const services = await api.get('/matchmaker/services', {}, { Authorization: `Bearer ${token}` });
const service = Array.isArray(services)
? services.find(item => (item.serviceId || item.id) === serviceId) : null;
this.setData({ service: service || null, loading: false });
} catch (err) {
this.setData({ loading: false });
}
},
async loadMyServices() {
this.setData({ loading: true });
try {
const token = wx.getStorageSync('accessToken');
const res = await api.get('/matchmaker/services', {}, { Authorization: `Bearer ${token}` });
if (res && res.length > 0) {
this.setData({ service: res[0], loading: false });
} else {
this.setData({ loading: false });
}
} catch (err) {
this.setData({ loading: false });
}
},
async onConfirmService() {
if (!this.data.service || this.data.service.status !== 'waiting_user' || this.data.confirming) return;
this.setData({ confirming: true });
try {
await matchmakerService.confirmService(this.data.service.serviceId || this.data.service.id);
wx.showToast({ title: '已确认', icon: 'success' });
await this.loadService(this.data.service.serviceId || this.data.service.id);
} catch (err) {
wx.showToast({ title: (err && err.message) || '确认失败,请稍后重试', icon: 'none' });
} finally {
this.setData({ confirming: false });
}
},
getStatusText(status) {
const map = {
'submitted': '已提交,等待分配',
'assigned': '已分配红娘',
'in_service': '红娘正在服务中',
'waiting_user': '等待您确认',
'completed': '服务已完成',
'cancelled': '已取消'
};
return map[status] || status;
},
getStatusColor(status) {
const map = {
'submitted': '#E59A32',
'assigned': '#17A2B8',
'in_service': '#E96B6B',
'waiting_user': '#E59A32',
'completed': '#2E9B68',
'cancelled': '#999'
};
return map[status] || '#999';
}
});