diff --git a/src/http/api/message/index.ts b/src/http/api/message/index.ts index 1c6eda0..3008a43 100644 --- a/src/http/api/message/index.ts +++ b/src/http/api/message/index.ts @@ -4,6 +4,10 @@ import { get, post } from '../../index' export const getMessageListApi = () => { return get('/material-mall/bm_message/list', {}) } +// 消息 获取消息列表历史记录 +export const getMessageListAllApi = () => { + return get('/material-mall/bm_message/listFromDB', {}) +} // 消息 获取消息详情 export const getMessageInfoApi = (data: any) => { return get('/material-mall/bm_message/listOneToOne', data) @@ -12,8 +16,16 @@ export const getMessageInfoApi = (data: any) => { export const sendMessageApi = (data: any) => { return post('/material-mall/bm_message', data) } +// 消息 已读 +export const isReadMessageAPI = (data: any) => { + return post('/material-mall/bm_message/edit', data) +} // 消息 发送消息 export const messageIsReadApi = (data: any) => { return post('/material-mall/bm_message/edit', data) } +// 消息 历史记录 +export const messageHistoryApi = (data: any) => { + return get('/material-mall/bm_message/listOneToOneFromDB', data) +} diff --git a/src/layout/header.vue b/src/layout/header.vue index 2249bec..4d82cbc 100644 --- a/src/layout/header.vue +++ b/src/layout/header.vue @@ -247,7 +247,7 @@ const onCarts = () => { const onJumpUser = () => { const isType: any = localStorage.getItem('rolesType') if (isType == 3) { - window.open(`http://36.33.26.201:17788/glweb/login?token=${store.token}`) + window.open(`http://36.33.26.201:17788/iws/glweb/login?token=${store.token}`) } else { router.push({ name: 'my-user' }) } diff --git a/src/views/message/index.vue b/src/views/message/index.vue index e623a1b..3cb7c4c 100644 --- a/src/views/message/index.vue +++ b/src/views/message/index.vue @@ -107,6 +107,9 @@ import { getMessageInfoApi, sendMessageApi, messageIsReadApi, + messageHistoryApi, + getMessageListAllApi, + isReadMessageAPI, } from 'http/api/message/index' import { mainStore } from 'store/main' import { debounce } from 'lodash-es' @@ -118,6 +121,7 @@ const rightCompanyName = ref('') const store: any = mainStore() const route = useRoute() const messageList = ref([]) +const messageListAll = ref([]) const messageDetails = ref([]) const messageInterval = ref(null) const messageListInterval = ref(null) @@ -132,7 +136,13 @@ const sendParams = ref({ // 消息列表 const getMessageListData = async () => { const { data: res }: any = await getMessageListApi() - messageList.value = res + messageList.value = [...new Set([...messageListAll.value, ...res])] +} + +const getMessageListAllData = async () => { + const { data: res }: any = await getMessageListAllApi() + messageListAll.value = res + // console.log(res, '历史记录') } // 消息详情 @@ -141,6 +151,22 @@ const getMessageInfoData = async (toCompany: any) => { messageDetails.value = res } +// 历史消息 +const getMessageHistoryData = async (fromCompany: any) => { + const { data: res }: any = await messageHistoryApi({ fromCompany }) + console.log(res, '历史记录---') + // messageDetails.value = res +} + +// 消息已读 +const isReadMessageData = async (toCompany: any, fromCompany: any) => { + const isReadParams = { + toCompany, + fromCompany, + } + const res = await isReadMessageAPI(isReadParams) +} + // 消息点击 const onClickMessage = async (item: any) => { const { toCompany, fromCompany, toCompanyName, fromCompanyName, toUser, fromUser } = item @@ -153,13 +179,18 @@ const onClickMessage = async (item: any) => { const res: any = await messageIsReadApi({ toCompany: myCompanyId.value, - fromCompany: sendParams.value.toCompany, + fromCompany: queryDetailsCompanyId.value, }) - console.log(res, '消息已读') + console.log(res, '已读结果--') + + getMessageInfoData(queryDetailsCompanyId.value) + + // console.log(res, '消息已读') if (!messageInterval.value) { messageInterval.value = setInterval(() => { getMessageInfoData(queryDetailsCompanyId.value) + // getMessageHistoryData(queryDetailsCompanyId.value) }, 5000) } } @@ -173,7 +204,10 @@ const onSendMessage = debounce(async () => { }, 500) const errorHandler = () => true onMounted(() => { - getMessageListData() + Promise.all([getMessageListAllData()]).then(() => { + getMessageListData() + }) + if (route.query && route.query.companyId) { const { companyId, companyName, ownId }: any = route.query rightCompanyName.value = companyName