set-single.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <div class="w-full h-[100vh] bg-[#F7F8FA]">
  3. <ChatHeaderBar title="聊天设置" />
  4. <div class="h-66"></div>
  5. <van-cell-group
  6. style="margin-bottom: 12px; padding-top: 12px; padding-left: 16px"
  7. class="box-border"
  8. inset
  9. >
  10. <van-row>
  11. <van-col style="width: 54px" span="4" class="mb-12 mr-10">
  12. <div class="w-40 h-40 rounded-full mx-auto overflow-hidden mb-4">
  13. <img class="w-full h-full object-cover" :src="itemData?.avatar" alt="" />
  14. </div>
  15. <p class="w-full line-clamp-1 lin text-sm text-center text-black-6">
  16. {{ itemData?.nickname }}
  17. </p>
  18. </van-col>
  19. <van-col style="width: 54px" span="4" class="mb-12 mr-10">
  20. <div
  21. @click="navigateTo('/chat/single-add')"
  22. class="w-40 h-40 flex justify-center items-center bg-[#F3F3F3] rounded-full mx-auto overflow-hidden mb-4"
  23. >
  24. <span class="iconfont icon-plus text-black-6" style="font-size: 24px"></span>
  25. </div>
  26. <p class="w-full line-clamp-1 lin text-sm text-center text-black-6">多人聊天</p>
  27. </van-col>
  28. </van-row>
  29. </van-cell-group>
  30. <van-cell-group style="margin-bottom: 12px" class="box-border" inset>
  31. <van-cell
  32. v-for="(item, index) in list"
  33. :key="index"
  34. size="large"
  35. :title="item.title"
  36. :is-link="item.isLink"
  37. @click="item.fn"
  38. >
  39. <template #icon>
  40. <span
  41. :class="`iconfont ${item.icon} text-[#FF9300] mr-12`"
  42. style="font-size: 24px"
  43. ></span>
  44. </template>
  45. <template v-if="item.vModel != null" #right-icon>
  46. <van-switch v-model="item.vModel" active-color="#FF9300" inactive-color="#dcdee0" />
  47. </template>
  48. </van-cell>
  49. </van-cell-group>
  50. <ChatDialog
  51. v-model:show="dialogParmas.show"
  52. v-model:title="dialogParmas.title"
  53. v-model:confirmText="dialogParmas.confirmText"
  54. v-model:cancelText="dialogParmas.cancelText"
  55. @confirm="confirm"
  56. @cancel="cancel"
  57. >
  58. <div class="w-full px-12 text-center mt-4">
  59. <p class="mx-auto w-[80%] text-sm text-black-9 mb-16">{{ dialogParmas.subTitle }}</p>
  60. <van-field
  61. class=""
  62. style="height: 40px; background: #f5f5f5; border-radius: 8px; margin-bottom: 30px"
  63. clearable
  64. :placeholder="dialogParmas.placeholder"
  65. v-model="dialogParmas.remark"
  66. maxlength="12"
  67. />
  68. </div>
  69. </ChatDialog>
  70. </div>
  71. </template>
  72. <script setup>
  73. definePageMeta({
  74. layout: false
  75. })
  76. const itemData = ref(null)
  77. const isNotDisturb = ref(false)
  78. const isTop = ref(false)
  79. const dialogParmas = reactive({
  80. show: false,
  81. title: '',
  82. placeholder: '',
  83. remark: '',
  84. subTitle: ''
  85. })
  86. // 弹窗确认的事件
  87. const confirm = async () => {
  88. try {
  89. let { data } = await request('', {})
  90. } catch (error) {}
  91. dialogParmas.show = false
  92. itemData.value.remark = dialogParmas.remark
  93. }
  94. const cancel = () => {
  95. dialogParmas.show = false
  96. }
  97. // 修改备注名
  98. const modifyNoteName = () => {
  99. dialogParmas.show = true
  100. dialogParmas.subTitle = '备注不得超过30个字'
  101. dialogParmas.placeholder = '请输入备注'
  102. if (itemData.value?.remark != '') {
  103. dialogParmas.title = '修改备注'
  104. dialogParmas.confirmText = '确认'
  105. dialogParmas.cancelText = '取消'
  106. } else {
  107. dialogParmas.title = '添加备注'
  108. dialogParmas.confirmText = '添加'
  109. dialogParmas.cancelText = '拒绝'
  110. }
  111. }
  112. // 查找聊天记录
  113. const findChatHistory = () => {
  114. navigateTo('/chat/set-sub', {
  115. query: {
  116. objectType: 1,
  117. userId: itemData.value?.userId
  118. }
  119. })
  120. }
  121. // 消息免打扰
  122. const notDisturb = () => {}
  123. // 置顶聊天
  124. const topChat = () => {}
  125. // 举报该用户
  126. const reportUser = () => {
  127. navigateTo('/chat/report', {
  128. query: {
  129. objectType: 1,
  130. userId: itemData.value?.userId
  131. }
  132. })
  133. }
  134. // 清空聊天记录
  135. const clearChatHistory = () => {
  136. showConfirmDialog({
  137. width: 260,
  138. // title: '提示',
  139. message: '清空聊天记录',
  140. confirmButtonColor: '#FF9300'
  141. })
  142. .then(async () => {
  143. const { data } = await request('/tourMessage/clearGroupMessage', {
  144. query: {
  145. groupId: itemData.value?.groupId
  146. }
  147. })
  148. if (data) return
  149. })
  150. .catch(() => {})
  151. }
  152. const list = reactive([
  153. {
  154. title: '设置备注名',
  155. // icon: setting,
  156. icon: 'icon-setting-one',
  157. isLink: true,
  158. vModel: null,
  159. fn: modifyNoteName,
  160. value: ''
  161. },
  162. {
  163. title: '查找聊天记录',
  164. value: '',
  165. icon: 'icon-log',
  166. isLink: true,
  167. vModel: null,
  168. fn: findChatHistory
  169. },
  170. {
  171. title: '消息面打扰',
  172. value: '',
  173. icon: 'icon-close-remind',
  174. isLink: false,
  175. vModel: isNotDisturb.value,
  176. fn: notDisturb
  177. },
  178. {
  179. title: '置顶聊天',
  180. value: '',
  181. icon: 'icon-set-top',
  182. isLink: false,
  183. vModel: isTop.value,
  184. fn: topChat
  185. },
  186. {
  187. title: '举报该用户',
  188. value: '',
  189. icon: 'icon-jubaoguanli',
  190. isLink: true,
  191. vModel: null,
  192. fn: reportUser
  193. },
  194. {
  195. title: '清空聊天记录',
  196. value: '',
  197. icon: 'icon-delete-one',
  198. isLink: true,
  199. vModel: null,
  200. fn: clearChatHistory
  201. }
  202. ])
  203. useSeoMeta({
  204. title: '我的消息'
  205. })
  206. </script>
  207. <style lang="scss" scoped></style>