zhengnaiwen_citu há 9 meses atrás
pai
commit
ae4a047a95

+ 14 - 0
src/api/common/index.js

@@ -235,4 +235,18 @@ export const getMessageSync = async (data) => {
     url: '/app-api/im/im/channel/messagesync',
     data
   })
+}
+// 设置最近会话未读数量
+export const setUnread = async (data) => {
+  return await request.post({
+    url: '/app-api/im/conversations/setUnread',
+    data
+  })
+}
+// 设置最近会话未读数量
+export const deleteConversation = async (data) => {
+  return await request.post({
+    url: '/app-api/im/conversation/delete',
+    data
+  })
 }

+ 118 - 108
src/hooks/web/useIM.js

@@ -2,7 +2,7 @@
 
 
 import { ref, onMounted, onUnmounted, watch } from 'vue';
-import { getConversationSync, getMessageSync, getChatKey } from '@/api/common'
+import { getConversationSync, getMessageSync, getChatKey, setUnread, deleteConversation } from '@/api/common'
 import { Base64 } from 'js-base64'
 
 import { useUserStore } from '@/store/user'
@@ -10,7 +10,6 @@ import { useLoginType } from '@/store/loginType'
 import { useIMStore } from '@/store/im'
 
 
-
 // 配置悟空IM
 import {
   MessageText,
@@ -18,9 +17,41 @@ import {
   WKSDK,
   ChannelTypePerson,
   // Conversation,
+  MessageContent,
   // Message, StreamItem, ChannelTypeGroup, MessageStatus, SyncOptions, MessageExtra, MessageContent
 } from "wukongimjssdk"
 
+// 注册消息体
+class ObjectContent extends MessageContent {
+  constructor(text) {
+    super();
+    this.content = text;
+  }
+
+  get conversationDigest() {
+      // 这里需要实现具体的逻辑
+      return this.content
+  }
+
+  get contentType() {
+      // 这里需要实现具体的逻辑
+      return 101; // 示例实现
+  }
+
+  decodeJSON(content) {
+      this.content = content.text;
+  }
+
+  encodeJSON() {
+      return {
+        content: this.content
+      };
+  }
+}
+// 注册101类型为面试
+WKSDK.shared().register(101, () => new ObjectContent())
+
+
 const HISTORY_QUERY = {
   limit: 30,
   startMessageSeq: 0,
@@ -88,9 +119,13 @@ export function useDataSource () {
             // const message = Convert.toMessage(msg);
             // msg.channel = new Channel(msg.channel_id, msg.channel_type)
             msg.payload = JSON.parse(Base64.decode(msg.payload))
+            if (msg.payload.type === 101) {
+              msg.payload.content = JSON.parse(msg.payload.content ?? '{}')
+            }
             resultMessages.push(msg);
         });
     }
+    console.log(resultMessages)
     const more = resp.more === 1
     return {
       more,
@@ -99,81 +134,6 @@ export function useDataSource () {
   }
 }
 
