Ver código fonte

fix: 1.群的公告修改,和消息面打扰修改,
2.群聊的介绍修改

suwenjiang 1 mês atrás
pai
commit
1f351db15c

+ 1 - 1
.env.development

@@ -17,7 +17,7 @@ VITE_APP_ENV=development
 # 黄雯本地
 # VITE_APP_BASE_URL=http://192.168.1.44:8082/
 # 本地socoket
-# VITE_APP_IM_URL=ws://192.168.1.44:8082/system/message
+# VITE_APP_IM_URL=ws://192.168.1.44:8082/system/message/
 # 花生壳
 # VITE_APP_BASE_URL=http://q9943037p3.goho.co
 # VITE_APP_IM_URL=ws://q9943037p3.goho.co/system/message

+ 21 - 15
src/components/Profile/News/GroupChat.vue

@@ -4,11 +4,7 @@
       @click="$emit('onChatPage')"
       class="w-full relative h-82 flex justify-start items-center px-16"
     >
-      <van-badge
-        v-if="itemData?.unreadMessageCount > 0"
-        v-bind="messageNumber(itemData?.unreadMessageCount)"
-        max="99"
-      >
+      <van-badge v-if="itemData?.unreadMessageCount > 0" v-bind="messageNumber(itemData)" max="99">
         <MultiHeader :size="48" :imgUrls="itemData?.dfGroupImage" />
       </van-badge>
       <MultiHeader v-else :size="48" :imgUrls="itemData?.dfGroupImage" />
@@ -22,8 +18,8 @@
         </p>
       </div>
 
-      <div class="w-35 h-48 shrink-0">
-        <p class="text-black/[0.6] mb-12 text-sm text-end">{{ itemData?.updateTime }}</p>
+      <div class="w-35 h-48 shrink-0 box-border">
+        <p class="text-black/[0.6] text-sm text-end">{{ itemData?.updateTime }}</p>
 
         <div v-if="itemData?.isNotDisturb == 1" class="w-full shrink-0 flex justify-end">
           <span class="iconfont icon-close-remind text-black-6" style="font-size: 16px"></span>
