index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <ToolbarItemContainer
  3. ref="container"
  4. :iconFile="evaluateIcon"
  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="['evaluate', !isPC && 'evaluate-h5']">
  13. <div :class="['evaluate-content-button', !isPC && 'evaluate-h5-content-button']">
  14. <button
  15. :class="['btn', isEvaluateValid ? 'btn-valid' : 'btn-invalid']"
  16. @click="submitEvaluate"
  17. >
  18. {{ TUITranslateService.t("发送手机号") }}
  19. </button>
  20. </div>
  21. </div>
  22. </ToolbarItemContainer>
  23. </template>
  24. <script setup lang="ts">
  25. import {
  26. TUITranslateService,
  27. TUIStore,
  28. StoreName,
  29. IConversationModel,
  30. TUIChatService,
  31. SendMessageParams,
  32. } from "@tencentcloud/chat-uikit-engine";
  33. import { ref, computed } from "../../../../adapter-vue";
  34. import ToolbarItemContainer from "../toolbar-item-container/index.vue";
  35. import evaluateIcon from "../../../../assets/icon/evaluate.svg";
  36. import Link from "../../../../utils/documentLink";
  37. import Icon from "../../../common/Icon.vue";
  38. import starIcon from "../../../../assets/icon/star.png";
  39. import starLightIcon from "../../../../assets/icon/star-light.png";
  40. import { CHAT_MSG_CUSTOM_TYPE } from "../../../../constant";
  41. import { isPC, isH5, isUniFrameWork } from "../../../../utils/env";
  42. import { isEnabledMessageReadReceiptGlobal } from "../../utils/utils";
  43. import { createOfflinePushInfo } from "../../utils/sendMessage";
  44. const props = defineProps({
  45. starTotal: {
  46. type: Number,
  47. default: 5,
  48. },
  49. });
  50. const emits = defineEmits(["onDialogPopupShowOrHide"]);
  51. const container = ref();
  52. const starList = ref<number>(props.starTotal);
  53. const currentStarIndex = ref<number>(-1);
  54. const comment = ref("");
  55. const currentConversation = ref<IConversationModel>();
  56. TUIStore.watch(StoreName.CONV, {
  57. currentConversation: (conversation: IConversationModel) => {
  58. currentConversation.value = conversation;
  59. },
  60. });
  61. const isEvaluateValid = computed(
  62. () => comment.value.length || currentStarIndex.value >= 0
  63. );
  64. const onDialogShow = () => {
  65. emits("onDialogPopupShowOrHide", true);
  66. };
  67. const onDialogClose = () => {
  68. resetEvaluate();
  69. emits("onDialogPopupShowOrHide", false);
  70. };
  71. const openLink = () => {
  72. if (isPC || isH5) {
  73. window.open(Link?.customMessage?.url);
  74. }
  75. };
  76. const closeDialog = () => {
  77. container?.value?.toggleDialogDisplay(false);
  78. };
  79. const resetEvaluate = () => {
  80. currentStarIndex.value = -1;
  81. comment.value = "";
  82. };
  83. const selectStar = (starIndex?: any) => {
  84. if (currentStarIndex.value === starIndex) {
  85. currentStarIndex.value = currentStarIndex.value - 1;
  86. } else {
  87. currentStarIndex.value = starIndex;
  88. }
  89. };
  90. const submitEvaluate = () => {
  91. let promise = TUIChatService.sendCustomMessage({
  92. payload: {
  93. data: JSON.stringify({
  94. businessID: "phone",
  95. title: "用户名称的手机号",
  96. iphone: "18790411793",
  97. }),
  98. description: "",
  99. extension: "",
  100. },
  101. });
  102. container?.value?.toggleDialogDisplay(false);
  103. };
  104. </script>
  105. <style scoped lang="scss" src="../../style/index.scss"></style>