Browse Source

Merge branch 'dev' of https://git.citupro.com/zhengnaiwen_citu/menduner into dev

Xiao_123 7 months ago
parent
commit
9d961b6048

+ 10 - 10
src/hooks/web/useIM.js

@@ -6,7 +6,7 @@ import { getConversationSync, getMessageSync, getChatKey, setUnread, deleteConve
 import { Base64 } from 'js-base64'
 import { Base64 } from 'js-base64'
 
 
 import { useUserStore } from '@/store/user'
 import { useUserStore } from '@/store/user'
-import { useLoginType } from '@/store/loginType'
+import { isEnterprise } from '@/utils/auth'
 import { useIMStore } from '@/store/im'
 import { useIMStore } from '@/store/im'
 
 
 
 
@@ -92,14 +92,13 @@ const ConnectStatus = {
 // api 接入
 // api 接入
 export function useDataSource () {
 export function useDataSource () {
   const userStore = useUserStore() 
   const userStore = useUserStore() 
-  const loginType = useLoginType()
   // 最近会话数据源
   // 最近会话数据源
   WKSDK.shared().config.provider.syncConversationsCallback  = async () => {
   WKSDK.shared().config.provider.syncConversationsCallback  = async () => {
     const query = {
     const query = {
       msg_count: 1
       msg_count: 1
     }
     }
-    if (loginType.loginType === 'enterprise') {
-      Object.assign(query, { enterpriseId: userStore.baseInfo.enterpriseId })
+    if (isEnterprise()) {
+      Object.assign(query, { enterpriseId: userStore.entBaseInfo.enterpriseId })
     }
     }
     const resultConversations = []
     const resultConversations = []
     const resp = await getConversationSync(query)
     const resp = await getConversationSync(query)
@@ -132,8 +131,8 @@ export function useDataSource () {
       limit,
       limit,
       pull_mode,
       pull_mode,
     }
     }
-    if (loginType.loginType === 'enterprise') {
-      Object.assign(query, { enterpriseId: userStore.baseInfo.enterpriseId })
+    if (isEnterprise()) {
+      Object.assign(query, { enterpriseId: userStore.entBaseInfo.enterpriseId })
     }
     }
     const resp = await getMessageSync(query)
     const resp = await getMessageSync(query)
     const messageList = resp && resp["messages"]
     const messageList = resp && resp["messages"]
@@ -159,12 +158,13 @@ export function useDataSource () {
 
 
 async function getKey () {
 async function getKey () {
   const userStore = useUserStore()
   const userStore = useUserStore()
-  const loginType = useLoginType()
+
   const keyQuery = {
   const keyQuery = {
     userId: userStore.accountInfo.userId
     userId: userStore.accountInfo.userId
   }
   }
-  if (loginType.loginType === 'enterprise') {
-    Object.assign(keyQuery, { enterpriseId: userStore.baseInfo.enterpriseId })
+  if (isEnterprise()) {
+    Object.assign(keyQuery, { enterpriseId: userStore.entBaseInfo.enterpriseId })
+    console.log('企业模式', keyQuery)
   }
   }
   const { uid, wsUrl, token } = await getChatKey(keyQuery)
   const { uid, wsUrl, token } = await getChatKey(keyQuery)
   return {
   return {
@@ -203,7 +203,7 @@ export const useIM = () => {
   })
   })
   
   
   async function messageListen (message) {
   async function messageListen (message) {
-    // console.log('收到消息', message)
+    console.log('收到消息', message)
     IM.setFromChannel(message.channel.channelID)
     IM.setFromChannel(message.channel.channelID)
     setUnreadCount()
     setUnreadCount()
   }
   }

+ 2 - 1
src/store/loginType.js

@@ -1,9 +1,10 @@
 import { defineStore } from 'pinia'
 import { defineStore } from 'pinia'
+import { isEnterprise } from '@/utils/auth'
 
 
 export const useLoginType = defineStore('changeLoginType', {
 export const useLoginType = defineStore('changeLoginType', {
   state: () => ({
   state: () => ({
     // loginType: 0
     // loginType: 0
-    loginType: localStorage.getItem('loginType') || 'personal'
+    loginType: isEnterprise() ? 'enterprise' : 'personal'
   }),
   }),
   actions: {
   actions: {
     change(type) {
     change(type) {

+ 1 - 1
src/utils/auth.js

@@ -1,6 +1,6 @@
 import router from '@/router'
 import router from '@/router'
 
 
-const isEnterprise = () => {
+export const isEnterprise = () => {
   const currentRoute = router.currentRoute.value
   const currentRoute = router.currentRoute.value
   const substr = '/recruit/enterprise'
   const substr = '/recruit/enterprise'
 
 

+ 7 - 2
src/views/recruit/components/message/components/chatting.vue

@@ -103,7 +103,7 @@
             <div style="width: 40px; height: 40px;">
             <div style="width: 40px; height: 40px;">
               <v-avatar>
               <v-avatar>
                 <v-img
                 <v-img
-                  :src="(val.from_uid === IM.uid ? mAvatar : getUserAvatar(info.avatar, info.sex)) || 'https://minio.citupro.com/dev/menduner/7.png'"
+                  :src="(val.from_uid === IM.uid ? mAvatar() : getUserAvatar(info.avatar, info.sex)) || 'https://minio.citupro.com/dev/menduner/7.png'"
                   :width="40"
                   :width="40"
                   height="40"
                   height="40"
                   rounded
                   rounded
@@ -286,7 +286,12 @@ const IM = useIMStore()
 const userStore = useUserStore()
 const userStore = useUserStore()
 const loading = ref(false)
 const loading = ref(false)
 
 
-const mAvatar = getUserAvatar(userStore.baseInfo?.avatar, userStore.baseInfo?.sex)
+const mAvatar = () => {
+  if (isEnterprise) {
+    return getUserAvatar(userStore.entBaseInfo?.avatar, userStore.entBaseInfo?.sex)
+  }
+  return getUserAvatar(userStore.baseInfo?.avatar, userStore.baseInfo?.sex)
+}
 
 
 const chatRef = ref()
 const chatRef = ref()
 const inputVal = ref('')
 const inputVal = ref('')

+ 9 - 5
src/views/recruit/components/message/index.vue

@@ -1,6 +1,6 @@
 <template>
 <template>
   <div class="default-width message" :style="`height: calc(100vh - ${isEnterprise ? '130px' : '50px'});`">
   <div class="default-width message" :style="`height: calc(100vh - ${isEnterprise ? '130px' : '50px'});`">
-    <div class="message-left">
+    <div class="message-left d-flex flex-column">
       <div class="message-left-search d-flex align-center px-3 justify-space-between" >
       <div class="message-left-search d-flex align-center px-3 justify-space-between" >
         <div>
         <div>
           <v-icon class="mr-3">mdi-history</v-icon>
           <v-icon class="mr-3">mdi-history</v-icon>
@@ -171,7 +171,7 @@ const chatRef = ref()
 
 
 const IM = useIMStore()
 const IM = useIMStore()
 // 自己的信息
 // 自己的信息
-const { baseInfo } = useUserStore()
+const { entBaseInfo } = useUserStore()
 
 
 const isEnterprise = inject('isEnterprise')
 const isEnterprise = inject('isEnterprise')
 // 实例
 // 实例
@@ -270,7 +270,7 @@ const updateUnreadMessageCount = (val) => {
   const obj = val.find(e => e.userInfoVo.userId === info.value.userId)
   const obj = val.find(e => e.userInfoVo.userId === info.value.userId)
   if (!obj?.unread || obj.unread === 0) return
   if (!obj?.unread || obj.unread === 0) return
   delete info.value.unread
   delete info.value.unread
-  Object.assign(info.value, { unread: obj.unread, enterpriseId: baseInfo?.enterpriseId })
+  Object.assign(info.value, { unread: obj.unread, enterpriseId: entBaseInfo?.enterpriseId })
 }
 }
 
 
 watch(
 watch(
@@ -313,7 +313,7 @@ async function handleChange (items) {
     hasMore.value = more
     hasMore.value = more
     chatRef.value.scrollBottom()
     chatRef.value.scrollBottom()
     // 点开窗口消除未读数量
     // 点开窗口消除未读数量
-    await resetUnread(channel.value, baseInfo?.enterpriseId)
+    await resetUnread(channel.value, entBaseInfo?.enterpriseId)
     await updateConversation()
     await updateConversation()
     updateUnreadCount()
     updateUnreadCount()
   } catch (error) {
   } catch (error) {
@@ -425,7 +425,7 @@ const handleGetMore = async () => {
 }
 }
 
 
 const handleDelete = async ({ channel }) => {
 const handleDelete = async ({ channel }) => {
-  await deleteConversations(channel, baseInfo?.enterpriseId)
+  await deleteConversations(channel, entBaseInfo?.enterpriseId)
   await updateConversation()
   await updateConversation()
   updateUnreadCount()
   updateUnreadCount()
 }
 }
@@ -535,6 +535,10 @@ const handleRefuse = (val) => {
       border-radius: 8px 8px 0 0;
       border-radius: 8px 8px 0 0;
     }
     }
     .message-chat-box {
     .message-chat-box {
+      height: 0;
+      flex: 1;
+      overflow: auto;
+      padding-bottom: 20px;
       .chat-item {
       .chat-item {
         position: relative;
         position: relative;
         width: 100%;
         width: 100%;