Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
dj-car-boutique-work-wechat
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit cbe53bd1
authored
Jun 15, 2026
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix 服务中心弹框bug
1 parent
4a15fce8
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
41 additions
and
178 deletions
docs/SERVICE-CENTER-NOTICE-POPUP.md
packageEquity/docs/DEVLOG.md
packageEquity/docs/HOMEPAGE-INDEX.md
packageEquity/pages/TabBar/equityPage.js
packageEquity/services/serviceCenterNoticeService.js
packageEquity/tests/serviceCenterNoticeService.test.mjs
tabIndex/docs/DEVLOG.md
tabIndex/docs/HOMEPAGE-INDEX.md
tabIndex/services/dailyCheckService.js
tabIndex/services/serviceCenterNoticeService.js
tabIndex/tests/tabIndexServiceCenterNotice.test.mjs
utils/constantData.js
utils/serviceCenterNoticeService.js
utils/serviceNoticePopupHandler.js
utils/util.js
docs/SERVICE-CENTER-NOTICE-POPUP.md
View file @
cbe53bd
# 服务中心公告:精品 vs 权益 弹窗逻辑
# 服务中心公告:精品 vs 权益 弹窗逻辑
精品首页(
`tabIndex`
)与权益首页(
`packageEquity`
)对服务中心未读公告的处理
**一致**
:有未读则弹窗,但
**每个 `moduleType` 每天最多弹 1 次**
(用户点确认进入后标记)
。
精品首页(
`tabIndex`
)与权益首页(
`packageEquity`
)对服务中心未读公告的处理
**一致**
,对齐
**V5.8.1**
:有未读(
`status:0`
)即弹首条,无本地 moduleType 门禁
。
## 行为对比
## 行为对比
...
@@ -12,25 +12,23 @@
...
@@ -12,25 +12,23 @@
## 流程
## 流程
1.
`fetchServiceCenterUnread()`
— 角标(60s TTL + in-flight;探测全部
`noticeSort`
类型)
1.
`fetchServiceCenterUnread()`
— 角标(60s TTL + in-flight;探测全部
`noticeSort`
类型)
2.
`resolve
ServiceNoticePopupCandidate()`
— 按
`noticeSort`
取
**第一条**
有未读且
**今日该类型尚未弹过**
的
公告
2.
`resolve
FirstUnreadNotice()`
— 按
`noticeSort`
取
**第一条**
`status:0`
未读
公告
3.
`enqueueServiceNoticePopup(page, candidate)`
—
`addModalToQueue`
priority 10;用户
**点确认**
后:
3.
`enqueueServiceNoticePopup(page, candidate)`
—
`addModalToQueue`
priority 10;用户
**点确认**
后:
-
`markServiceNoticePopupShown(moduleType)`
写入固定 key
`serviceNoticePop`
(结构
`{ date, [moduleType]: true }`
)
-
先调
`getCompanyNoticeDetail({ id })`
— 服务端将该条标为已读
-
`clearServiceCenterNoticeCache()`
清探测缓存
-
`clearServiceCenterNoticeCache()`
清探测缓存
-
跳转详情并
`showNextModal`
链式展示
-
跳转详情并
`showNextModal`
链式展示
**
与 V5.8.1 的差异**
:V5.8.1 有未读即每次
`onShow`
都弹;当前实现用户确认进入后,同日同类型不再弹(角标仍可显示未读数)
。
**
返回首页后**
:已读条目不参与
`status:0`
列表,同一条不再弹;同类型其他未读仍可继续弹下一条
。
## 共享模块
## 共享模块
| 模块 | 路径 |
| 模块 | 路径 |
|------|------|
|------|------|
| 角标 /
弹窗候选
|
[
`utils/serviceCenterNoticeService.js`
](
../utils/serviceCenterNoticeService.js
)
|
| 角标 /
未读解析
|
[
`utils/serviceCenterNoticeService.js`
](
../utils/serviceCenterNoticeService.js
)
|
| 弹窗入队 |
[
`utils/serviceNoticePopupHandler.js`
](
../utils/serviceNoticePopupHandler.js
)
|
| 弹窗入队 |
[
`utils/serviceNoticePopupHandler.js`
](
../utils/serviceNoticePopupHandler.js
)
|
双端通过
[
`tabIndex/services/serviceCenterNoticeService.js`
](
../tabIndex/services/serviceCenterNoticeService.js
)
、
[
`packageEquity/services/serviceCenterNoticeService.js`
](
../packageEquity/services/serviceCenterNoticeService.js
)
re-export。
双端通过
[
`tabIndex/services/serviceCenterNoticeService.js`
](
../tabIndex/services/serviceCenterNoticeService.js
)
、
[
`packageEquity/services/serviceCenterNoticeService.js`
](
../packageEquity/services/serviceCenterNoticeService.js
)
re-export。
Storage key 双端共用固定 key
`serviceNoticePop`
(须在
[
`utils/constantData.js`
](
../utils/constantData.js
)
注册),内含
`date`
字段区分当日,避免精品/权益各记各的导致重复弹。
## 调用链
## 调用链
-
**精品**
:
`initData`
→
`checkDailyRecport`
→
`runDailyChecks`
→
`checkServiceNotice`
(
`isStaff`
)→
`showNextModal`
-
**精品**
:
`initData`
→
`checkDailyRecport`
→
`runDailyChecks`
→
`checkServiceNotice`
(
`isStaff`
)→
`showNextModal`
...
@@ -40,8 +38,7 @@ Storage key 双端共用固定 key `serviceNoticePop`(须在 [`utils/constantD
...
@@ -40,8 +38,7 @@ Storage key 双端共用固定 key `serviceNoticePop`(须在 [`utils/constantD
1.
**`checkAgreeClient` 悬挂**
:已修复
`code != '0'`
与
`.catch`
不 resolve 的问题
1.
**`checkAgreeClient` 悬挂**
:已修复
`code != '0'`
与
`.catch`
不 resolve 的问题
2.
**`wx.__HAS_SHOW_MODAL`**
:
`runDailyChecks`
/
`initList`
展示前会重置;
`modalQueueService`
支持短暂重试
2.
**`wx.__HAS_SHOW_MODAL`**
:
`runDailyChecks`
/
`initList`
展示前会重置;
`modalQueueService`
支持短暂重试
3.
**今日已弹过该类型**
:属预期行为;次日或清 storage 后可再弹
3.
**入队失败**
:查看控制台
`[serviceNoticePopup] missing dialogOptions`
或
`[checkServiceNotice] enqueue failed`
4.
**入队失败**
:查看控制台
`[serviceNoticePopup] missing dialogOptions`
或
`[checkServiceNotice] enqueue failed`
## 测试
## 测试
...
...
packageEquity/docs/DEVLOG.md
View file @
cbe53bd
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
-
**Tab0 看板**
:
`homeRefreshService`
in-flight;
`initList`
不再刷 home;
`onShow`
补子页返回路径
-
**Tab0 看板**
:
`homeRefreshService`
in-flight;
`initList`
不再刷 home;
`onShow`
补子页返回路径
-
**Tab1–4 子页**
:
`pageShow[N]`
懒挂载 +
`hide`
保活;
`show`
→
`refreshOnShow`
+
`tabRefreshService`
-
**Tab1–4 子页**
:
`pageShow[N]`
懒挂载 +
`hide`
保活;
`show`
→
`refreshOnShow`
+
`tabRefreshService`
-
**父页去重**
:
`getMerchant4SMode`
仅
`onLoad`
;
`checkStaffOrderStatus`
仅 Tab0 +
`staffOrderValidService`
-
**父页去重**
:
`getMerchant4SMode`
仅
`onLoad`
;
`checkStaffOrderStatus`
仅 Tab0 +
`staffOrderValidService`
-
**服务中心公告**
:
每日每
`moduleType`
弹 1 次,确认后标记
;见
[
`docs/SERVICE-CENTER-NOTICE-POPUP.md`
](
../../docs/SERVICE-CENTER-NOTICE-POPUP.md
)
-
**服务中心公告**
:
V5.8.1 已读语义,
`resolveFirstUnreadNotice`
+ 确认调 detail
;见
[
`docs/SERVICE-CENTER-NOTICE-POPUP.md`
](
../../docs/SERVICE-CENTER-NOTICE-POPUP.md
)
-
**tab-bar**
:
`suppressInitialClick`
避免工单/权益列表首屏三入口
-
**tab-bar**
:
`suppressInitialClick`
避免工单/权益列表首屏三入口
-
详录:
[
`TAB-REFRESH-CHANGELOG.md`
](
./TAB-REFRESH-CHANGELOG.md
)
-
详录:
[
`TAB-REFRESH-CHANGELOG.md`
](
./TAB-REFRESH-CHANGELOG.md
)
-
单测:
`IT-EQ-HOME-*`
、
`IT-EQ-TAB-*`
、
`IT-EQ-STAFF-*`
(
`npm run test:equity`
68 用例)
-
单测:
`IT-EQ-HOME-*`
、
`IT-EQ-TAB-*`
、
`IT-EQ-STAFF-*`
(
`npm run test:equity`
68 用例)
packageEquity/docs/HOMEPAGE-INDEX.md
View file @
cbe53bd
...
@@ -54,7 +54,7 @@
...
@@ -54,7 +54,7 @@
| 职责 | equityPage(父页) | home(本组件) |
| 职责 | equityPage(父页) | home(本组件) |
|------|-------------------|----------------|
|------|-------------------|----------------|
| 公告角标/弹窗 |
`checkServiceNotice`
(仅 Tab0 +
[
`serviceCenterNoticeService`
](
../services/serviceCenterNoticeService.js
)
缓存;
每日每 moduleType 弹 1 次
) | 只读
`serviceCenterUnreadNum`
|
| 公告角标/弹窗 |
`checkServiceNotice`
(仅 Tab0 +
[
`serviceCenterNoticeService`
](
../services/serviceCenterNoticeService.js
)
缓存;
V5.8.1 已读语义
) | 只读
`serviceCenterUnreadNum`
|
| 门店 mode |
`equityPage.onLoad`
/ 切店
`initData`
调用
`getMerchant4SMode`
下发
`mode`
|
`scheduleInitialMenuBuild`
等 mode 就绪后建菜单 |
| 门店 mode |
`equityPage.onLoad`
/ 切店
`initData`
调用
`getMerchant4SMode`
下发
`mode`
|
`scheduleInitialMenuBuild`
等 mode 就绪后建菜单 |
| 菜单异步 API | 不调用 |
`rebuildEquityMenus`
唯一入口 |
| 菜单异步 API | 不调用 |
`rebuildEquityMenus`
唯一入口 |
| 切 4S 店 |
`SideSelectPopup`
→
`equityPage.initData`
→
`getMerchant4SMode`
→ home
`onStoreSwitched`
(同步 userInfo/品牌、
`invalidateMenuCache`
含 API 缓存、
`rebuildEquityMenus({ force, mode })`
、
`refreshEquityHome`
);Tab1–4 额外
`refreshOnShow`
| 动态日报 / 工资申诉 / 驻店目标等随门店重建 |
| 切 4S 店 |
`SideSelectPopup`
→
`equityPage.initData`
→
`getMerchant4SMode`
→ home
`onStoreSwitched`
(同步 userInfo/品牌、
`invalidateMenuCache`
含 API 缓存、
`rebuildEquityMenus({ force, mode })`
、
`refreshEquityHome`
);Tab1–4 额外
`refreshOnShow`
| 动态日报 / 工资申诉 / 驻店目标等随门店重建 |
...
@@ -110,7 +110,7 @@ npm run test:equity
...
@@ -110,7 +110,7 @@ npm run test:equity
| 步骤 | 模块 |
| 步骤 | 模块 |
|------|------|
|------|------|
| 角标 |
`fetchServiceCenterUnread`
(60s 缓存) |
| 角标 |
`fetchServiceCenterUnread`
(60s 缓存) |
| 弹窗候选 |
`resolve
ServiceNoticePopupCandidate`
(每日每 moduleType 弹 1 次,确认后标记
) |
| 弹窗候选 |
`resolve
FirstUnreadNotice`
(status:0 首条未读,确认调 detail 标已读
) |
| 入队 |
`equityPage.checkServiceNotice`
→ priority 10 |
| 入队 |
`equityPage.checkServiceNotice`
→ priority 10 |
触发:
`initList`
且
`isStaff && tabIndex === 0`
。详见
[
`docs/SERVICE-CENTER-NOTICE-POPUP.md`
](
../../docs/SERVICE-CENTER-NOTICE-POPUP.md
)
。
触发:
`initList`
且
`isStaff && tabIndex === 0`
。详见
[
`docs/SERVICE-CENTER-NOTICE-POPUP.md`
](
../../docs/SERVICE-CENTER-NOTICE-POPUP.md
)
。
...
...
packageEquity/pages/TabBar/equityPage.js
View file @
cbe53bd
...
@@ -18,7 +18,7 @@ import carLifeApi from '../../carEquityApi'
...
@@ -18,7 +18,7 @@ import carLifeApi from '../../carEquityApi'
import
{
import
{
fetchServiceCenterUnread
,
fetchServiceCenterUnread
,
resolve
ServiceNoticePopupCandidat
e
resolve
FirstUnreadNotic
e
}
from
'../../services/serviceCenterNoticeService.js'
}
from
'../../services/serviceCenterNoticeService.js'
import
{
enqueueServiceNoticePopup
}
from
'~/utils/serviceNoticePopupHandler.js'
import
{
enqueueServiceNoticePopup
}
from
'~/utils/serviceNoticePopupHandler.js'
import
{
import
{
...
@@ -674,7 +674,7 @@ Page({
...
@@ -674,7 +674,7 @@ Page({
const
unread
=
await
fetchServiceCenterUnread
()
const
unread
=
await
fetchServiceCenterUnread
()
this
.
setData
({
serviceCenterUnreadNum
:
unread
})
this
.
setData
({
serviceCenterUnreadNum
:
unread
})
const
candidate
=
await
resolve
ServiceNoticePopupCandidat
e
()
const
candidate
=
await
resolve
FirstUnreadNotic
e
()
if
(
!
candidate
)
return
if
(
!
candidate
)
return
try
{
try
{
...
...
packageEquity/services/serviceCenterNoticeService.js
View file @
cbe53bd
export
{
export
{
fetchServiceCenterUnread
,
fetchServiceCenterUnread
,
resolveServiceNoticePopupCandidate
,
resolveFirstUnreadNotice
,
markServiceNoticePopupShown
,
clearServiceCenterNoticeCache
,
clearServiceCenterNoticeCache
,
__setListApiForTest
__setListApiForTest
}
from
'../../utils/serviceCenterNoticeService.js'
}
from
'../../utils/serviceCenterNoticeService.js'
packageEquity/tests/serviceCenterNoticeService.test.mjs
View file @
cbe53bd
import { describe, it, beforeEach, afterEach } from 'node:test'
import { describe, it, beforeEach, afterEach } from 'node:test'
import assert from 'node:assert/strict'
import assert from 'node:assert/strict'
function createStorageMock() {
const data = {}
return {
get(key) {
return data[key]
},
set(key, value) {
data[key] = value
}
}
}
describe('serviceCenterNoticeService', async () => {
describe('serviceCenterNoticeService', async () => {
const {
const {
fetchServiceCenterUnread,
fetchServiceCenterUnread,
resolveServiceNoticePopupCandidate,
resolveFirstUnreadNotice,
markServiceNoticePopupShown,
__setListApiForTest,
__setListApiForTest,
clearServiceCenterNoticeCache
clearServiceCenterNoticeCache
} = await import('../services/serviceCenterNoticeService.js')
} = await import('../services/serviceCenterNoticeService.js')
...
@@ -32,7 +19,7 @@ describe('serviceCenterNoticeService', async () => {
...
@@ -32,7 +19,7 @@ describe('serviceCenterNoticeService', async () => {
return '2026-06-09'
return '2026-06-09'
}
}
}
}
globalThis.wx = {
$storage: createStorageMock()
}
globalThis.wx = {}
__setListApiForTest(async params => {
__setListApiForTest(async params => {
apiCalls.push(params.moduleType)
apiCalls.push(params.moduleType)
if (params.moduleType === 6) {
if (params.moduleType === 6) {
...
@@ -55,8 +42,8 @@ describe('serviceCenterNoticeService', async () => {
...
@@ -55,8 +42,8 @@ describe('serviceCenterNoticeService', async () => {
assert.equal(apiCalls.length, 3)
assert.equal(apiCalls.length, 3)
})
})
it('IT-EQ-NOTICE-002: resolve
ServiceNoticePopupCandidat
e returns first unread by noticeSort', async () => {
it('IT-EQ-NOTICE-002: resolve
FirstUnreadNotic
e returns first unread by noticeSort', async () => {
const first = await resolve
ServiceNoticePopupCandidat
e()
const first = await resolve
FirstUnreadNotic
e()
assert.ok(first)
assert.ok(first)
assert.equal(first.moduleType, 6)
assert.equal(first.moduleType, 6)
clearServiceCenterNoticeCache()
clearServiceCenterNoticeCache()
...
@@ -70,36 +57,12 @@ describe('serviceCenterNoticeService', async () => {
...
@@ -70,36 +57,12 @@ describe('serviceCenterNoticeService', async () => {
}
}
return { data: { list: [] } }
return { data: { list: [] } }
})
})
const second = await resolve
ServiceNoticePopupCandidat
e()
const second = await resolve
FirstUnreadNotic
e()
assert.ok(second)
assert.ok(second)
assert.equal(second.moduleType, 7)
assert.equal(second.moduleType, 7)
})
})
it('IT-EQ-NOTICE-003: skips moduleType already shown today', async () => {
it('IT-EQ-NOTICE-003: probe scans all module types once per cache window', async () => {
markServiceNoticePopupShown(6)
const candidate = await resolveServiceNoticePopupCandidate()
assert.equal(candidate, null)
})
it('IT-EQ-NOTICE-004: daily gate is per moduleType not global', async () => {
markServiceNoticePopupShown(6)
clearServiceCenterNoticeCache()
__setListApiForTest(async params => {
apiCalls.push(params.moduleType)
if (params.moduleType === 6) {
return { data: { list: [{ id: 1, msgTitle: '课程', reminderType: 1 }] } }
}
if (params.moduleType === 7) {
return { data: { list: [{ id: 2, msgTitle: '案例', reminderType: 1 }] } }
}
return { data: { list: [] } }
})
const candidate = await resolveServiceNoticePopupCandidate()
assert.ok(candidate)
assert.equal(candidate.moduleType, 7)
})
it('IT-EQ-NOTICE-005: probe scans all module types once per cache window', async () => {
__setListApiForTest(async params => {
__setListApiForTest(async params => {
apiCalls.push(params.moduleType)
apiCalls.push(params.moduleType)
if (params.moduleType === 6) {
if (params.moduleType === 6) {
...
@@ -108,14 +71,7 @@ describe('serviceCenterNoticeService', async () => {
...
@@ -108,14 +71,7 @@ describe('serviceCenterNoticeService', async () => {
return { data: { list: [] } }
return { data: { list: [] } }
})
})
await fetchServiceCenterUnread()
await fetchServiceCenterUnread()
await resolve
ServiceNoticePopupCandidat
e()
await resolve
FirstUnreadNotic
e()
assert.equal(apiCalls.length, 3)
assert.equal(apiCalls.length, 3)
})
})
it('IT-EQ-NOTICE-006: allows popup again when storage date is stale', async () => {
wx.$storage.set('serviceNoticePop', { date: '2026-06-08', 6: true })
const candidate = await resolveServiceNoticePopupCandidate()
assert.ok(candidate)
assert.equal(candidate.moduleType, 6)
})
})
})
tabIndex/docs/DEVLOG.md
View file @
cbe53bd
# DEVLOG — tabIndex 精品首页
# DEVLOG — tabIndex 精品首页
## 2026-06 — 服务中心公告
每日弹窗门禁
## 2026-06 — 服务中心公告
按已读状态弹窗(V5.8.1)
-
恢复每个
`moduleType`
每天最多弹 1 次;
`resolveServiceNoticePopupCandidate`
+ 固定 key
`serviceNoticePop`
(内嵌
`date`
)
-
去掉 moduleType 每日门禁;
`resolveFirstUnreadNotice`
+ 确认时
`getCompanyNoticeDetail`
标已读
-
**确认后标记**
(非入队时标记),修复「进入详情返回仍弹同一条」
-
共享
[
`utils/serviceCenterNoticeService.js`
](
../../utils/serviceCenterNoticeService.js
)
、
[
`utils/serviceNoticePopupHandler.js`
](
../../utils/serviceNoticePopupHandler.js
)
-
共享
[
`utils/serviceCenterNoticeService.js`
](
../../utils/serviceCenterNoticeService.js
)
、
[
`utils/serviceNoticePopupHandler.js`
](
../../utils/serviceNoticePopupHandler.js
)
## 2026-06 — 服务中心公告
对齐 V5.8.1
(已 supersede)
## 2026-06 — 服务中心公告
每日弹窗门禁
(已 supersede)
-
曾
移除「今日已弹」门禁;已由上条每日门禁
替代
-
曾
按 moduleType 每日弹 1 次;已由上条服务端已读方案
替代
## 2026-06 — 服务中心公告弹窗恢复
## 2026-06 — 服务中心公告弹窗恢复
...
...
tabIndex/docs/HOMEPAGE-INDEX.md
View file @
cbe53bd
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
| 方法 | 服务 | 说明 |
| 方法 | 服务 | 说明 |
|------|------|------|
|------|------|------|
|
`checkDailyRecport`
→
`checkServiceNotice`
|
[
`dailyCheckService.js`
](
../services/dailyCheckService.js
)
+
[
`serviceCenterNoticeService.js`
](
../services/serviceCenterNoticeService.js
)
|
每日每 moduleType 弹 1 次,确认后标记
|
|
`checkDailyRecport`
→
`checkServiceNotice`
|
[
`dailyCheckService.js`
](
../services/dailyCheckService.js
)
+
[
`serviceCenterNoticeService.js`
](
../services/serviceCenterNoticeService.js
)
|
V5.8.1:status:0 首条未读,确认调 detail 标已读
|
-
调用:
`runDailyChecks`
在
`isStaff`
时并行执行
`checkServiceNotice(page)`
-
调用:
`runDailyChecks`
在
`isStaff`
时并行执行
`checkServiceNotice(page)`
-
弹窗入队见
[
`utils/serviceNoticePopupHandler.js`
](
../../utils/serviceNoticePopupHandler.js
)
-
弹窗入队见
[
`utils/serviceNoticePopupHandler.js`
](
../../utils/serviceNoticePopupHandler.js
)
...
...
tabIndex/services/dailyCheckService.js
View file @
cbe53bd
...
@@ -9,7 +9,7 @@ import {
...
@@ -9,7 +9,7 @@ import {
}
from
'./todoService.js'
}
from
'./todoService.js'
import
{
import
{
fetchServiceCenterUnread
,
fetchServiceCenterUnread
,
resolve
ServiceNoticePopupCandidat
e
resolve
FirstUnreadNotic
e
}
from
'./serviceCenterNoticeService.js'
}
from
'./serviceCenterNoticeService.js'
import
{
enqueueServiceNoticePopup
}
from
'../../utils/serviceNoticePopupHandler.js'
import
{
enqueueServiceNoticePopup
}
from
'../../utils/serviceNoticePopupHandler.js'
...
@@ -149,12 +149,12 @@ export function checkAgreeClient(page, loginUserObj) {
...
@@ -149,12 +149,12 @@ export function checkAgreeClient(page, loginUserObj) {
})
})
}
}
/** 服务中心未读角标 + 弹窗(
每日每 moduleType 最多弹 1 次,确认后标记
) */
/** 服务中心未读角标 + 弹窗(
V5.8.1:status:0 首条未读,确认调 detail 标已读
) */
export
async
function
checkServiceNotice
(
page
)
{
export
async
function
checkServiceNotice
(
page
)
{
const
unread
=
await
fetchServiceCenterUnread
()
const
unread
=
await
fetchServiceCenterUnread
()
page
.
setData
({
serviceCenterUnreadNum
:
unread
})
page
.
setData
({
serviceCenterUnreadNum
:
unread
})
const
candidate
=
await
resolve
ServiceNoticePopupCandidat
e
()
const
candidate
=
await
resolve
FirstUnreadNotic
e
()
if
(
!
candidate
)
return
if
(
!
candidate
)
return
try
{
try
{
...
...
tabIndex/services/serviceCenterNoticeService.js
View file @
cbe53bd
export
{
export
{
fetchServiceCenterUnread
,
fetchServiceCenterUnread
,
resolveServiceNoticePopupCandidate
,
resolveFirstUnreadNotice
,
markServiceNoticePopupShown
,
clearServiceCenterNoticeCache
,
clearServiceCenterNoticeCache
,
__setListApiForTest
__setListApiForTest
}
from
'../../utils/serviceCenterNoticeService.js'
}
from
'../../utils/serviceCenterNoticeService.js'
tabIndex/tests/tabIndexServiceCenterNotice.test.mjs
View file @
cbe53bd
import { describe, it, beforeEach, afterEach } from 'node:test'
import { describe, it, beforeEach, afterEach } from 'node:test'
import assert from 'node:assert/strict'
import assert from 'node:assert/strict'
function createStorageMock() {
const data = {}
return {
get(key) {
return data[key]
},
set(key, value) {
data[key] = value
}
}
}
describe('tabIndex serviceCenterNoticeService', async () => {
describe('tabIndex serviceCenterNoticeService', async () => {
const {
const {
fetchServiceCenterUnread,
fetchServiceCenterUnread,
resolveServiceNoticePopupCandidate,
resolveFirstUnreadNotice,
markServiceNoticePopupShown,
__setListApiForTest,
__setListApiForTest,
clearServiceCenterNoticeCache
clearServiceCenterNoticeCache
} = await import('../services/serviceCenterNoticeService.js')
} = await import('../services/serviceCenterNoticeService.js')
...
@@ -32,7 +19,7 @@ describe('tabIndex serviceCenterNoticeService', async () => {
...
@@ -32,7 +19,7 @@ describe('tabIndex serviceCenterNoticeService', async () => {
return '2026-06-09'
return '2026-06-09'
}
}
}
}
globalThis.wx = {
$storage: createStorageMock()
}
globalThis.wx = {}
__setListApiForTest(async params => {
__setListApiForTest(async params => {
apiCalls.push(params.moduleType)
apiCalls.push(params.moduleType)
if (params.moduleType === 6) {
if (params.moduleType === 6) {
...
@@ -55,8 +42,8 @@ describe('tabIndex serviceCenterNoticeService', async () => {
...
@@ -55,8 +42,8 @@ describe('tabIndex serviceCenterNoticeService', async () => {
assert.equal(apiCalls.length, 3)
assert.equal(apiCalls.length, 3)
})
})
it('IT-TAB-NOTICE-002: resolve
ServiceNoticePopupCandidat
e returns first unread by noticeSort', async () => {
it('IT-TAB-NOTICE-002: resolve
FirstUnreadNotic
e returns first unread by noticeSort', async () => {
const first = await resolve
ServiceNoticePopupCandidat
e()
const first = await resolve
FirstUnreadNotic
e()
assert.ok(first)
assert.ok(first)
assert.equal(first.moduleType, 6)
assert.equal(first.moduleType, 6)
clearServiceCenterNoticeCache()
clearServiceCenterNoticeCache()
...
@@ -70,36 +57,12 @@ describe('tabIndex serviceCenterNoticeService', async () => {
...
@@ -70,36 +57,12 @@ describe('tabIndex serviceCenterNoticeService', async () => {
}
}
return { data: { list: [] } }
return { data: { list: [] } }
})
})
const second = await resolve
ServiceNoticePopupCandidat
e()
const second = await resolve
FirstUnreadNotic
e()
assert.ok(second)
assert.ok(second)
assert.equal(second.moduleType, 7)
assert.equal(second.moduleType, 7)
})
})
it('IT-TAB-NOTICE-003: skips moduleType already shown today', async () => {
it('IT-TAB-NOTICE-003: probe scans all module types once per cache window', async () => {
markServiceNoticePopupShown(6)
const candidate = await resolveServiceNoticePopupCandidate()
assert.equal(candidate, null)
})
it('IT-TAB-NOTICE-004: daily gate is per moduleType not global', async () => {
markServiceNoticePopupShown(6)
clearServiceCenterNoticeCache()
__setListApiForTest(async params => {
apiCalls.push(params.moduleType)
if (params.moduleType === 6) {
return { data: { list: [{ id: 1, msgTitle: '课程', reminderType: 1 }] } }
}
if (params.moduleType === 7) {
return { data: { list: [{ id: 2, msgTitle: '案例', reminderType: 1 }] } }
}
return { data: { list: [] } }
})
const candidate = await resolveServiceNoticePopupCandidate()
assert.ok(candidate)
assert.equal(candidate.moduleType, 7)
})
it('IT-TAB-NOTICE-005: probe scans all module types once per cache window', async () => {
__setListApiForTest(async params => {
__setListApiForTest(async params => {
apiCalls.push(params.moduleType)
apiCalls.push(params.moduleType)
if (params.moduleType === 6) {
if (params.moduleType === 6) {
...
@@ -108,14 +71,7 @@ describe('tabIndex serviceCenterNoticeService', async () => {
...
@@ -108,14 +71,7 @@ describe('tabIndex serviceCenterNoticeService', async () => {
return { data: { list: [] } }
return { data: { list: [] } }
})
})
await fetchServiceCenterUnread()
await fetchServiceCenterUnread()
await resolve
ServiceNoticePopupCandidat
e()
await resolve
FirstUnreadNotic
e()
assert.equal(apiCalls.length, 3)
assert.equal(apiCalls.length, 3)
})
})
it('IT-TAB-NOTICE-006: allows popup again when storage date is stale', async () => {
wx.$storage.set('serviceNoticePop', { date: '2026-06-08', 6: true })
const candidate = await resolveServiceNoticePopupCandidate()
assert.ok(candidate)
assert.equal(candidate.moduleType, 6)
})
})
})
utils/constantData.js
View file @
cbe53bd
...
@@ -23,7 +23,6 @@ export const STORAGE_OBJECTkEY = {
...
@@ -23,7 +23,6 @@ export const STORAGE_OBJECTkEY = {
crowdFundingParams
:
'crowdFundingParams'
,
crowdFundingParams
:
'crowdFundingParams'
,
dateStaffPop
:
'dateStaffPop'
,
dateStaffPop
:
'dateStaffPop'
,
abnormalOrderPop
:
'abnormalOrderPop'
,
abnormalOrderPop
:
'abnormalOrderPop'
,
serviceNoticePop
:
'serviceNoticePop'
,
mock_data
:
'mock_data'
,
mock_data
:
'mock_data'
,
recordList
:
'recordList'
recordList
:
'recordList'
}
}
...
...
utils/serviceCenterNoticeService.js
View file @
cbe53bd
/**
/**
* 服务中心公告:角标拉取(TTL + in-flight)与
弹窗候选(每日每 moduleType 最多弹 1 次
)
* 服务中心公告:角标拉取(TTL + in-flight)与
首条未读(status:0,无本地门禁
)
*/
*/
import
{
noticeSort
}
from
'./enum/serviceCenter.js'
import
{
noticeSort
}
from
'./enum/serviceCenter.js'
...
@@ -83,48 +83,11 @@ export async function fetchServiceCenterUnread() {
...
@@ -83,48 +83,11 @@ export async function fetchServiceCenterUnread() {
}
}
}
}
const
POPUP_STORAGE_KEY
=
'serviceNoticePop'
/** 按 noticeSort 返回首条未读公告(V5.8.1:有未读即弹,依赖服务端 status) */
export
async
function
resolveFirstUnreadNotice
()
{
function
todayDateString
()
{
const
d
=
new
Date
()
if
(
typeof
d
.
format
===
'function'
)
{
return
d
.
format
(
'yyyy-MM-dd'
)
}
return
d
.
toISOString
().
slice
(
0
,
10
)
}
function
readPopupStorage
()
{
const
stored
=
wx
.
$storage
?.
get
?.(
POPUP_STORAGE_KEY
)
||
{}
const
today
=
todayDateString
()
if
(
stored
.
date
&&
stored
.
date
!==
today
)
{
return
{
date
:
today
}
}
return
stored
.
date
?
stored
:
{
date
:
today
}
}
function
wasPopupShownToday
(
moduleType
)
{
const
stored
=
readPopupStorage
()
const
today
=
todayDateString
()
return
stored
.
date
===
today
&&
!!
stored
[
moduleType
]
}
/** 用户点确认进入后标记,避免同日同 moduleType 重复弹 */
export
function
markServiceNoticePopupShown
(
moduleType
)
{
const
stored
=
readPopupStorage
()
const
today
=
todayDateString
()
const
next
=
stored
.
date
===
today
?
{
...
stored
,
[
moduleType
]:
true
}
:
{
date
:
today
,
[
moduleType
]:
true
}
wx
.
$storage
?.
set
?.(
POPUP_STORAGE_KEY
,
next
)
}
/** 按 noticeSort 返回今日尚未弹过的首条未读公告 */
export
async
function
resolveServiceNoticePopupCandidate
()
{
const
probes
=
await
probeNoticeLists
()
const
probes
=
await
probeNoticeLists
()
for
(
const
{
moduleType
,
list
}
of
probes
)
{
for
(
const
{
moduleType
,
list
}
of
probes
)
{
if
(
!
list
?.
length
)
continue
if
(
!
list
?.
length
)
continue
if
(
wasPopupShownToday
(
moduleType
))
continue
return
{
moduleType
,
noticeItem
:
list
[
0
]
}
return
{
moduleType
,
noticeItem
:
list
[
0
]
}
}
}
return
null
return
null
...
...
utils/serviceNoticePopupHandler.js
View file @
cbe53bd
...
@@ -3,10 +3,7 @@
...
@@ -3,10 +3,7 @@
*/
*/
import
{
dialogOptions
,
ServerCenterEnum
}
from
'./enum/index.js'
import
{
dialogOptions
,
ServerCenterEnum
}
from
'./enum/index.js'
import
{
getCompanyNoticeDetail
}
from
'~/api/serviceCenter/index'
import
{
getCompanyNoticeDetail
}
from
'~/api/serviceCenter/index'
import
{
import
{
clearServiceCenterNoticeCache
}
from
'./serviceCenterNoticeService.js'
markServiceNoticePopupShown
,
clearServiceCenterNoticeCache
}
from
'./serviceCenterNoticeService.js'
function
resolveDialogParams
(
serviceCenterEnum
,
noticeItem
)
{
function
resolveDialogParams
(
serviceCenterEnum
,
noticeItem
)
{
const
typeOpts
=
dialogOptions
[
serviceCenterEnum
]
const
typeOpts
=
dialogOptions
[
serviceCenterEnum
]
...
@@ -42,12 +39,11 @@ export function enqueueServiceNoticePopup(page, candidate) {
...
@@ -42,12 +39,11 @@ export function enqueueServiceNoticePopup(page, candidate) {
false
,
false
,
10
,
10
,
async
()
=>
{
async
()
=>
{
markServiceNoticePopupShown
(
serviceCenterEnum
)
clearServiceCenterNoticeCache
()
wx
.
$util
.
showLoading
()
wx
.
$util
.
showLoading
()
try
{
try
{
const
{
data
}
=
await
getCompanyNoticeDetail
({
id
:
noticeItem
.
id
})
clearServiceCenterNoticeCache
()
if
(
dialogParams
.
type
===
ServerCenterEnum
.
longCourse
)
{
if
(
dialogParams
.
type
===
ServerCenterEnum
.
longCourse
)
{
const
{
data
}
=
await
getCompanyNoticeDetail
({
id
:
noticeItem
.
id
})
wx
.
navigateTo
({
wx
.
navigateTo
({
url
:
`/packageStudyCenter/pages/taskDetail/longCourse/longCourse?row=
${
encodeURIComponent
(
JSON
.
stringify
(
data
.
msgDetail
))}
&form=serviceCenter`
,
url
:
`/packageStudyCenter/pages/taskDetail/longCourse/longCourse?row=
${
encodeURIComponent
(
JSON
.
stringify
(
data
.
msgDetail
))}
&form=serviceCenter`
,
fail
:
err
=>
{
fail
:
err
=>
{
...
...
utils/util.js
View file @
cbe53bd
...
@@ -136,7 +136,6 @@ const removeStorage = () => {
...
@@ -136,7 +136,6 @@ const removeStorage = () => {
wx
.
removeStorageSync
(
'dj_boutique_sessionId'
)
wx
.
removeStorageSync
(
'dj_boutique_sessionId'
)
wx
.
removeStorageSync
(
'dateStaffPop'
)
wx
.
removeStorageSync
(
'dateStaffPop'
)
wx
.
removeStorageSync
(
'abnormalOrderPop'
)
wx
.
removeStorageSync
(
'abnormalOrderPop'
)
wx
.
removeStorageSync
(
'serviceNoticePop'
)
wx
.
removeStorageSync
(
'dj_boutique_webview_h5_tokens'
)
wx
.
removeStorageSync
(
'dj_boutique_webview_h5_tokens'
)
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment