Files
danyang-match/miniapp/pages/matchmaker-workbench/matchmaker-workbench.js
T
WorkBuddy ca0db57f24 chore(release): 冻结 v1.1.0 版本
- 同步版本号:VERSION / backend pom / admin-web / miniapp 均升至 1.1.0
- 合并本轮代码审查修复(详见 docs/CODE-REVIEW-2026-09-24.md):
  - 后端:微信登录真实实现 RealWechatLoginProvider、实名核验真实实现 RealIdentityVerificationProvider(本地强校验 + 可配置第三方 + fail-closed/fail-fast)
  - 照片直传落库端点 POST /me/photos/confirm(fileKey 归属校验 + 对象存在性校验后 savePhoto)
  - 刷新 Token Redis TTL 修正(getExpirationMs()*2 的 4h → refreshExpirationMs 的 14 天)
  - 管理端 token 改为 HttpOnly Cookie + silent-refresh,移除 localStorage 明文存储与 30+ 处手工注入
  - 小程序:红娘接单鉴权头错位修复、serviceType 中文映射、生产域名可配置
- 隔离本地产物(.workbuddy/、*.bundle、*.dump、secrets、application-dev.yml 等已被 .gitignore 覆盖)

未验证项(打标签 ≠ 生产发布):
- 后端编译 / 单测未在本环境执行(Maven 慢、Docker DNS 受限)
- 管理端 登录→刷新→登出 端到端、小程序真机走查待人工验收
- 生产部署需注入 WECHAT_APP_ID / WECHAT_APP_SECRET、VERIFICATION_API_URL / VERIFICATION_API_KEY 与小程序生产域名
2026-09-30 12:10:00 +08:00

137 lines
4.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 红娘工作台主页
*
* 展示待处理服务、工作台数据概览
*/
const api = require('../../utils/api');
const { serviceTypeLabel } = require('../../constants/profileLabels');
Page({
data: {
operatorName: '',
pendingCount: 0,
inProgressCount: 0,
todayCount: 0,
completedCount: 0,
pendingServices: [],
loading: true,
currentDate: '',
},
onLoad() {
wx.setNavigationBarTitle({ title: '红娘工作台' });
// 获取操作员信息
const operatorName = wx.getStorageSync('operatorName') || '红娘';
this.setData({ operatorName });
// 设置当前日期
const now = new Date();
const dateStr = `${now.getFullYear()}年${now.getMonth() + 1}月${now.getDate()}日`;
this.setData({ currentDate: dateStr });
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;
}
// 加载工作台数据
const [dashRes, pendingRes] = await Promise.all([
api.get('/operator/matchmaker/dashboard', {}, { Authorization: `Bearer ${token}` }),
api.get('/operator/matchmaker/pending', {}, { Authorization: `Bearer ${token}` }),
]);
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,
});
}
if (pendingRes.success) {
this.setData({
pendingServices: pendingRes.data || [],
});
}
} catch (err) {
console.error('加载工作台数据失败:', err);
} finally {
this.setData({ loading: false });
}
},
onViewService(e) {
const serviceId = e.currentTarget.dataset.id;
wx.navigateTo({ url: `/pages/matchmaker-service-detail/matchmaker-service-detail?id=${serviceId}` });
},
onClaimService(e) {
const serviceId = e.currentTarget.dataset.id;
wx.showLoading({ title: '接单中...' });
const token = wx.getStorageSync('operatorToken');
// 注意:api.post 签名为 (url, data, headers, idempotencyKey),Authorization 必须放第 3 参(headers),
// 此前误放到第 4 参(idempotencyKey),导致实际请求不携带任何鉴权头、接单必 401。
api.post(`/operator/matchmaker/services/${serviceId}/claim`, {}, { Authorization: `Bearer ${token}` })
.then(res => {
wx.hideLoading();
if (res.success) {
wx.showToast({ title: '接单成功', icon: 'success' });
this.loadDashboard();
} else {
wx.showToast({ title: res.message || '接单失败', icon: 'none' });
}
})
.catch(err => {
wx.hideLoading();
wx.showToast({ title: '网络错误', icon: 'none' });
});
},
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 + '日';
},
// 红娘服务类型 → 中文(避免枚举码直接上屏,见 profileLabels 铁律)
serviceTypeLabel(code) {
return serviceTypeLabel(code);
},
onLogout() {
wx.showModal({
title: '退出登录',
content: '确定要退出登录吗?',
success: (res) => {
if (res.confirm) {
wx.removeStorageSync('operatorToken');
wx.removeStorageSync('operatorName');
wx.reLaunch({ url: '/pages/matchmaker-login/matchmaker-login' });
}
},
});
},
});