feat:性能优化
This commit is contained in:
+27
@@ -0,0 +1,27 @@
|
||||
import { KEFU_BASE_URL, Authorization } from '@/utils/config.js'
|
||||
import { getStorageFun, TOKEN_NAME } from '@/utils/auth.js'
|
||||
|
||||
export function getUnreadCount(userId) {
|
||||
const token = getStorageFun(TOKEN_NAME)
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
url: `${KEFU_BASE_URL}/kefu/user/unread-count`,
|
||||
method: 'GET',
|
||||
data: { userId },
|
||||
header: {
|
||||
Authorization,
|
||||
'HSM-AUTH': token || '',
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
success: response => {
|
||||
const body = response.data || {}
|
||||
if (response.statusCode >= 200 && response.statusCode < 300 && body.bizcode === 100) {
|
||||
resolve(Number(body.data || 0))
|
||||
return
|
||||
}
|
||||
resolve(0)
|
||||
},
|
||||
fail: () => resolve(0)
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user