瀏覽代碼

系统消息

zhengnaiwen_citu 6 月之前
父節點
當前提交
b4d7d1d147
共有 4 個文件被更改,包括 32 次插入7 次删除
  1. 5 1
      hooks/useIM.js
  2. 6 2
      pages/index/communicate.vue
  3. 19 3
      pagesA/chart/index.vue
  4. 2 1
      pagesB/positionDetail/index.vue

+ 5 - 1
hooks/useIM.js

@@ -148,6 +148,10 @@ export function useDataSource () {
   }
 }
 
+export function toChannel (channelID, channelType) {
+  return new Channel(channelID, channelType)
+}
+
 async function getKey () {
   const useUserStore = userStore()
   if (!useUserStore.accountInfo?.userId) {
@@ -337,7 +341,7 @@ export async function initChart (userId, enterpriseId) {
     }
     // 创建聊天频道
     const { data } = await getChatKey(query)
-    console.log(data, 'data')
+    // console.log(data, 'data')
     const { uid } = data
     const _channel = new Channel(uid, ChannelTypePerson)
     channel.value = _channel

+ 6 - 2
pages/index/communicate.vue

@@ -106,18 +106,22 @@ onLoad(() => {
 
 
 const handleTo = (item) => {
-	const { userInfoVo, thatName, postNameCn, enterpriseAnotherName, channel_id } = item
+	const { userInfoVo, thatName, postNameCn, enterpriseAnotherName, channel_id, channel_type } = item
 	const query = {
 		id: userInfoVo?.userInfoResp?.userId,
 		name: thatName,
 		postName: postNameCn,
 		enterpriseName: enterpriseAnotherName,
 		enterpriseId: userInfoVo?.userInfoResp?.enterpriseId,
-		channelId: channel_id,
+		channelID: channel_id,
+		channelType: channel_type,
 		avatar: userInfoVo?.userInfoResp?.avatar,
 		sex: userInfoVo?.userInfoResp?.sex,
 	}
 	const queryStr = Object.keys(query).reduce((r, v) => {
+		if (!query[v]) {
+			return r
+		}
 		return r += `${v}=${encodeURIComponent(query[v])}&`
 	}, '?')
 	uni.navigateTo({

+ 19 - 3
pagesA/chart/index.vue

@@ -138,6 +138,9 @@
                 </view>
               </view>
             </view>
+            <view v-else-if="val.payload.type === -1" class="message-text" :class="{ active: val.from_uid === IM.uid}">
+              {{ val.payload?.content?.text }}
+            </view>
             <view v-else class="message-text" :class="{ active: val.from_uid === IM.uid}">
               {{ val.payload?.content }}
             </view>
@@ -145,14 +148,14 @@
         </view>
       </scroll-view>
       
-    <view class="box-bottom">
+    <view class="box-bottom" v-if="channelItem?.channelID !== 'system'">
       <view class="box-bottom-tool" style="display: flex; justify-content: space-between;">
         <text class="toolBtn" :class="{ disabled: !isSendResume }" @tap="handleFindResume">{{ isSendResume ? '简历已投递' : '发送简历' }}</text>
         <!-- <uni-tag :text="isSendResume ? '简历已投递' : '发送简历'" :disabled="isSendResume" type="success" @tap="handleFindResume"/> -->
         <!-- <uni-tag text="发 送" type="success" @tap="handleSend"/> -->
       </view>
       
-      <view class="d-flex align-end textBox">
+      <view class="d-flex align-end textBox" v-if="channelItem?.channelID !== 'system'">
         <textarea
           v-model="inputValue"
           :cursor-spacing="25"
@@ -210,7 +213,7 @@ import { ref, watch, onMounted } from 'vue'
 import { onLoad } from '@dcloudio/uni-app'
 import { useIMStore } from '@/store/im'
 import { userStore } from '@/store/user'
-import { initConnect, send, initChart, getMoreMessages } from '@/hooks/useIM'
+import { initConnect, send, initChart, getMoreMessages, toChannel } from '@/hooks/useIM'
 import { getDict } from '@/hooks/useDictionaries'
 import { timesTampChange } from '@/utils/date'
 import { getUserAvatar } from '@/utils/avatar'
@@ -570,6 +573,19 @@ onLoad(async (options) => {
     return r
   }, {})
   isEmployment.value = info.value.isEmployment
+  channelItem.value = toChannel(info.value.channelID, info.value.channelType)
+
+  if (channelItem.value.channelID === 'system') {
+    const { list, more } = await getMoreMessages(1, channelItem.value)
+    hasMore.value = more
+    items.value = list.value
+    setScrollBottom()
+    // 清除未读消息
+    resetUnread(channelItem.value)
+    // 更新未读消息
+    updateUnreadCount()
+    return
+  }
   await init(info.value.id, info.value.enterpriseId)
   // 获取最新的职位信息
   await getMessageTypeSync(info.value.id)

+ 2 - 1
pagesB/positionDetail/index.vue

@@ -542,7 +542,8 @@ async function handleSend () {
 		postName: info.value?.contact?.postNameCn,
 		enterpriseName: info.value?.enterprise?.anotherName,
 		enterpriseId: info.value?.enterpriseId,
-		channelId: channel.channel_id,
+		channelID: channel.channel_id,
+		channelType: channel.channel_type,
 		avatar: info.value?.contact?.avatar,
 		sex: info.value?.contact?.sex,
 	}