index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <div class="w-full h-[100vh]">
  3. <ChatHeader :title="title" />
  4. <ChatSearch
  5. v-model:searchString="searchString"
  6. v-model:placeholder="placeholder"
  7. @search="search"
  8. />
  9. <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
  10. <div v-if="tab == 'records'" class="w-full min-h-400 pt-20">
  11. <!-- :title="`没有找到&quot;${searchString}&quot;相关的结果`" v-if="!list?.length && !loading"-->
  12. <ChatEmpty
  13. v-if="!list?.length && !loading"
  14. image="search"
  15. title="输入关键词,搜索聊天记录"
  16. />
  17. <template v-if="searchString && list?.length > 0">
  18. <van-cell
  19. clickable
  20. v-for="(item, index) in list"
  21. :key="item?.id"
  22. :value="beforeTime(item?.createTime)"
  23. >
  24. <template #icon>
  25. <div class="w-40 h-40 rounded-full mr-12 overflow-hidden">
  26. <img class="w-full h-full object-cover" :src="item?.avatar" alt="" />
  27. </div>
  28. </template>
  29. <template :title>
  30. <p class="text-sm text-black-9">
  31. {{ item?.nickname }}
  32. </p>
  33. </template>
  34. <template :label>
  35. <van-highlight
  36. :keywords="searchString"
  37. :source-string="item?.nickname"
  38. class="text-xl text-black-3"
  39. highlight-class="custom-class"
  40. />
  41. </template>
  42. </van-cell>
  43. </template>
  44. <!-- <template v-if="!searchString && list?.length">
  45. <p class="text-bsae text-center">按以下条件查找</p>
  46. <div class="w-full flex justify-center mt-15">
  47. <van-button
  48. icon="contact-o"
  49. type="primary"
  50. color="#F6F6F6"
  51. round
  52. @click=""
  53. size="small"
  54. style="color: #333333; margin-right: 10px"
  55. >
  56. 群成员
  57. </van-button>
  58. <van-button
  59. icon="notes-o"
  60. type="primary"
  61. color="#F6F6F6"
  62. color-text="#333333"
  63. size="small"
  64. round
  65. @click=""
  66. style="color: #333333"
  67. >
  68. 日期
  69. </van-button>
  70. </div>
  71. </template> -->
  72. </div>
  73. </van-pull-refresh>
  74. </div>
  75. </template>
  76. <script setup>
  77. import { beforeTime } from '~/utils/detalTime'
  78. const route = useRoute()
  79. const tab = useRouteQuery('tab')
  80. const queryParams = reactive({
  81. groupId: computed(() => route.query.groupId ?? ''),
  82. pageNum: 1,
  83. pageSize: 20,
  84. searchMessage: ''
  85. })
  86. const loading = ref(false)
  87. const refreshing = ref(false)
  88. const searchString = ref('')
  89. onMounted(() => {
  90. getList()
  91. })
  92. // 全部成员
  93. const list = ref([])
  94. const title = ref('聊天记录')
  95. // 搜索
  96. const search = () => {
  97. queryParams.searchMessage = searchString.value
  98. queryParams.pageNum = 1
  99. list.value = []
  100. getList()
  101. }
  102. // 下拉刷新
  103. const onRefresh = () => {
  104. list.value ? queryParams.pageNum++ : (queryParams.pageNum = 1)
  105. getList()
  106. }
  107. // 获取聊天记录
  108. const getList = async () => {
  109. try {
  110. loading.value = true
  111. if (tab == 'records') data.records = searchString.value
  112. let { data } = await request('/website/tourMessage/getMessageByGroupId', {
  113. query: {
  114. ...queryParams
  115. }
  116. })
  117. if (Array.isArray(data.data) && data?.data?.length) {
  118. list.value = list.value.concat(...data.data)
  119. } else {
  120. list.value = []
  121. }
  122. refreshing.value = false
  123. loading.value = false
  124. } catch (err) {
  125. } finally {
  126. refreshing.value = false
  127. loading.value = false
  128. }
  129. }
  130. // 是否是普通成员
  131. // const isRankAndFiler = (role) => {
  132. // return role == 1 || role == 2 ? true : false
  133. // }
  134. definePageMeta({
  135. layout: false
  136. })
  137. useSeoMeta({
  138. title
  139. })
  140. </script>
  141. <style lang="scss" scoped>
  142. .custom-class {
  143. color: #ff9300;
  144. }
  145. </style>