You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
apply-assistant-v3/pages/NEUIKit/utils/msg.ts

118 lines
3.9 KiB
TypeScript

5 months ago
import { V2NIMConst } from 'nim-web-sdk-ng/dist/v2/NIM_UNIAPP_SDK'
import { t } from './i18n'
import { V2NIMMessageType } from 'nim-web-sdk-ng/dist/v2/NIM_UNIAPP_SDK/V2NIMMessageService'
const translate = (key: string): string => {
const text =
{
textMsgText: t('textMsgText'),
customMsgText: t('customMsgText'),
audioMsgText: t('audioMsgText'),
videoMsgText: t('videoMsgText'),
fileMsgText: t('fileMsgText'),
callMsgText: t('callMsgText'),
geoMsgText: t('geoMsgText'),
imgMsgText: t('imgMsgText'),
notiMsgText: t('notiMsgText'),
robotMsgText: t('robotMsgText'),
tipMsgText: t('tipMsgText'),
unknowMsgText: t('unknowMsgText'),
}[key] || ''
return `[${text}]`
}
export const getMsgContentTipByType = (msg: {
messageType?: V2NIMMessageType
text?: string
}): string => {
const { messageType, text } = msg
// switch (messageType) {
// case V2NIMConst.V2NIMMessageType.V2NIM_MESSAGE_TYPE_TEXT:
// return text || translate('textMsgText')
// case V2NIMConst.V2NIMMessageType.V2NIM_MESSAGE_TYPE_FILE:
// return translate('fileMsgText')
// case V2NIMConst.V2NIMMessageType.V2NIM_MESSAGE_TYPE_IMAGE:
// return translate('imgMsgText')
// case V2NIMConst.V2NIMMessageType.V2NIM_MESSAGE_TYPE_CUSTOM:
// return text || translate('customMsgText')
// case V2NIMConst.V2NIMMessageType.V2NIM_MESSAGE_TYPE_AUDIO:
// return translate('audioMsgText')
// case V2NIMConst.V2NIMMessageType.V2NIM_MESSAGE_TYPE_CALL:
// return translate('callMsgText')
// case V2NIMConst.V2NIMMessageType.V2NIM_MESSAGE_TYPE_LOCATION:
// return translate('geoMsgText')
// case V2NIMConst.V2NIMMessageType.V2NIM_MESSAGE_TYPE_NOTIFICATION:
// return translate('notiMsgText')
// case V2NIMConst.V2NIMMessageType.V2NIM_MESSAGE_TYPE_ROBOT:
// return translate('robotMsgText')
// case V2NIMConst.V2NIMMessageType.V2NIM_MESSAGE_TYPE_TIPS:
// return translate('tipMsgText')
// case V2NIMConst.V2NIMMessageType.V2NIM_MESSAGE_TYPE_VIDEO:
// return translate('videoMsgText')
// default:
// return translate('unknowMsgText')
// }
return text;
}
export const setTabUnread = (val): void => {
const routes = getCurrentPages()
const curRoute = routes[routes.length - 1].route
const tabPaths = [
'pages/home/index',
3 months ago
'pages/home/order',
5 months ago
'pages/workBench/index',
3 months ago
'pages/message/index',
3 months ago
'pages/person/index',
3 months ago
'root/person/changeTeam'
5 months ago
]
if (curRoute && !tabPaths.includes(curRoute)) {
// 不是首页和聊天页不需要设置tabbar的badge
return
}
const store = uni.$UIKitStore
const unread = store?.conversationStore.totalUnreadCount || 0
3 months ago
// console.log('store?.conversationStore.totalUnreadCount', store?.conversationStore.totalUnreadCount);
5 months ago
uni.$emit('newMessage', { count: store?.conversationStore.totalUnreadCount, type: 'message' })
uni.setStorageSync("chat_info", { count: store?.conversationStore.totalUnreadCount, type: 'message' });
3 months ago
// if (unread === 0) {
// uni.hideTabBarRedDot({
// //隐藏数字
// index: 3, //tabbar下标
// })
// } else {
// uni.showTabBarRedDot({
// index: 3, //tabbar下标
// })
// }
5 months ago
}
export const setContactTabUnread = (): void => {
const routes = getCurrentPages()
const curRoute = routes[routes.length - 1].route
const tabPaths = [
'pages/home/index',
3 months ago
'pages/home/order',
5 months ago
'pages/workBench/index',
3 months ago
'pages/message/index',
3 months ago
'pages/person/index',
3 months ago
'root/person/changeTeam'
5 months ago
]
if (curRoute && !tabPaths.includes(curRoute)) {
// 不是首页和聊天页不需要设置tabbar的badge
return
}
const unread = uni.$UIKitStore?.sysMsgStore?.getTotalUnreadMsgsCount()
3 months ago
// if (unread === 0) {
// uni.hideTabBarRedDot({
// //隐藏数字
// index: 3, //tabbar下标
// })
// } else {
// uni.showTabBarRedDot({
// index: 3, //tabbar下标
// })
// }
5 months ago
}