From dba3b42aec7f29406edb52bfad9ec3001f029a31 Mon Sep 17 00:00:00 2001 From: cursor Date: Tue, 9 Jun 2026 05:04:11 +0800 Subject: [PATCH] =?UTF-8?q?fix(R26):=20=E6=9C=AA=E8=AF=BB=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E8=BD=AE=E8=AF=A2=E6=94=B9=E7=94=A8unread=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3+=E6=98=BE=E7=A4=BA=E4=B8=8A=E9=99=909+=E5=91=98?= =?UTF-8?q?=E5=B7=A5=E7=AB=AF=E6=9C=AA=E8=AF=BB=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/orders/orders.vue | 9 +++++---- pages/staff/board.vue | 15 ++++++++++++--- utils/constants.js | 2 ++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/pages/orders/orders.vue b/pages/orders/orders.vue index 7c1920f..da6f991 100644 --- a/pages/orders/orders.vue +++ b/pages/orders/orders.vue @@ -13,7 +13,7 @@ @@ -50,9 +50,9 @@ export default { } async function checkUnread() { try { - const res = await get(API.MESSAGE_LIST, { card_no: card.cardNo, since: 0 }) - if (Array.isArray(res)) { - card.unread = res.filter(m => m.senderType === 'staff').length + const res = await get(API.MESSAGE_UNREAD, { card_no: card.cardNo }) + if (res && typeof res.count !== 'undefined') { + card.unread = res.count } } catch (e) {} } @@ -94,3 +94,4 @@ export default { .empty-text{font-size:28rpx;color:var(--text-muted);margin:16rpx 0} .btn-back-menu{margin-top:40rpx;padding:16rpx 48rpx;border-radius:40rpx;background:var(--gold);color:#1A1A1A;font-size:28rpx;font-weight:700;border:none} + diff --git a/pages/staff/board.vue b/pages/staff/board.vue index eb6e091..1b4408f 100644 --- a/pages/staff/board.vue +++ b/pages/staff/board.vue @@ -10,7 +10,7 @@ - πŸ§‘β€πŸ³ {{ staff.nickname }} β€” εˆ«ζ‘Έι±ΌδΊ†οΌπŸ’¬ {{ staff.unread }}ζ‘ζ–°ζΆˆζ― + πŸ§‘β€πŸ³ {{ staff.nickname }} β€” εˆ«ζ‘Έι±ΌδΊ†οΌπŸ’¬ {{ staff.unread > 9 ? '9+' : staff.unread }}ζ‘ζ–°ζΆˆζ― @@ -85,6 +85,14 @@ export default { } } catch (e) {} } + async function checkUnread() { + try { + const res = await get(API.MESSAGE_UNREAD, { card_no: 'all', staff_id: staff.staffId }) + if (res && typeof res.count !== 'undefined') { + staff.unread = res.count + } + } catch (e) {} + } function switchTab(s) { activeTab.value = s; loadOrders() } async function onConfirm(id) { try { await post(API.STAFF_CONFIRM, { id }); uni.showToast({ title: 'ε·²ζŽ₯单', icon: 'none' }); loadOrders(); loadCounts() } catch (e) {} } async function onCancel(id) { try { await post(API.STAFF_CANCEL, { id }); uni.showToast({ title: '已拒单', icon: 'none' }); loadOrders(); loadCounts() } catch (e) {} } @@ -95,11 +103,11 @@ export default { function onLogout() { staff.logout(); uni.redirectTo({ url: '/pages/staff/login' }) } onMounted(() => { - loadOrders(); loadCounts(); startPoll('board', () => { loadOrders(); loadCounts() }, 10000) + loadOrders(); loadCounts(); checkUnread(); startPoll('board', () => { loadOrders(); loadCounts(); checkUnread() }, 10000) }) onUnmounted(() => stopPoll('board')) - return { staff, tabs, activeTab, orders, counts, recipeVisible, recipeCardNo, recipeItems, switchTab, onConfirm, onCancel, onDone, onDetail, onRecipe, onChat, onLogout } + return { staff, tabs, activeTab, orders, counts, recipeVisible, recipeCardNo, recipeItems, switchTab, onConfirm, onCancel, onDone, onDetail, onRecipe, onChat, onLogout, checkUnread } } } @@ -126,3 +134,4 @@ export default { .empty-icon{font-size:112rpx;opacity:.3} .empty-text{font-size:28rpx;color:var(--text-muted);margin-top:16rpx} + diff --git a/utils/constants.js b/utils/constants.js index 1d0e25a..f550703 100644 --- a/utils/constants.js +++ b/utils/constants.js @@ -13,6 +13,7 @@ export const API = { MESSAGE_LIST: '/api/message/list', MESSAGE_SEND: '/api/message/send', MESSAGE_READ: '/api/message/read', + MESSAGE_UNREAD: '/api/message/unread', STAFF_LOGIN: '/api/staff/login', STAFF_ORDERS: '/api/staff/orders', STAFF_ORDER: '/api/staff/order', @@ -39,3 +40,4 @@ export const CONFIRM_PRESETS = [ { label: '低度', icon: '🍹' }, ] +