2026-09-09 22:05:00 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 红娘工作台主页
|
2026-10-09 22:46:32 +08:00
|
|
|
|
*
|
|
|
|
|
|
* ZC-MM-002(A1 / DEC-MATCHMAKER-002 锁定决策):
|
|
|
|
|
|
* - 普通红娘禁止认领(原 POST /services/{id}/claim 端点已删除),本页不再有任何接单逻辑;
|
|
|
|
|
|
* - 列表数据源从 GET /operator/matchmaker/pending(现仅分配权持有者可调,普通红娘 403)
|
|
|
|
|
|
* 改为 GET /operator/matchmaker/assignments/my(仅返回本人生效中的服务对象分配)。
|
|
|
|
|
|
* 响应为 assignment 字段(userId/assignmentReason/status/assignedAt/serviceId 等),
|
|
|
|
|
|
* 无服务类型/诉求描述字段,故按实际字段精简展示,不前端拼空值。
|
|
|
|
|
|
*
|
2026-09-09 22:05:00 +08:00
|
|
|
|
* 展示待处理服务、工作台数据概览
|
|
|
|
|
|
*/
|
|
|
|
|
|
const api = require('../../utils/api');
|
|
|
|
|
|
|
|
|
|
|
|
Page({
|
|
|
|
|
|
data: {
|
|
|
|
|
|
operatorName: '',
|
|
|
|
|
|
pendingCount: 0,
|
|
|
|
|
|
inProgressCount: 0,
|
|
|
|
|
|
todayCount: 0,
|
|
|
|
|
|
completedCount: 0,
|
2026-10-09 22:46:32 +08:00
|
|
|
|
myAssignments: [],
|
|
|
|
|
|
assignmentCount: 0,
|
2026-09-09 22:05:00 +08:00
|
|
|
|
loading: true,
|
|
|
|
|
|
currentDate: '',
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
onLoad() {
|
|
|
|
|
|
wx.setNavigationBarTitle({ title: '红娘工作台' });
|
|
|
|
|
|
// 获取操作员信息
|
|
|
|
|
|
const operatorName = wx.getStorageSync('operatorName') || '红娘';
|
|
|
|
|
|
this.setData({ operatorName });
|
2026-10-09 22:46:32 +08:00
|
|
|
|
|
2026-09-09 22:05:00 +08:00
|
|
|
|
// 设置当前日期
|
|
|
|
|
|
const now = new Date();
|
|
|
|
|
|
const dateStr = `${now.getFullYear()}年${now.getMonth() + 1}月${now.getDate()}日`;
|
|
|
|
|
|
this.setData({ currentDate: dateStr });
|
2026-10-09 22:46:32 +08:00
|
|
|
|
|
2026-09-09 22:05:00 +08:00
|
|
|
|
this.loadDashboard();
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
onShow() {
|
|
|
|
|
|
// 每次显示刷新数据
|
|
|
|
|
|
this.loadDashboard();
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
async loadDashboard() {
|
|
|
|
|
|
this.setData({ loading: true });
|
|
|
|
|
|
try {
|
|
|
|
|
|
const token = wx.getStorageSync('operatorToken');
|
|
|
|
|
|
if (!token) {
|
|
|
|
|
|
wx.redirectTo({ url: '/pages/matchmaker-login/matchmaker-login' });
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-09 22:46:32 +08:00
|
|
|
|
// 加载工作台数据 + 本人服务对象分配(ZC-MM-002:不再调用 /pending,普通红娘无该权限)
|
|
|
|
|
|
const [dashRes, assignmentRes] = await Promise.all([
|
2026-09-09 22:05:00 +08:00
|
|
|
|
api.get('/operator/matchmaker/dashboard', {}, { Authorization: `Bearer ${token}` }),
|
2026-10-09 22:46:32 +08:00
|
|
|
|
api.get('/operator/matchmaker/assignments/my', {}, { Authorization: `Bearer ${token}` }),
|
2026-09-09 22:05:00 +08:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
if (dashRes.success) {
|
|
|
|
|
|
this.setData({
|
|
|
|
|
|
pendingCount: dashRes.data.pendingCount || 0,
|
|
|
|
|
|
inProgressCount: dashRes.data.inProgressCount || 0,
|
|
|
|
|
|
todayCount: dashRes.data.todayCount || 0,
|
|
|
|
|
|
completedCount: dashRes.data.completedCount || 0,
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-09 22:46:32 +08:00
|
|
|
|
if (assignmentRes.success) {
|
|
|
|
|
|
const assignments = assignmentRes.data || [];
|
2026-09-09 22:05:00 +08:00
|
|
|
|
this.setData({
|
2026-10-09 22:46:32 +08:00
|
|
|
|
myAssignments: assignments,
|
|
|
|
|
|
assignmentCount: assignments.length,
|
2026-09-09 22:05:00 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
console.error('加载工作台数据失败:', err);
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
this.setData({ loading: false });
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
onViewService(e) {
|
|
|
|
|
|
const serviceId = e.currentTarget.dataset.id;
|
2026-10-09 22:46:32 +08:00
|
|
|
|
if (!serviceId) {
|
|
|
|
|
|
// 纯用户级分配(无关联服务单)无处可跳,不拼空参数
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2026-09-09 22:05:00 +08:00
|
|
|
|
wx.navigateTo({ url: `/pages/matchmaker-service-detail/matchmaker-service-detail?id=${serviceId}` });
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2026-10-09 22:46:32 +08:00
|
|
|
|
// 分配状态 → 中文(避免枚举码直接上屏,见 profileLabels 铁律)
|
|
|
|
|
|
assignmentStatusLabel(code) {
|
|
|
|
|
|
const labels = {
|
|
|
|
|
|
active: '生效中',
|
|
|
|
|
|
ended: '已结束',
|
|
|
|
|
|
revoked: '已撤销',
|
|
|
|
|
|
transferred: '已转分配',
|
|
|
|
|
|
expired: '已过期',
|
|
|
|
|
|
};
|
|
|
|
|
|
return labels[code] || code || '';
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 分配范围 → 中文
|
|
|
|
|
|
assignmentScopeLabel(code) {
|
|
|
|
|
|
const labels = { primary: '主责', collaborating: '协同' };
|
|
|
|
|
|
return labels[code] || code || '';
|
2026-09-09 22:05:00 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
formatTime(timeStr) {
|
|
|
|
|
|
if (!timeStr) return '';
|
|
|
|
|
|
const date = new Date(timeStr);
|
|
|
|
|
|
const now = new Date();
|
|
|
|
|
|
const diff = now - date;
|
|
|
|
|
|
const days = Math.floor(diff / 86400000);
|
|
|
|
|
|
if (days === 0) return '今天';
|
|
|
|
|
|
if (days === 1) return '昨天';
|
|
|
|
|
|
if (days < 7) return days + '天前';
|
|
|
|
|
|
const m = date.getMonth() + 1;
|
|
|
|
|
|
const d = date.getDate();
|
|
|
|
|
|
return m + '月' + d + '日';
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
onLogout() {
|
|
|
|
|
|
wx.showModal({
|
|
|
|
|
|
title: '退出登录',
|
|
|
|
|
|
content: '确定要退出登录吗?',
|
|
|
|
|
|
success: (res) => {
|
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
|
wx.removeStorageSync('operatorToken');
|
|
|
|
|
|
wx.removeStorageSync('operatorName');
|
|
|
|
|
|
wx.reLaunch({ url: '/pages/matchmaker-login/matchmaker-login' });
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|