badgeProviders.js
1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* 权益首页菜单角标拉取(异步回写时按 id 定位,避免重排错位)
*/
import {
getWaitAuditCountAPI,
waitstaffstateAPI
} from '~/api/api'
import commonApi from '../../api/api.js'
import { setMenuTipsNumById } from '../../utils/menuBadgeUtils.js'
const MENU_LIST_KEY = 'menuList'
/**
* 菜单重建后按 id 拉取角标
* @param {Object} page - index Component 实例
* @param {Object} userInfo
* @param {Array} [menuList] - 当前 menuList
*/
export function applyEquityMenuBadges(page, userInfo, menuList = page.data.menuList) {
const hasApproval = menuList.some(e => e.id === 'pending_approval')
const hasRecruit = menuList.some(e => e.id === 'recruit_manage')
const hasClue = menuList.some(e => e.id === 'customer_clue')
if (hasApproval) {
getWaitAuditCountAPI({ sceneType: userInfo?.sceneType }).then(res => {
if (res.code == 0) {
setMenuTipsNumById(
page,
MENU_LIST_KEY,
'pending_approval',
res.data.waiteForAuditNum
)
}
})
}
if (hasRecruit) {
waitstaffstateAPI().then(result => {
if (result.code == 0) {
setMenuTipsNumById(
page,
MENU_LIST_KEY,
'recruit_manage',
result.data.waitProcessCount
)
}
})
}
if (hasClue) {
applyCustomerClueBadge(page)
}
}
/** 客户线索角标(clue.tips.newCount) */
export async function applyCustomerClueBadge(page) {
const list = page.data.menuList || []
if (!list.some(item => item.id === 'customer_clue')) {
return
}
const { sceneType, shopMerchantId: merchantId } = wx.$util.getUserInfo()
const { data, code } = await commonApi.getCustomerClueRemind({
sceneType,
merchantId: [merchantId]
})
if (code == 0) {
setMenuTipsNumById(page, MENU_LIST_KEY, 'customer_clue', data)
}
}