11
This commit is contained in:
1 parent
86a0e9ce46
commit
6fc455dbaf
2 files changed
+21
-1
No files matched your search
@@ -20,3 +20,8 @@ dist
|
||||
*.sln
|
||||
*.sw?
|
||||
unpackage
|
||||
|
||||
# AI assistant artifacts
|
||||
.video_agent
|
||||
.mimosa
|
||||
.v2c
|
||||
@@ -497,6 +497,20 @@ const bookedMenus = computed(() =>
|
||||
*/
|
||||
const resolveDailyMenuCartUserId = () => String(userStore.userId || userStore.userInfo?.userId || "")
|
||||
|
||||
/**
|
||||
* 清理预约日期严格早于当前本地自然日的购物车草稿。
|
||||
* 页面引用的是 Pinia Store 内的持久化对象,逐项删除会同步更新统一缓存;日期缺失或无效时保留原数据,避免误删。
|
||||
*/
|
||||
const removeExpiredDrafts = () => {
|
||||
const today = dayjs().startOf("day")
|
||||
Object.entries(state.draftMap).forEach(([draftKey, draft]) => {
|
||||
const apptDate = dayjs(draft?.apptDate)
|
||||
if (apptDate.isValid() && apptDate.startOf("day").isBefore(today)) {
|
||||
delete state.draftMap[draftKey]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 使用日期和餐段生成仅供页面草稿索引的稳定键。 */
|
||||
const createDraftKey = (apptDate: string, hourType: string | number) =>
|
||||
apptDate && String(hourType) ? `${apptDate}::${String(hourType)}` : ""
|
||||
@@ -1167,8 +1181,9 @@ onLoad((options: any) => {
|
||||
state.draftMap = dailyMenuCartStore.getOrCreateDraftMap(resolveDailyMenuCartUserId(), state.merchantId)
|
||||
})
|
||||
|
||||
/** 页面每次显示时刷新商户配置和已预订菜谱。 */
|
||||
/** 页面每次显示时先清理过期购物车,再刷新商户配置和已预订菜谱。 */
|
||||
onShow(async () => {
|
||||
removeExpiredDrafts()
|
||||
await loadMch()
|
||||
await loadBookedMenus()
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user