2026-09-09 22:05:00 +08:00
|
|
|
/**
|
|
|
|
|
* 红娘服务进度页 U35
|
|
|
|
|
*/
|
|
|
|
|
const api = require('../../utils/api');
|
2026-10-15 09:47:31 +08:00
|
|
|
const { matchmakerService } = require('../../services');
|
2026-09-09 22:05:00 +08:00
|
|
|
|
|
|
|
|
Page({
|
|
|
|
|
data: {
|
|
|
|
|
service: null,
|
2026-10-15 09:47:31 +08:00
|
|
|
loading: true,
|
|
|
|
|
confirming: false
|
2026-09-09 22:05:00 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
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');
|
2026-10-15 09:47:31 +08:00
|
|
|
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 });
|
2026-09-09 22:05:00 +08:00
|
|
|
} 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 });
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2026-10-15 09:47:31 +08:00
|
|
|
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 });
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2026-09-09 22:05:00 +08:00
|
|
|
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';
|
|
|
|
|
}
|
|
|
|
|
});
|