-// function toConversation (conversationMap) {
-//   const conversation = new Conversation()
-//   conversation.channel = new Channel(conversationMap['channel_id'], conversationMap['channel_type'])
-//   conversation.unread = conversationMap['unread'] || 0;
-//   conversation.timestamp = conversationMap['timestamp'] || 0;
-//   // let recents = conversationMap["recents"];
-//   // if (recents && recents.length > 0) {
-//   //     const messageModel = toMessage(recents[0]);
-//   //     conversation.lastMessage = messageModel
-//   // }
-//   conversation.extra = {}
-
-//   return conversation
-// }
-// function toMessage(msgMap) {
-//   const message = new Message();
-//   if (msgMap['message_idstr']) {
-//       message.messageID = msgMap['message_idstr'];
-//   }
-//   // else {
-//   //     message.messageID = new BigNumber(msgMap['message_id']).toString();
-//   // }
-//   if (msgMap["header"]) {
-//       message.header.reddot = msgMap["header"]["red_dot"] === 1 ? true : false
-//   }
-//   // if (msgMap["setting"]) {
-//   //     message.setting = Setting.fromUint8(msgMap["setting"])
-//   // }
-//   if (msgMap["revoke"]) {
-//       message.remoteExtra.revoke = msgMap["revoke"] === 1 ? true : false
-//   }
-//   if(msgMap["message_extra"]) {
-//       const messageExtra = msgMap["message_extra"]
-//       message.remoteExtra = this.toMessageExtra(messageExtra)
-//   }
-  
-//   message.clientSeq = msgMap["client_seq"]
-//   message.channel = new Channel(msgMap['channel_id'], msgMap['channel_type']);
-//   message.messageSeq = msgMap["message_seq"]
-//   message.clientMsgNo = msgMap["client_msg_no"]
-//   message.streamNo = msgMap["stream_no"]
-//   message.streamFlag = msgMap["stream_flag"]
-//   message.fromUID = msgMap["from_uid"]
-//   message.timestamp = msgMap["timestamp"]
-//   message.status = MessageStatus.Normal
- 
-//   const contentObj = JSON.parse(Base64.decode(msgMap["payload"]))
-//   // const contentObj = JSON.parse(decodedBuffer.toString('utf8'))
-//   let contentType = 0
-//   if (contentObj) {
-//       contentType = contentObj.type
-//   }
-//   const messageContent = WKSDK.shared().getMessageContent(contentType)
-//   if (contentObj) {
-//       messageContent.decode(this.stringToUint8Array(JSON.stringify(contentObj)))
-//   }
-//   message.content = messageContent
-
-//   message.isDeleted = msgMap["is_deleted"] === 1
-
-//   const streamMaps = msgMap["streams"]
-//   if(streamMaps && streamMaps.length>0) {
-//       const streams = []
-//       for (const streamMap of streamMaps) {
-//           const streamItem = new StreamItem()
-//           streamItem.clientMsgNo = streamMap["client_msg_no"]
-//           streamItem.streamSeq = streamMap["stream_seq"]
-//           streams.push(streamItem)
-//       }
-//       message.streams = streams
-//   }
-
-//   return message
-// }
-
 async function getKey () {
   const userStore = useUserStore()
   const loginType = useLoginType()
@@ -193,8 +153,6 @@ export const useIM = () => {
   useDataSource()
   const key = ref(0)
   const IM = useIMStore()
-  const unreadCount = ref(0)
-  const connected = ref(0)
   
   onMounted( async () => {
     
@@ -230,14 +188,12 @@ export const useIM = () => {
   async function connectStatusListener (status) {
     // console.log('连接状态', status === ConnectStatus.Connected)
     // 连接成功 获取点击数
-    connected.value = status === ConnectStatus.Connected
-    if (connected.value) {
+    const connected = status === ConnectStatus.Connected
+    IM.setConnected(connected)
+    if (connected) {
+      // 必须同步最近会话才能获取未读总数
       await syncConversation()
       setUnreadCount()
-      // setTimeout(() => {
-      //   setUnreadCount()
-      //   console.log('连接成功, 获取总数')
-      // }, 0)
     }
   }
 
@@ -245,14 +201,9 @@ export const useIM = () => {
     const count = WKSDK.shared().conversationManager.getAllUnreadCount()
     key.value++
     IM.setNewMsg(key.value)
-    unreadCount.value = count
+    IM.setUnreadCount(count)
     console.log('未读消息总数', count)
   }
-
-  return {
-    unreadCount,
-    connected
-  }
 }
 
 export function initConnect (callback = () => {}) {
@@ -265,8 +216,7 @@ export function initConnect (callback = () => {}) {
     () => IM.newMsg,
     async () => {
       // 未读消息变化
-      const res = await syncConversation()
-      conversationList.value = res
+      updateConversation()
       // 拉取最新消息 查看是否是自己的数据
     },
     {
@@ -301,8 +251,42 @@ export function initConnect (callback = () => {}) {
       callback(false)
     }
   }
+
+  async function updateConversation () {
+    const res = await syncConversation()
+    conversationList.value = res
+  }
+
+  function updateUnreadCount () {
+    const count = WKSDK.shared().conversationManager.getAllUnreadCount()
+    IM.setUnreadCount(count)
+  } 
+
+  async function deleteConversations (channel, enterpriseId) {
+    const query = {
+      channel_id: channel.channelID,
+      channel_type: channel.channelType,
+      enterpriseId
+    }
+    await deleteConversation(query)
+  }
+
+  async function resetUnread (channel, enterpriseId) {
+    const query = {
+      channel_id: channel.channelID,
+      channel_type: channel.channelType,
+      enterpriseId,
+      unread: 0
+    }
+    const res = await setUnread(query)
+    return res
+  }
+
   return {
-    // connected,
+    resetUnread,
+    deleteConversations,
+    updateConversation,
+    updateUnreadCount,
     conversationList,
     messageItems,
     // channel
@@ -315,15 +299,6 @@ async function syncConversation () {
   return res
 }
 
-// export async function getRecentMessages (channel) {
-//   const { resultMessages, more } = await WKSDK.shared().chatManager.syncMessages(channel, HISTORY_QUERY)
-//   // console.log(res)
-//   // return resultMessages.map(_e => {
-//   //   _e.payload = JSON.parse(Base64.decode(_e.payload))
-//   //   return _e
-//   // })
-// }
-
 // 发起聊天
 export async function initChart (userId, enterpriseId) {
   const channel = ref()
@@ -362,12 +337,47 @@ export async function getMoreMessages (pageSize, channel) {
   }
 }
 
-export function send (text, _channel) {
-  
-  const _text = new MessageText(text) // 文本消息
-  console.log('发送', _text, _channel)
+/**
+ * 
+ * @param {*} text 
+ * @param {*} _channel 
+ * @param { Number } type : 101 面试主体 
+ * @returns 
+ */
+export function send (text, _channel, type) {
+  let _text
+  if (type === 101) {
+    _text = new ObjectContent(text)
+    WKSDK.shared().chatManager.send(_text, _channel)
+    console.log(_text)
+    return
+  }
+  _text = new MessageText(text)
+  console.log(_text)
   WKSDK.shared().chatManager.send(_text, _channel)
 }
 
+// 对话开场白
+export async function prologue ({userId, enterpriseId, text}) {
+  const { channel } = await checkConversation(userId, enterpriseId)
+  send(text, channel)
+}
 
-
+// 检测是否存在频道
+export async function checkConversation (userId, enterpriseId) {
+  const query = {
+    userId,
+    enterpriseId
+  }
+  // 创建聊天频道
+  const { uid } = await getChatKey(query)
+  const _channel = new Channel(uid, ChannelTypePerson)
+  const conversation = WKSDK.shared().conversationManager.findConversation(_channel)
+  if(!conversation) {
+    // 如果最近会话不存在,则创建一个空的会话
+    WKSDK.shared().conversationManager.createEmptyConversation(_channel)
+  }
+  return {
+    channel: _channel
+  }
+}

+ 2 - 1
src/layout/company/navBar.vue

@@ -186,8 +186,9 @@ const handleSwitchToAnotherEnterprise = async () => {
 const handleToAnotherEnterpriseSubmit = async () => { 
   // 获取企业账号令牌以及企业用户个人信息
   await userStore.changeRole(radios.value) // enterpriseId
-  router.push({ path: '/recruit/enterprise' })
+  // router.push({ path: '/recruit/enterprise' })
   localStorage.setItem('loginType', 'enterprise')
+  window.location.href = '/recruit/enterprise'
 }
 
 const test = ref(false)

+ 4 - 17
src/layout/message.vue

@@ -1,8 +1,8 @@
 <template>
   <v-badge
     color="error"
-    :content="unreadCount"
-    :model-value="unreadCount > 0"
+    :content="IM.unreadCount"
+    :model-value="IM.unreadCount > 0"
     offset-y="10"
   >
     <v-btn class="ml-1" size="small" icon="mdi-bell-outline" @click="router.push(path)"></v-btn>
@@ -11,7 +11,6 @@
 
 <script setup>
 defineOptions({ name: 'layout-message' })
-import { watch } from 'vue'
 import { useIM } from '@/hooks/web/useIM'
 import { useIMStore } from '@/store/im'
 import { useRouter } from 'vue-router'
@@ -25,22 +24,10 @@ defineProps({
 
 const router = useRouter()
 
-const _im = useIMStore()
+const IM = useIMStore()
 // useDataSource()
 
-const {
-  unreadCount,
-  connected
-} = useIM()
-
-watch(
-  () => connected.value,
-  (val) => {
-    console.log('connected变化', val)
-    _im.setConnected(val)
-
-  }
-)
+useIM()
 </script>
 
 <style lang="scss" scoped>

+ 2 - 1
src/layout/personal/navBar.vue

@@ -176,7 +176,8 @@ const toEnterprise = async (enterpriseId) => {
   await getUserBindEnterpriseList({ enterpriseId })
   // 获取企业账号令牌以及企业用户个人信息
   await userStore.changeRole(enterpriseId)
-  router.push({ path: '/recruit/enterprise' })
+  // router.push({ path: '/recruit/enterprise' })
+  window.location.href = '/recruit/enterprise'
 }
 
 // 查看用户是否有在申请中的数据

+ 6 - 0
src/store/im.js

@@ -8,6 +8,7 @@ export const useIMStore = defineStore('IM',
 
     const newMsg = ref(0)
     const fromChannel = ref('')
+    const unreadCount = ref(0)
 
     const setConnected = (val) => {
       connected.value = val
@@ -21,11 +22,16 @@ export const useIMStore = defineStore('IM',
     const setFromChannel = (val) => {
       fromChannel.value = val
     }
+    const setUnreadCount = (val) => {
+      unreadCount.value = val
+    }
     return {
       connected,
       uid,
       newMsg,
       fromChannel,
+      unreadCount,
+      setUnreadCount,
       setFromChannel,
       setNewMsg,
       setUid,

+ 83 - 9
src/views/recruit/components/message/components/chatting.vue

@@ -60,11 +60,63 @@
                 ></v-img>
               </v-avatar>
             </div>
-            <div class="message-text" :class="{ active: val.from_uid === IM.uid}">{{ val.payload.content }}</div>
+            <div v-if="val.payload.type === 101">
+              <v-chip
+                class="ma-2"
+                color="teal"
+                label
+              >
+              发起了面试邀请
+              <v-icon icon="mdi-email-newsletter" end></v-icon>
+              </v-chip>
+            </div>
+            <div v-else class="message-text" :class="{ active: val.from_uid === IM.uid}">
+              {{ val.payload.content }}
+            </div>
+          </div>
+          <div v-if="val.payload.type === 101 && val.from_uid !== IM.uid" class="d-flex justify-center">
+            <v-card
+              color="teal"
+              variant="tonal"
+              class="mx-auto"
+            >
+              <v-card-item>
+                <div>
+                  <div class="text-overline mb-1">
+                    面试邀请
+                  </div>
+                  <div class="text-h6 mb-1">
+                    {{ val.payload.content.jobName }}
+                  </div>
+                  
+                  <!-- <div class="text-caption"></div> -->
+                  <div class="text-caption">联系电话: {{ val.payload.content.invitePhone }} 面试时间: {{ val.payload.content.time }}</div>
+                </div>
+              </v-card-item>
+
+              <v-card-actions>
+                <v-btn>
+                  同意
+                </v-btn>
+              </v-card-actions>
+            </v-card>
           </div>
         </div>
       </div>
     </div>
+    <!-- <v-divider></v-divider> -->
+    <div class="tools pa-3" v-if="Object.keys(info).length > 0">
+      <v-btn
+        v-for="tool in tools"
+        :key="tool.name"
+        size="small"
+        :prepend-icon="tool.icon"
+        class="mr-3"
+        @click="tool.handle"
+      >
+        {{ tool.name }}
+      </v-btn>
+    </div>
     <div class="bottom-info">
       <v-divider></v-divider>
       <div class="pa-3">
@@ -96,15 +148,16 @@
 
 <script setup>
 defineOptions({ name: 'message-chatting'})
-import { ref, nextTick, onMounted, defineEmits } from 'vue'
+import { ref, nextTick, onMounted, inject } from 'vue'
 import { timesTampChange } from '@/utils/date'
 import { useIMStore } from '@/store/im'
 
 import { useUserStore } from '@/store/user'
-// const isEnterprise = inject('isEnterprise')
+const isEnterprise = inject('isEnterprise')
+
+const emits = defineEmits(['handleInquire', 'handleInvite', 'handleMore', 'handleSend'])
 
-const emits = defineEmits(['inputVal'])
-defineProps({
+const props = defineProps({
   items: {
     type: Array,
     default: () => []
@@ -113,10 +166,10 @@ defineProps({
     type: Object,
     default: () => ({})
   },
-  uid: {
-    type: String,
-    default: ''
-  },
+  // uid: {
+  //   type: String,
+  //   default: ''
+  // },
   hasMore: {
     type: Boolean,
     default: false
@@ -135,6 +188,27 @@ const inputVal = ref('')
 const pullDowning = ref(false) // 下拉中
 const pulldownFinished = ref(false) // 下拉完成
 
+const enterpriseTools = [
+  { name: '查看面试', icon: 'mdi-email-newsletter', handle: handleInquire },
+  { name: '面试邀约', icon: 'mdi-email', handle: handleInvite }
+]
+
+const userTools = [
+  { name: '查看面试', icon: 'mdi-email-newsletter', handle: handleInquire }
+]
+
+const tools = isEnterprise ? enterpriseTools : userTools
+
+// 查看
+function handleInquire () {
+  console.log(props.info)
+  emits('handleInquire', props.info.userId, props.info.enterpriseId || undefined)
+}
+// 邀请
+function handleInvite () {
+  emits('handleInvite', props.info.userId, props.info.enterpriseId || undefined)
+}
+
 // 滚动到底部
 const scrollBottom = () => {
   const chat = chatRef.value

+ 107 - 32
src/views/recruit/components/message/index.vue

@@ -1,9 +1,23 @@
 <template>
   <div class="default-width message pa-3" :style="`height: calc(100vh - ${isEnterprise ? '130px' : '50px'});`">
     <div class="message-left">
-      <div class="message-left-search d-flex align-center justify-center">
+      <div class="message-left-search d-flex align-center px-3 justify-space-between" >
+        <div>
+          <v-icon class="mr-3">mdi-history</v-icon>
+          最近联系人
+        </div>
+        <div>
+          <v-btn
+            density="compact"
+            :color="showDelete ? '' : 'red'"
+            :icon="showDelete ? 'mdi-close' : 'mdi-trash-can-outline'"
+            variant="text"
+            @click="showDelete = !showDelete"
+          >
+          </v-btn>
+        </div>
         <!-- {{ connected ? '连接成功': '连接失败' }} -->
-        <TextInput v-model="searchInputVal" :item="textItem" @appendInnerClick="handleSearch" @enter="handleSearch"></TextInput>
+        <!-- <TextInput v-model="searchInputVal" :item="textItem" @appendInnerClick="handleSearch" @enter="handleSearch"></TextInput> -->
       </div>
       <div class="message-chat-box mt-5">
         <v-overlay
@@ -25,7 +39,7 @@
               :value="val"
               color="primary"
               class="mb-2"
-              :active="val.userInfoVo && val.userInfoVo.userInfoResp.userId === info.userId"
+              :active="val.channel.channelID === info?.channel?.channelID"
               :title="val.userInfoVo ? val.userInfoVo.userInfoResp.name : '系统消息'"
               :subtitle="timesTampChange(+val.timestamp.padEnd(13, '0'))"
             >
@@ -42,6 +56,7 @@
                   :content="val.unread"
                   inline
                 ></v-badge>
+                <v-btn v-show="showDelete" density="compact" icon="mdi-trash-can-outline" variant="text" color="red" @click.stop="handleDelete(val)"></v-btn>
               </template>
             </v-list-item>
           </v-list>
@@ -57,7 +72,16 @@
       <div v-if="showRightNoData" class="right-noData">
         <Empty :elevation="false" message="与您进行过沟通的 Boss 都会在左侧列表中显示"></Empty>
       </div>
-      <Chatting ref="chatRef" :items="messageItems" :info="info" :has-more="hasMore" @handleSend="handleUpdate" @handleMore="handleGetMore"></Chatting>
+      <Chatting
+        ref="chatRef"
+        :items="messageItems"
+        :info="info"
+        :has-more="hasMore"
+        @handleSend="handleUpdate"
+        @handleMore="handleGetMore"
+        @handleInquire="handleInquire"
+        @handleInvite="handleInvite"
+      ></Chatting>
     </div>
   </div>
 </template>
@@ -65,31 +89,46 @@
 <script setup>
 defineOptions({ name: 'personal-message-index'})
 import { timesTampChange } from '@/utils/date'
-import { ref, inject, watch, nextTick, onMounted } from 'vue'
+import { ref, inject, watch,onMounted, nextTick } from 'vue'
 import Chatting from './components/chatting.vue'
-import { initConnect, send, initChart, getMoreMessages } from '@/hooks/web/useIM'
+import { initConnect, send, initChart, getMoreMessages, checkConversation } from '@/hooks/web/useIM'
 import { useRoute } from 'vue-router'
 import { getPositionDetails } from '@/api/position'
 import { getUserInfo } from '@/api/personal/user'
 import { useIMStore } from '@/store/im'
+import { useUserStore } from '@/store/user'
 import Snackbar from '@/plugins/snackbar'
 
 const chatRef = ref()
 
 const IM = useIMStore()
+const { baseInfo } = useUserStore()
 
 const isEnterprise = inject('isEnterprise')
 // 实例
 const route = useRoute()
 
+const channelItem = ref(null)
+const messageItems = ref([])
+const pageSize = ref(1)
+const hasMore = ref(false)
+
+
+const showDelete = ref(false)
+
+if (!IM) {
+  console.log('IM is disconnected')
+}
+
 if (route.query.id) {
   const api = route.query.enterprise ? getPositionDetails : getUserInfo
   const res = await api({ id: route.query.id })
-  console.log(res)
   onMounted(() => {
-    nextTick(() => {
+    nextTick(async () => {
+      const { channel } = await checkConversation(res.contact.userId, res.contact.enterpriseId)
       const items = [
         {
+          channel,
           userInfoVo: {
             userInfoResp: res.contact
           }
@@ -100,16 +139,13 @@ if (route.query.id) {
   })
 }
 
-const channelItem = ref(null)
-const messageItems = ref([])
-const pageSize = ref(1)
-const hasMore = ref(false)
-
-if (!IM) {
-  console.log('IM is disconnected')
-}
-
-const { conversationList } = initConnect(async (successful) => {
+const {
+  conversationList,
+  updateConversation,
+  updateUnreadCount,
+  deleteConversations,
+  resetUnread
+} = initConnect(async (successful) => {
   if (!successful) {
     Snackbar.error('发送失败')
     return
@@ -117,10 +153,12 @@ const { conversationList } = initConnect(async (successful) => {
   chatRef.value.reset()
   // 发送成功
   const { list } = await getMoreMessages(1, channelItem.value)
+  // updateConversation()
   messageItems.value = list.value
   chatRef.value.scrollBottom()
 })
 
+
 watch(
   () => conversationList.value,
   async () => {
@@ -139,17 +177,18 @@ watch(
   }
 )
 
+
 const showRightNoData = ref(false)
-const searchInputVal = ref()
-const textItem = ref({
-  type: 'text',
-  value: null,
-  width: 336,
-  clearable: true,
-  hideDetails: true,
-  appendInnerIcon: 'mdi-magnify',
-  label: '搜索30天内的联系人'
-})
+// const searchInputVal = ref()
+// const textItem = ref({
+//   type: 'text',
+//   value: null,
+//   width: 336,
+//   clearable: true,
+//   hideDetails: true,
+//   appendInnerIcon: 'mdi-magnify',
+//   label: '搜索30天内的联系人'
+// })
 
 const info = ref({})
 
@@ -157,15 +196,19 @@ const handleUpdate = (val) => {
   send(val.value, channelItem.value)
 }
 
-const handleSearch = () => {
-  console.log(searchInputVal.value, 'search')
-}
+// const handleSearch = () => {
+//   console.log(searchInputVal.value, 'search')
+// }
 
 async function handleChange (items) {
+  // console.log([...items])
   try {
     chatRef.value.changeOverlay(true)
-    const { userInfoVo } = items.pop()
+    const { userInfoVo, channel: myChannel } = items.pop()
     info.value = userInfoVo?.userInfoResp ?? { name: '系统消息' }
+    Object.assign(info.value, {
+      channel: myChannel
+    })
     const userId = userInfoVo.userInfoResp.userId
     const enterpriseId = userInfoVo.userInfoResp.enterpriseId || undefined
     const { channel, list, more } = await initChart(userId, enterpriseId)
@@ -173,6 +216,10 @@ async function handleChange (items) {
     messageItems.value = list.value
     hasMore.value = more
     chatRef.value.scrollBottom()
+    // 点开窗口消除未读数量
+    await resetUnread(channel.value, baseInfo?.enterpriseId)
+    await updateConversation()
+    updateUnreadCount()
   } catch (error) {
     messageItems.value = []
   } finally {
@@ -193,6 +240,34 @@ const handleGetMore = async () => {
   }
 }
 
+const handleDelete = async ({ channel }) => {
+  await deleteConversations(channel, baseInfo?.enterpriseId)
+  await updateConversation()
+  updateUnreadCount()
+}
+
+// 没有企业ID则enterpriseId为undefined
+// 发送消息体 { text, type: 2 }
+// 面试邀约
+const handleInvite = (userId, enterpriseId) => {
+  const query = { userId, enterpriseId }
+  // IM 信息发送
+  const msg = {
+    jobName: '可控核聚变工程师',
+    time: '2024-07-06 15:00:00',
+    invitePhone: '138001380000',
+    address: '北京市海淀区中关村',
+    remark: '备注'
+  }
+  send(JSON.stringify(msg), channelItem.value, 101)
+  console.log(query)
+}
+// 查看面试
+const handleInquire = (userId, enterpriseId) => {
+  const query = { userId, enterpriseId }
+  console.log(query)
+}
+
 </script>
 
 <style scoped lang="scss">

+ 8 - 2
src/views/recruit/personal/position/components/details.vue

@@ -54,7 +54,7 @@
             :prepend-icon="isCollection ? 'mdi-heart' : 'mdi-heart-outline'"
             @click="handleCollection"
           >{{ isCollection ? $t('position.cancelFavorite') : $t('position.collection') }}</v-btn>
-          <v-btn class="button-item mx-2 radius" color="success" variant="outlined">{{ $t('position.communicate') }}</v-btn>
+          <v-btn class="button-item mx-2 radius" color="success" variant="outlined" @click="toDetails(info)">{{ $t('position.communicate') }}</v-btn>
           <v-btn class="button-item radius" :disabled="delivery" color="primary" variant="outlined" @click="handleDelivery">{{ delivery ? $t('position.delivered') : $t('position.submitResume') }}</v-btn>
         </div>
       </div>
@@ -160,6 +160,7 @@ import Dialog from '@/components/CtDialog'
 import promptToUpload from './jobDetails/promptToUpload'
 import selectResumeDialog from './jobDetails/selectResumeDialog'
 import { getToken } from '@/utils/auth'
+import { prologue } from '@/hooks/web/useIM'
 
 const { t } = useI18n()
 const router = useRouter()
@@ -312,11 +313,16 @@ const handleSubmit = async (val) =>{
   deliveryCheck()
 }
 
-const toDetails = (info) => {
+const toDetails = async (info) => {
+  const userId = info.contact.userId
+  const enterpriseId = info.contact.enterpriseId
+  const text = '您好,我对该职位很感兴趣,希望能有机会与您进一步沟通。'
+  await prologue({userId, enterpriseId, text})
   let url = `/recruit/personal/message?id=${info.id}`
   if (info.contact.enterpriseId) {
     url += `&enterprise=${info.contact.enterpriseId}`
   }
+
   router.push(url)
 }
 </script>