index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <div class="w-full">
  3. <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
  4. <van-sticky :offset-top="50">
  5. <div
  6. class="w-full text-xl font-semibold px-16 h-48 flex justify-start items-center bg-white"
  7. >
  8. <span
  9. @click="showPopover = true"
  10. v-if="showPopover"
  11. class="iconfont icon-plus text-[#FF9300]"
  12. style="font-size: 24px"
  13. ></span>
  14. <span v-else class="iconfont icon-plus text-black" style="font-size: 24px"></span>
  15. <van-popover
  16. v-model:show="showPopover"
  17. placement="bottom"
  18. theme="dark"
  19. offset="[5,20]"
  20. :actions="actionsList"
  21. @select="onSelect"
  22. >
  23. <template #reference>
  24. <span :class="`${showPopover ? 'text-[#FF9300]' : 'text-black-3'}`">添加</span>
  25. </template>
  26. </van-popover>
  27. </div>
  28. </van-sticky>
  29. <div
  30. @click="onChatPage('/profile/system-message', {})"
  31. class="w-full relative h-82 flex justify-start items-center px-16"
  32. >
  33. <van-badge v-if="messagesNumber > 0" v-bind="messageNumber(messagesNumber)" max="99">
  34. <div
  35. class="w-48 h-48 bg-[#0052D9] rounded-full overflow-hidden flex justify-center items-center"
  36. >
  37. <img
  38. class="w-24 h-24 shrink-0 object-cover"
  39. src="~/assets/img/chat/remind.svg"
  40. alt=""
  41. />
  42. </div>
  43. </van-badge>
  44. <div
  45. v-else
  46. class="w-48 h-48 bg-[#0052D9] rounded-full overflow-hidden flex justify-center items-center"
  47. >
  48. <img class="w-24 h-24 shrink-0 object-cover" src="~/assets/img/chat/user.svg" alt="" />
  49. </div>
  50. <div class="h-48 w-245 shrink-0 ml-12 flex flex-wrap items-end">
  51. <h1 class="line-clamp-1 w-full text-base text-black-3 font-semibold mb-4">系统消息</h1>
  52. <p class="line-clamp-1 h-20 text-sm text-black-6 leading-3xl">
  53. 你吃饭了么wwwwwdasdasdasdwwwwwwwwwwwwwwwwwwwwwwwssssssssssssssssssssssssssssss
  54. </p>
  55. </div>
  56. <div class="w-35 h-48 shrink-0">
  57. <p class="text-black/[0.6] text-sm text-end">02:06</p>
  58. </div>
  59. <div class="absolute bottom-0 right-0 w-[96%] h-1 border-b-[1px]"></div>
  60. </div>
  61. <div
  62. @click="onChatPage('/', {})"
  63. class="w-full relative h-82 flex justify-start items-center px-16"
  64. >
  65. <van-badge v-if="messagesNumber > 0" v-bind="messageNumber(messagesNumber)" max="99">
  66. <div
  67. class="w-48 h-48 bg-[#FF9300] rounded-full overflow-hidden flex justify-center items-center"
  68. >
  69. <img class="w-24 h-24 shrink-0 object-cover" src="~/assets/img/chat/user.svg" alt="" />
  70. </div>
  71. </van-badge>
  72. <div
  73. v-else
  74. class="w-48 h-48 bg-[#0052D9] rounded-full overflow-hidden flex justify-center items-center"
  75. >
  76. <img class="w-24 h-24 shrink-0 object-cover" src="~/assets/img/chat/user.svg" alt="" />
  77. </div>
  78. <div class="h-48 w-245 shrink-0 ml-12 flex flex-wrap items-end">
  79. <h1 class="line-clamp-1 w-full text-base text-black-3 font-semibold mb-4">新增粉丝</h1>
  80. <p class="line-clamp-1 h-20 text-sm text-black-6 leading-3xl">
  81. 你吃饭了么wwwwwdasdasdasdwwwwwwwwwwwwwwwwwwwwwwwssssssssssssssssssssssssssssss
  82. </p>
  83. </div>
  84. <div class="w-35 h-48 shrink-0">
  85. <p class="text-black/[0.6] text-sm text-end">02:06</p>
  86. </div>
  87. <div class="absolute bottom-0 right-0 w-[96%] h-1 border-b-[1px]"></div>
  88. </div>
  89. <div
  90. @click="onChatPage('/profile/interaction-message', {})"
  91. class="w-full relative h-82 flex justify-start items-center px-16"
  92. >
  93. <van-badge v-if="messagesNumber > 0" v-bind="messageNumber(messagesNumber)" max="99">
  94. <div
  95. class="w-48 h-48 bg-[#FF9300] rounded-full overflow-hidden flex justify-center items-center"
  96. >
  97. <img class="w-24 h-24 shrink-0 object-cover" src="~/assets/img/chat/user.svg" alt="" />
  98. </div>
  99. </van-badge>
  100. <div
  101. v-else
  102. class="w-48 h-48 bg-[#0052D9] rounded-full overflow-hidden flex justify-center items-center"
  103. >
  104. <img class="w-24 h-24 shrink-0 object-cover" src="~/assets/img/chat/user.svg" alt="" />
  105. </div>
  106. <div class="h-48 w-245 shrink-0 ml-12 flex flex-wrap items-end">
  107. <h1 class="line-clamp-1 w-full text-base text-black-3 font-semibold mb-4">互动消息</h1>
  108. <p class="line-clamp-1 h-20 text-sm text-black-6 leading-3xl">收藏了你的游记</p>
  109. </div>
  110. <div class="w-35 h-48 shrink-0">
  111. <p class="text-black/[0.6] text-sm text-end">02:06</p>
  112. </div>
  113. <div class="absolute bottom-0 right-0 w-[96%] h-1 border-b-[1px]"></div>
  114. </div>
  115. <!-- 置顶绘画列表 -->
  116. <div v-if="activeNames" class="w-full">
  117. <template v-for="(item, index) in pinnedList" :key="index">
  118. <ProfileNewsGroupChat
  119. :item-data="{ title: item }"
  120. @on-chat-page="
  121. onChatPage('/chat/group', { userId: userInfo.userId, groupId: '1877363770339758081' })
  122. "
  123. @on-no-bother="noBother(item)"
  124. @on-conv-delete="convDelete()"
  125. />
  126. </template>
  127. </div>
  128. <div
  129. v-if="pinnedList.length >= 6"
  130. @click="activeNames = !activeNames"
  131. class="flex justify-between border items-center h-20 w-full p-16 box-border"
  132. >
  133. <div class="shrink-0 flex items-center">
  134. <van-icon name="bars" size="16" class="mr-5" />
  135. <span class="text-sm">{{ collapseTitle }}</span>
  136. </div>
  137. <div class="w-16 h-16 shrink-0">
  138. <van-icon name="arrow" size="16" />
  139. <!-- <img class="w-full h-full object-cover" src="" alt="" /> -->
  140. </div>
  141. </div>
  142. <ProfileNewsGroupChat
  143. @on-chat-page="
  144. onChatPage('/chat/group', { userId: userInfo.userId, groupId: '1877349481146540033' })
  145. "
  146. @on-no-bother="noBother()"
  147. @on-conv-delete="convDelete()"
  148. />
  149. <ProfileNewsSingleChat
  150. @on-chat-page="onChatPage('/chat/single', { userId: userInfo.userId, singleId: '2' })"
  151. @on-no-bother="noBother()"
  152. @on-conv-delete="convDelete()"
  153. />
  154. </van-pull-refresh>
  155. </div>
  156. </template>
  157. <script setup>
  158. import comments from '~/assets/img/chat/comments-white.svg'
  159. import plaza from '~/assets/img/chat/guangchang.svg'
  160. import userAdd from '~/assets/img/chat/user-add.svg'
  161. const actionsList = [
  162. { text: '创建群聊', icon: comments },
  163. { text: '群聊广场', icon: plaza },
  164. { text: '加入群聊', icon: plaza },
  165. { text: '添加用户', icon: userAdd }
  166. ]
  167. const userInfoStore = useUserInfoStore()
  168. const { userInfo } = storeToRefs(userInfoStore)
  169. const uploadUrl = `${import.meta.env.VITE_APP_BASE_URL}/website/tourMessage/upload`
  170. const chatStore = useChatStore()
  171. const { ws, curConversiton, receive, receiveGetter, connectSta, onNewMessage } =
  172. storeToRefs(chatStore)
  173. const user = computed(() => chatStore.user)
  174. // 消息接收者的用户id
  175. const getUserId = computed(() => curConversiton.value.toUserId)
  176. // 消息发送者:当前登录用户的加密id
  177. const sendUserId = computed(() => user.value.pass)
  178. // 会话id
  179. const groupId = computed(() => curConversiton.value.groupId)
  180. // 用户在群聊中艾特的人
  181. const specialUserId = ref('')
  182. // 用户输入的文本消息
  183. const messageContent = ref('')
  184. // 聊天类型 1单聊 2群聊 3系统消息 4关注信息
  185. const noticeType = computed(() => curConversiton.value.noticeType)
  186. onMounted(() => {
  187. userInfoStore.getUserInfo()
  188. })
  189. useSeoMeta({
  190. title: '我的消息'
  191. })
  192. // 获取连接状态
  193. const isConnected = computed(() => chatStore.isConnected)
  194. // 连接 WebSocket
  195. // const connectSocket = () => {
  196. // chatStore.connect(`?userId=${userInfo.value.userId}`)
  197. // }
  198. // 发送测试消息
  199. // const sendTestMessage = () => {
  200. // chatStore.sendMessage({ message: 'Hello WebSocket!' })
  201. // }
  202. // 断开 WebSocket
  203. // const disconnectSocket = () => {
  204. // chatStore.disconnect()
  205. // }
  206. // 消息历史
  207. // const messages = computed(() => chatStore.wsService.value?.messages || [])
  208. const finished = ref(false)
  209. const error = ref(false)
  210. const loading = ref(false)
  211. const showPopover = ref(false)
  212. const messagesNumber = ref(10)
  213. // 置顶列表
  214. const pinnedList = ref([1, 2, 3, 4, 5, 6, 7])
  215. // 个置顶聊天
  216. const collapse_text = '折叠置顶聊天'
  217. const activeNames = ref(true)
  218. // collapse
  219. const collapseTitle = ref(collapse_text)
  220. // 刷新
  221. const refreshing = ref(false)
  222. // 下拉刷新
  223. const onRefresh = () => {
  224. refreshing.value = true
  225. // getVisaOrderList()
  226. }
  227. // 打扰和免打扰得
  228. const noBother = (parmas) => {
  229. if (parmas?.bother == false) {
  230. parmas.bother = true
  231. } else {
  232. parmas.bother = false
  233. }
  234. }
  235. // 会话的删除
  236. const convDelete = (parmas) => {}
  237. // 消息数量通知的展示 需要动态的展示
  238. const messageNumber = (content) => {
  239. let messageNumberObj = {}
  240. if (content <= 1) {
  241. messageNumberObj = {
  242. offset: [-5, 4],
  243. dot: true,
  244. content
  245. }
  246. }
  247. if (content > 1) {
  248. messageNumberObj = {
  249. offset: [-10, 7],
  250. content
  251. }
  252. }
  253. return messageNumberObj
  254. }
  255. // 跳转聊天页面
  256. const onChatPage = (path, query) => {
  257. navigateTo({
  258. path,
  259. query
  260. })
  261. }
  262. // 选中的是那个页面
  263. const onSelect = (action) => {
  264. if (action.text == '创建群聊') onChatPage('/chat/create-group', {})
  265. if (action.text == '群聊广场') onChatPage('/chat/group-square', {})
  266. if (action.text == '加入群聊') onChatPage('/scan', {})
  267. if (action.text == '添加用户') onChatPage('/chat/user-add', {})
  268. }
  269. async function getList() {
  270. try {
  271. let {
  272. data: { dataList }
  273. } = await request('/website/tourism/fans/getTourMemberList')
  274. } catch (error) {}
  275. }
  276. onMounted(() => {
  277. getList()
  278. })
  279. </script>
  280. <style lang="scss" scoped></style>