index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <ToolbarItemContainer
  3. ref="container"
  4. :iconFile="wordsIcon"
  5. title="常用语"
  6. :needBottomPopup="true"
  7. :iconWidth="isUniFrameWork ? '26px' : '20px'"
  8. :iconHeight="isUniFrameWork ? '26px' : '20px'"
  9. @onDialogShow="onDialogShow"
  10. @onDialogClose="onDialogClose"
  11. >
  12. <div :class="['words', !isPC && 'words-h5']">
  13. <div :class="['words-header', !isPC && 'words-h5-header']">
  14. <span :class="['words-header-title', !isPC && 'words-h5-header-title']">
  15. {{ TUITranslateService.t("Words.常用语-快捷回复工具") }}
  16. </span>
  17. <span
  18. v-if="!isPC"
  19. :class="['words-header-close', !isPC && 'words-h5-header-close']"
  20. @click="closeDialog"
  21. >
  22. 关闭
  23. </span>
  24. </div>
  25. <ul :class="['words-list', !isPC && 'words-h5-list']">
  26. <li
  27. v-for="(item, index) in wordsList"
  28. :key="index"
  29. :class="['words-list-item', !isPC && 'words-h5-list-item']"
  30. @click="selectWord(item)"
  31. >
  32. {{ TUITranslateService.t(`Words.${item.value}`) }}
  33. </li>
  34. </ul>
  35. </div>
  36. </ToolbarItemContainer>
  37. </template>
  38. <script setup lang="ts">
  39. import {
  40. TUITranslateService,
  41. TUIStore,
  42. StoreName,
  43. IConversationModel,
  44. SendMessageParams,
  45. TUIChatService,
  46. } from '@tencentcloud/chat-uikit-engine';
  47. import { ref } from '../../../../adapter-vue';
  48. import ToolbarItemContainer from '../toolbar-item-container/index.vue';
  49. import wordsIcon from '../../../../assets/icon/words.svg';
  50. import { wordsList } from '../../utils/wordsList';
  51. import { isEnabledMessageReadReceiptGlobal } from '../../utils/utils';
  52. import { isPC, isUniFrameWork } from '../../../../utils/env';
  53. const emits = defineEmits(['onDialogPopupShowOrHide']);
  54. const currentConversation = ref<IConversationModel>();
  55. const container = ref();
  56. TUIStore.watch(StoreName.CONV, {
  57. currentConversation: (conversation: IConversationModel) => {
  58. currentConversation.value = conversation;
  59. },
  60. });
  61. const selectWord = (item: any) => {
  62. const options = {
  63. to:
  64. currentConversation?.value?.groupProfile?.groupID
  65. || currentConversation?.value?.userProfile?.userID,
  66. conversationType: currentConversation?.value?.type,
  67. payload: {
  68. text: TUITranslateService.t(`Words.${item.value}`),
  69. },
  70. needReadReceipt: isEnabledMessageReadReceiptGlobal(),
  71. } as SendMessageParams;
  72. TUIChatService.sendTextMessage(options);
  73. // close dialog after submit evaluate
  74. container?.value?.toggleDialogDisplay(false);
  75. };
  76. const closeDialog = () => {
  77. container?.value?.toggleDialogDisplay(false);
  78. };
  79. const onDialogShow = () => {
  80. emits('onDialogPopupShowOrHide', true);
  81. };
  82. const onDialogClose = () => {
  83. emits('onDialogPopupShowOrHide', false);
  84. };
  85. </script>
  86. <style scoped lang="scss" src="./style/index.scss"></style>