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: 'πΉ' },
]
+