index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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-header', !isPC && 'evaluate-h5-header']">
  14. <div :class="['evaluate-header-content', !isPC && 'evaluate-h5-header-content']">
  15. {{ TUITranslateService.t("发送面试邀请") }}
  16. </div>
  17. <div
  18. v-if="!isPC"
  19. :class="['evaluate-header-close', !isPC && 'evaluate-h5-header-close']"
  20. @click.stop="closeDialog"
  21. >
  22. {{ TUITranslateService.t("关闭") }}
  23. </div>
  24. </div>
  25. <div :class="['evaluate-content', !isPC && 'evaluate-h5-content']">
  26. <picker
  27. class="picker"
  28. style="
  29. height: 40px;
  30. width: 94%;
  31. background: #f8f8f8;
  32. text-align: left;
  33. line-height: 39px;
  34. padding: 0px 11px;
  35. "
  36. mode="date"
  37. :value="date"
  38. @change="bindDateChange"
  39. >
  40. <view class="uni-input">{{ date ? date : "请选择面试时间" }}</view>
  41. </picker>
  42. <textarea
  43. v-model="comment"
  44. placeholder="请输入面试地址"
  45. :class="['evaluate-content-text', !isPC && 'evaluate-h5-content-text']"
  46. />
  47. <input
  48. style="
  49. height: 40px;
  50. width: 94%;
  51. background: #f8f8f8;
  52. text-align: left;
  53. line-height: 39px;
  54. padding: 0px 11px;
  55. margin-bottom: 20px;
  56. "
  57. @input="replaceInput"
  58. :value="inpvalue"
  59. focus
  60. placeholder="联系电话"
  61. />
  62. <div :class="['evaluate-content-button', !isPC && 'evaluate-h5-content-button']">
  63. <button
  64. :class="['btn', isEvaluateValid ? 'btn-valid' : 'btn-invalid']"
  65. @click="submitEvaluate"
  66. >
  67. {{ TUITranslateService.t("发送邀请") }}
  68. </button>
  69. </div>
  70. </div>
  71. </div>
  72. </ToolbarItemContainer>
  73. </template>
  74. <script setup lang="ts">
  75. import {
  76. TUITranslateService,
  77. TUIStore,
  78. StoreName,
  79. IConversationModel,
  80. TUIChatService,
  81. SendMessageParams,
  82. } from "@tencentcloud/chat-uikit-engine";
  83. import { ref, computed } from "../../../../adapter-vue";
  84. import ToolbarItemContainer from "../toolbar-item-container/index.vue";
  85. import evaluateIcon from "../../../../assets/icon/evaluate.svg";
  86. import Link from "../../../../utils/documentLink";
  87. import Icon from "../../../common/Icon.vue";
  88. import starIcon from "../../../../assets/icon/star.png";
  89. import starLightIcon from "../../../../assets/icon/star-light.png";
  90. import { CHAT_MSG_CUSTOM_TYPE } from "../../../../constant";
  91. import { isPC, isH5, isUniFrameWork } from "../../../../utils/env";
  92. import { isEnabledMessageReadReceiptGlobal } from "../../utils/utils";
  93. import { createOfflinePushInfo } from "../../utils/sendMessage";
  94. const date = ref("");
  95. const inpvalue = ref("");
  96. const props = defineProps({
  97. starTotal: {
  98. type: Number,
  99. default: 5,
  100. },
  101. });
  102. const emits = defineEmits(["onDialogPopupShowOrHide"]);
  103. const container = ref();
  104. const starList = ref<number>(props.starTotal);
  105. const currentStarIndex = ref<number>(-1);
  106. const comment = ref("");
  107. const currentConversation = ref<IConversationModel>();
  108. TUIStore.watch(StoreName.CONV, {
  109. currentConversation: (conversation: IConversationModel) => {
  110. currentConversation.value = conversation;
  111. },
  112. });
  113. const isEvaluateValid = computed(
  114. () => comment.value.length || currentStarIndex.value >= 0
  115. );
  116. const bindDateChange = (e) => {
  117. date.value = e.detail.value;
  118. };
  119. const replaceInput = (e) => {
  120. inpvalue.value = e.detail.value;
  121. };
  122. const onDialogShow = () => {
  123. emits("onDialogPopupShowOrHide", true);
  124. };
  125. const onDialogClose = () => {
  126. resetEvaluate();
  127. emits("onDialogPopupShowOrHide", false);
  128. };
  129. const openLink = () => {
  130. if (isPC || isH5) {
  131. window.open(Link?.customMessage?.url);
  132. }
  133. };
  134. const closeDialog = () => {
  135. container?.value?.toggleDialogDisplay(false);
  136. };
  137. const resetEvaluate = () => {
  138. currentStarIndex.value = -1;
  139. comment.value = "";
  140. };
  141. const selectStar = (starIndex?: any) => {
  142. if (currentStarIndex.value === starIndex) {
  143. currentStarIndex.value = currentStarIndex.value - 1;
  144. } else {
  145. currentStarIndex.value = starIndex;
  146. }
  147. };
  148. const submitEvaluate = () => {
  149. // 评价消息,星星数和文本必须有一个才可以提交
  150. if (currentStarIndex.value < 0 && !comment.value.length) {
  151. return;
  152. }
  153. let promise = TUIChatService.sendCustomMessage({
  154. payload: {
  155. data: JSON.stringify({
  156. // 订单类消息标识字段
  157. businessID: "order",
  158. // 订单标题
  159. companyname: "云赋能网络信息有限公司",
  160. interviewtime: date.value, //面试时间
  161. Interviewlocation: comment.value, //面试地点
  162. iphone: inpvalue.value, //联系方式
  163. name: "王希望", //联系人
  164. imageUrl:
  165. "https://qcloudimg.tencent-cloud.cn/trisys/assets/product/images/SOOZNXCHkHcm50wX2ndp4.png",
  166. }),
  167. description: "",
  168. extension: "",
  169. },
  170. });
  171. // const options = {
  172. // to:
  173. // currentConversation?.value?.groupProfile?.groupID
  174. // || currentConversation?.value?.userProfile?.userID,
  175. // conversationType: currentConversation?.value?.type,
  176. // payload: {
  177. // data: JSON.stringify({
  178. // businessID: CHAT_MSG_CUSTOM_TYPE.EVALUATE,
  179. // version: 1,
  180. // score: currentStarIndex.value + 1,
  181. // comment: comment.value,
  182. // }),
  183. // description: '对本次的服务评价',
  184. // extension: '对本次的服务评价',
  185. // },
  186. // needReadReceipt: isEnabledMessageReadReceiptGlobal(),
  187. // };
  188. // const sendMessageOptions: any = {
  189. // offlinePushInfo: createOfflinePushInfo(currentConversation),
  190. // };
  191. // TUIChatService.sendCustomMessage(options as SendMessageParams, sendMessageOptions);
  192. // 提交后关闭 dialog
  193. // close dialog after submit evaluate
  194. container?.value?.toggleDialogDisplay(false);
  195. };
  196. </script>
  197. <style scoped lang="scss" src="./style/index.scss"></style>