@@ -75,21 +71,31 @@ const props = defineProps({
 defineEmits(['onNoBother', 'onIsTop', 'onConvDelete', 'onChatPage'])
 
 // 消息数量通知的展示  需要动态的展示
-const messageNumber = (content) => {
+const messageNumber = (itemData) => {
   let messageNumberObj = {}
-  if (content <= 1) {
-    messageNumberObj = {
-      offset: [-5, 4],
-      dot: true,
-      content
+  let content = itemData?.unreadMessageCount
+  if (!itemData?.isNotDisturb) {
+    if (content <= 1) {
+      messageNumberObj = {
+        offset: [-5, 4],
+        dot: true,
+        content
+      }
     }
-  }
-  if (content > 1) {
+    if (content > 1) {
+      messageNumberObj = {
+        offset: [-10, 7],
+        content
+      }
+    }
+  } else {
     messageNumberObj = {
       offset: [-10, 7],
+      dot: false,
       content
     }
   }
+
   return messageNumberObj
 }
 </script>

+ 21 - 13
src/components/Profile/News/SingleChat.vue

@@ -2,12 +2,12 @@
   <van-swipe-cell>
     <div
       @click="$emit('onChatPage')"
-      class="w-full h-82 relative flex justify-start items-center px-16 mb-20"
+      class="w-full h-82 relative flex justify-start items-center px-16"
     >
       <div class="w-48 h-48">
         <van-badge
           v-if="itemData?.unreadMessageCount > 0"
-          v-bind="messageNumber(itemData?.unreadMessageCount)"
+          v-bind="messageNumber(itemData)"
           max="99"
         >
           <div
@@ -58,7 +58,7 @@
         </p>
       </div>
 
-      <div class="w-35 h-48 shrink-0">
+      <div class="w-35 h-48 shrink-0 box-border">
         <p class="text-black/[0.6] text-sm text-end">{{ itemData?.updateTime }}</p>
 
         <div v-if="itemData?.isNotDisturb == 1" class="w-full h-16 shrink-0 mt-12 flex justify-end">
@@ -104,8 +104,6 @@
 </template>
 
 <script setup>
-import { messageContentParse } from '~/utils/detalTime.js'
-
 defineProps({
   itemData: {
     type: Object,
@@ -115,21 +113,31 @@ defineProps({
 defineEmits(['onNoBother', 'onIsTop', 'onConvDelete', 'onChatPage'])
 
 // 消息数量通知的展示  需要动态的展示
-const messageNumber = (content) => {
+const messageNumber = (itemData) => {
   let messageNumberObj = {}
-  if (content <= 1) {
-    messageNumberObj = {
-      offset: [-5, 4],
-      dot: true,
-      content
+  let content = itemData?.unreadMessageCount
+  if (!itemData?.isNotDisturb) {
+    if (content <= 1) {
+      messageNumberObj = {
+        offset: [-5, 4],
+        dot: true,
+        content
+      }
     }
-  }
-  if (content > 1) {
+    if (content > 1) {
+      messageNumberObj = {
+        offset: [-10, 7],
+        content
+      }
+    }
+  } else {
     messageNumberObj = {
       offset: [-10, 7],
+      dot: false,
       content
     }
   }
+
   return messageNumberObj
 }
 </script>

+ 2 - 3
src/pages/chat/announcement.vue

@@ -11,7 +11,6 @@
           :class="`font-semibold text-xl ${showBottom ? 'text-[#FF9300]' : 'text-black-9'} `"
           @click="getUpdAnnouncement"
         >
-          <!--   -->
           确认
         </div>
       </template>
@@ -109,7 +108,7 @@ const getUpdAnnouncement = async () => {
       method: 'post',
       body: {
         groupId: queryDataName.groupId,
-        messageContent: queryDataName.groupNotice
+        messageContent: queryDataName?.groupNotice
       }
     })
     if (data) {
@@ -130,7 +129,7 @@ const getAnnouncement = async () => {
     }
   })
   if (data) {
-    queryDataName.groupNotice = data.groupNotice
+    queryDataName.groupNotice = data.groupNotice?.messageContent
     if (Array.isArray(data.memberList) && data?.memberList?.length) {
       data.memberList.map((el) => {
         if (el.userId == queryDataName.userId) {

+ 25 - 2
src/pages/chat/create-group.vue

@@ -143,7 +143,7 @@
             color="#FF9300"
             round
             block
-            @click="show = false"
+            @click="changeBelongTypeId"
           >
             确认
           </van-button>
@@ -220,6 +220,13 @@ const handleTypeClick = (item) => {
   } else {
     showIndex.value = item.id
     subTypeList.value = item.children
+    if (item.children == 0) {
+      childrenIndex.value = item.id
+      groupTypeName.value = item.typeName
+    } else {
+      childrenIndex.value = null
+      groupTypeName.value = ''
+    }
   }
 }
 
@@ -228,7 +235,6 @@ const childrenHandleTypeClick = (item) => {
   if (childrenIndex.value == item?.id) {
     formData.belongTypeId = ''
     childrenIndex.value = null
-
     groupTypeName.value = TYPE_TEXT
   } else {
     formData.belongTypeId = item.id
@@ -237,6 +243,23 @@ const childrenHandleTypeClick = (item) => {
   }
 }
 
+// 确认群聊类型
+const changeBelongTypeId = () => {
+  if (groupTypeName.value && childrenIndex.value) {
+    if (childrenIndex.value != setData.belongTypeId) {
+      show.value = false
+    }
+  } else {
+    showDialog({
+      width: 260,
+      message: '请选择群类型',
+      confirmButtonColor: '#FF9400'
+    })
+      .then(() => {})
+      .catch(() => {})
+  }
+}
+
 const isSubmiting = ref(false)
 // 创建群聊
 async function handleCreateGroup() {

+ 17 - 5
src/pages/chat/group-chat.vue

@@ -24,7 +24,7 @@
     </van-nav-bar>
 
     <van-notice-bar
-      v-if="groupInfo?.groupNotice"
+      v-if="groupInfo?.groupNotice?.messageContent"
       left-icon="volume-o"
       mode="link"
       @click="
@@ -36,7 +36,7 @@
           }
         })
       "
-      :text="groupInfo?.groupNotice"
+      :text="groupInfo?.groupNotice?.messageContent"
     ></van-notice-bar>
 
     <template v-if="showPage">
@@ -44,8 +44,13 @@
       <van-list
         ref="chatListRef"
         class="h-full overflow-y-auto px-12 flex flex-col"
-        :finished="true"
+        :offset="50"
+        v-model="loading"
+        :finished="finished"
+        direction="up"
+        scroller
         finished-text=""
+        @load="loadMore"
       >
         <!-- <div ref="chatListRef" class="h-full overflow-y-auto px-12 flex flex-col"> -->
         <template v-for="(message, index) in currConversationChatList" :key="index">
@@ -84,6 +89,9 @@ import { findHyperlinks } from '~/pages/chat/components/chat-message/link-messag
 import { XYWebSocket } from '~/utils/XYWebSocket'
 import { isValidJson } from '~/utils'
 
+const finished = ref(false)
+const loading = ref(false)
+
 const route = useRoute()
 const router = useRouter()
 
@@ -269,10 +277,13 @@ const scrollToBottom = async () => {
 const refreshing = ref(false)
 const loadMore = async () => {
   try {
-    refreshing.value = true
+    // refreshing.value = true
+    loading.value = true
+    finished.value = true
     if (currConversationChatList.value.length) {
       if (totalCount.value == currConversationChatList.value.length) {
         // 已经加载了全部
+        finished.value = false
       } else {
         await getChatList('more')
       }
@@ -281,7 +292,8 @@ const loadMore = async () => {
     }
   } catch (e) {
   } finally {
-    refreshing.value = false
+    loading.value = false
+    finished.value = false
   }
 }
 

+ 1 - 1
src/pages/chat/set-sub/index.vue

@@ -161,7 +161,7 @@ useSeoMeta({
 })
 </script>
 <style lang="scss" scoped>
-.custom-class {
+::v-deep .custom-class {
   color: #ff9300;
 }
 </style>

+ 81 - 35
src/pages/chat/set.vue

@@ -147,10 +147,22 @@
           center
           is-link
           title="群公告"
-          :value="setData?.groupNotice ? '' : '未设置'"
+          :value="setData?.groupNotice?.messageContent ? '' : '未设置'"
         ></van-cell>
 
-        <van-cell @click="handleDescription" size="large" center>
+        <van-cell
+          @click="
+            handleDescription({
+              title: '群介绍',
+              value: setData?.description,
+              placeholder: '请输入群介绍的内容',
+              isRemark: 3,
+              subTitle: '群介绍最多可输入200字'
+            })
+          "
+          size="large"
+          center
+        >
           <template #title>
             <p class="w-full line-clamp-1">群介绍:{{ setData?.description }}</p>
           </template>
@@ -359,7 +371,7 @@
     </div>
 
     <ChatDialog
-      v-model:show="showDialog"
+      v-model:show="showDialogs"
       v-model:title="dialogTitle"
       @confirm="confirm"
       @cancel="cancel"
@@ -368,7 +380,18 @@
         <p class="mx-auto w-[80%] text-sm text-black-9 mb-16">{{ dialogSubTitle }}</p>
 
         <van-field
-          class=""
+          v-if="isRemark == 3"
+          style="background: #f5f5f5; border-radius: 8px; margin-bottom: 30px"
+          clearable
+          rows="2"
+          autosize
+          type="textarea"
+          :placeholder="dialogPlaceholder"
+          v-model="groupName"
+          maxlength="200"
+        />
+        <van-field
+          v-else
           style="height: 40px; background: #f5f5f5; border-radius: 8px; margin-bottom: 30px"
           clearable
           :placeholder="dialogPlaceholder"
@@ -504,15 +527,15 @@ const isNotDisturb = ref(0)
 const isTop = ref(0)
 
 // 弹出窗
-const showDialog = ref(false)
-const isRemark = ref(0) //0 群名称 1备注 2 我在群里的昵称
+const showDialogs = ref(false)
+const isRemark = ref(0) //0 群名称 1备注 2 我在群里的昵称 3 修改群介绍
 const dialogTitle = ref('')
 const dialogPlaceholder = ref('')
 const dialogSubTitle = ref('')
 
 // 弹窗的方法
 const openDialog = (item) => {
-  showDialog.value = true
+  showDialogs.value = true
   dialogTitle.value = item?.title
   isRemark.value = item.isRemark
   groupName.value = item?.value
@@ -521,17 +544,21 @@ const openDialog = (item) => {
 }
 // 弹窗确认的事件
 const confirm = () => {
+  // 修改群名称
   if (userGroupData.value?.groupRole == 1 && isRemark.value == 0)
     changeGroupName({ groupName: groupName.value })
+  // 修改群介绍
+  if (userGroupData.value?.groupRole == 1 && isRemark.value == 3)
+    changeGroupName({ groupId: setData.id, description: groupName.value })
 
+  // 修群备注
   if (isRemark.value == 1) changeTourMember({ groupId: setData.id, remark: groupName.value })
 
+  // 修改群昵称
   if (isRemark.value == 2)
     changeGroupName({
       groupNickname: groupName.value
     })
-
-  // showDialog.value = false
 }
 
 // groupName 修改群名称
@@ -552,7 +579,8 @@ const changeGroupName = async (body) => {
     })
 
     if (data) {
-      userGroupData.value[Object.keys(body)[0]] = groupName.value
+      getGroupSetData()
+      // userGroupData.value[Object.keys(body)[0]] = groupName.value
 
       // showSuccessToast('修改成功')
     } else {
@@ -586,6 +614,13 @@ const handleTypeClick = (item) => {
   } else {
     showIndex.value = item.id
     subTypeList.value = item.children
+    if (item.children == 0) {
+      childrenIndex.value = item.id
+      groupTypeName.value = item.typeName
+    } else {
+      childrenIndex.value = null
+      groupTypeName.value = ''
+    }
   }
 }
 // 选中群类型子集的方法
@@ -623,12 +658,21 @@ async function getTreeType() {
   }
 }
 
-// 群聊类型
-const changeBelongTypeId = async () => {
-  if (childrenIndex.value != setData.belongTypeId) {
-    changeGroupBelongTypeIdIsNeedConfirm({ belongTypeId: childrenIndex.value })
+// 确认群聊类型
+const changeBelongTypeId = () => {
+  if (groupTypeName.value && childrenIndex.value) {
+    if (childrenIndex.value != setData.belongTypeId) {
+      changeGroupBelongTypeIdIsNeedConfirm({ belongTypeId: childrenIndex.value })
+    }
+  } else {
+    showDialog({
+      width: 260,
+      message: '请选择群类型',
+      confirmButtonColor: '#FF9400'
+    })
+      .then(() => {})
+      .catch(() => {})
   }
-  showBelongTypeId = false
 }
 
 // 修改 群聊类型  是否开启群验证
@@ -642,10 +686,13 @@ async function changeGroupBelongTypeIdIsNeedConfirm(body) {
       }
     })
     if (data) {
-      if ((userGroupData.value[Object.keys(body)[0]] = 'belongTypeId')) {
-        setData.belongTypeIdDictMap.name = groupTypeName.value
-      }
-      // showSuccessToast('修改成功')
+      // if ((userGroupData.value[Object.keys(body)[0]] = 'belongTypeId')) {
+      //   setData.belongTypeIdDictMap.name = groupTypeName.value
+
+      // }
+      getGroupSetData()
+      showBelongTypeId.value = false
+      showSuccessToast('修改成功')
       return
     }
   } catch (error) {}
@@ -662,11 +709,12 @@ const changeTourMember = async (body) => {
 
     if (data) {
       //修改成功
-      if ((Object.keys(body)[1] = 'remark')) {
-        userGroupData.value.groupRemark = groupName.value
-      } else {
-        userGroupData.value[Object.keys(body)[1]] = groupName.value
-      }
+      getGroupSetData()
+      // if ((Object.keys(body)[1] = 'remark')) {
+      //   userGroupData.value.groupRemark = groupName.value
+      // } else {
+      //   userGroupData.value[Object.keys(body)[1]] = groupName.value
+      // }
       showSuccessToast('操作成功')
     } else {
       // showSuccessToast('操作失败')
@@ -676,7 +724,7 @@ const changeTourMember = async (body) => {
 
 // 弹窗的取消
 const cancel = () => {
-  showDialog.value = false
+  showDialogs.value = false
 }
 
 // 数字转换成布尔值
@@ -789,21 +837,19 @@ const handleAnnouncement = () => {
 }
 
 // 修改群介绍
-const handleDescription = () => {
+const handleDescription = (item) => {
   if (isRankAndFiler(userGroupData.value?.groupRole)) {
-    showDialog({
-      width: 260,
-      title: '群介绍',
-      message: setData.description,
-      confirmButtonColor: '#FF9400'
-    }).then(() => {
-      // on close
-    })
+    showDialogs.value = true
+    dialogTitle.value = item.title
+    isRemark.value = item.isRemark
+    groupName.value = item?.value
+    dialogPlaceholder.value = item?.placeholder
+    dialogSubTitle.value = item?.subTitle
   } else {
     showDialog({
       width: 260,
       title: '群介绍',
-      message: setData.description,
+      message: setData?.description ? setData?.description : '暂无群介绍',
       confirmButtonColor: '#FF9400'
     }).then(() => {
       // on close

+ 30 - 6
src/pages/chat/single-chat.vue

@@ -7,11 +7,15 @@
         </div>
       </template>
       <template #title>
-        <div class="text-2xl text-black-3 text-semibold">
-          <div class="inline-block w-220 line-clamp-1">
-            {{ title }}
+        <div class="text-2xl text-black-3 text-semibold flex items-center">
+          <div style="min-width: 50px; max-width: 200px" class="inline-block line-clamp-1">
+            {{ memberInfo?.groupRemark }}
           </div>
-          <!-- <span class="ml-7 iconfont icon-close-remind text-black-9" style="font-size: 16px"></span> -->
+          <span
+            v-if="memberInfo?.isNotDisturb"
+            class="ml-7 iconfont icon-close-remind text-black-9"
+            style="font-size: 16px"
+          ></span>
         </div>
       </template>
       <template #right>
@@ -70,8 +74,9 @@ const chatsStore = useChatsStore()
 const userInfoStore = useUserInfoStore()
 
 const { userInfo } = storeToRefs(userInfoStore)
-// 单聊的标题
-const title = computed(() => route.query?.groupRemark)
+
+// 对方成员的信息
+const memberInfo = ref({})
 
 // 聊天列表
 const chatListRef = ref(null)
@@ -88,9 +93,11 @@ const initGroupId = async () => {
   try {
     if (!getUserId.value) return
     pageLoading.value = true
+
     const res = await chatsStore.getCurrConversationId(getUserId.value)
     await handleResponse(res)
     groupId.value = res.data
+    getAnnouncement()
     await getChatList('init')
   } catch (e) {
   } finally {
@@ -310,6 +317,23 @@ onMounted(() => {
 
 watchEffect(() => {})
 
+// 会话好友的信息
+async function getAnnouncement() {
+  let { data } = await request('/website/tourGroup/getGroupInfoAndMemberByGroupId', {
+    query: { groupId: groupId.value }
+  })
+
+  if (data) {
+    if (Array.isArray(data.memberList) && data?.memberList?.length) {
+      data.memberList.map((el) => {
+        if (el.userId == userInfo.value.userId) {
+          memberInfo.value = el
+        }
+      })
+    }
+  }
+}
+
 // 用户删除消息
 const delMessage = (messageId) => {
   showConfirmDialog({

+ 37 - 2
src/pages/follow/components/follow-list/index.vue

@@ -7,7 +7,16 @@
     finished-text="-- 没有更多了 --"
     @load="onLoad"
   >
-    <van-cell v-for="(item, i) in list" :key="i">
+    <van-cell
+      v-for="(item, i) in list"
+      :key="i"
+      @click="
+        createSingle({
+          getUserId: item.attentionId,
+          noticeType: 1
+        })
+      "
+    >
       <div class="follow-item flex flex-row items-center w-full h-82 text-left" fit="cover">
         <van-image width="48" height="48" round class="mr-12" :src="item?.avatar" />
         <div class="flex-col flex-1 mr-12 min-w-0">
@@ -25,7 +34,7 @@
             :disabled="item.saveLoading"
             :color="FANS_STATUS[item.fansStatus].bg"
             type="primary"
-            @click="handleFollow(item)"
+            @click.stop="handleFollow(item)"
           >
             {{ FANS_STATUS[item.fansStatus].text }}
           </van-button>
@@ -40,6 +49,9 @@ const props = defineProps({
   listType: { type: String, default: 'friend' } // friend|follow|fans
 })
 
+const userInfoStore = useUserInfoStore()
+const { userInfo } = storeToRefs(userInfoStore)
+
 const listConfig = new Map([
   [
     'friend',
@@ -151,6 +163,29 @@ const handleFollow = async (item) => {
   }
 }
 
+// 随机生成的唯一id
+function getLocalId() {
+  const random = Math.floor(Math.random() * 10000)
+  return Date.now() + '' + random
+}
+
+// 创建单聊的会话
+const createSingle = async (body) => {
+  body.groupId = getLocalId()
+
+  body.sendUserId = userInfo.value.userId
+  const { data } = await request('/website/tourGroup/createMember', {
+    method: 'post',
+    body
+  })
+  if (data) {
+    navigateTo({
+      path: '/profile/my-news',
+      replace: true
+    })
+  }
+}
+
 onLoad()
 </script>
 <style scoped lang="scss">

+ 8 - 2
src/pages/profile/my-news/index.vue

@@ -337,10 +337,16 @@ useSeoMeta({
 
 // 时间的转换
 const createTimeSplit = (timer) => {
+  let h = ''
   if (timer) {
-    return timer.split(' ')[1]
+    let days = timer.split(' ')[1]?.split(':')
+
+    h = `${days[0]}:${days[1]}`
   }
+
+  return h
 }
+
 // 下拉刷新
 const onRefresh = () => {
   refreshing.value = true
@@ -430,7 +436,7 @@ const onSelect = (action) => {
 }
 
 const goDetails = (type, item) => {
-  console.log(type, item, 'itemitem')
+  // console.log(type, item, 'itemitem')
   switch (type) {
     case 'single': // 单聊消息
       readMessage(item.groupId)