message-custom.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <div class="custom">
  3. <template v-if="isCustom === constant.typeService">
  4. <div>
  5. <h1>
  6. <label>{{ extension.title }}</label>
  7. <a
  8. v-if="extension.hyperlinks_text"
  9. :href="extension.hyperlinks_text.value"
  10. target="view_window"
  11. >
  12. {{ extension.hyperlinks_text.key }}
  13. </a>
  14. </h1>
  15. <ul v-if="extension.item && extension.item.length > 0">
  16. <li v-for="(item, index) in extension.item" :key="index">
  17. <a v-if="isUrl(item.value)" :href="item.value" target="view_window">
  18. {{ item.key }}
  19. </a>
  20. <p v-else>{{ item.key }}</p>
  21. </li>
  22. </ul>
  23. <article>{{ extension.description }}</article>
  24. </div>
  25. </template>
  26. <template v-else-if="isCustom.businessID === constant.typeEvaluate">
  27. <div class="evaluate">
  28. <h1>{{ $t('message.custom.对本次服务评价') }}</h1>
  29. <ul>
  30. <li
  31. class="evaluate-list-item"
  32. v-for="(item, index) in ~~isCustom.score"
  33. :key="index"
  34. >
  35. <i class="icon icon-star-light"></i>
  36. </li>
  37. </ul>
  38. <article>{{ isCustom.comment }}</article>
  39. </div>
  40. </template>
  41. <template v-else-if="isCustom.businessID === constant.typeOrder">
  42. <div class="order" @click="openLink(isCustom.link)">
  43. <img :src="isCustom.imageUrl" alt="" />
  44. <main>
  45. <h1>{{ isCustom.title }}</h1>
  46. <p>{{ isCustom.description }}</p>
  47. <span>{{ isCustom.price }}</span>
  48. </main>
  49. </div>
  50. </template>
  51. <template v-else-if="isCustom.businessID === constant.typeTextLink">
  52. <div class="textLink">
  53. <p>{{ isCustom.text }}</p>
  54. <a :href="isCustom.link" target="view_window">
  55. {{ $t('message.custom.查看详情>>') }}
  56. </a>
  57. </div>
  58. </template>
  59. <template v-else-if="isCustom.businessID === constant.TYPE_CALL_MESSAGE">
  60. <div
  61. class="call"
  62. @click="handleCallAgain"
  63. :class="`call-${data?.message?.conversationType}`"
  64. >
  65. <i class="icon" :class="handleCallMessageIcon()"></i>
  66. <span>{{ data.custom }}</span>
  67. </div>
  68. </template>
  69. <template v-else-if="isCustom.businessID === constant.TC_GROUP_NOTICE">
  70. <div class="notice-message" @click="handleNotice">
  71. <div class="notice-title">
  72. <i class="iconNotice"></i>
  73. <span>群公告</span>
  74. </div>
  75. <div class="content">
  76. <div class="content-title">
  77. {{isCustom.msgTitle}}
  78. </div>
  79. <div class="content-text">{{isCustom.msgContent}}</div>
  80. </div>
  81. </div>
  82. </template>
  83. <template v-else>
  84. <span v-html="data.custom"></span>
  85. </template>
  86. </div>
  87. </template>
  88. <script lang="ts">
  89. import { defineComponent, watchEffect, reactive, toRefs } from 'vue';
  90. import { isUrl, JSONToObject } from '../utils/utils';
  91. import constant from '../../constant';
  92. import { useStore } from 'vuex';
  93. import { eventGlobal } from "@/helpers";
  94. import TUIMessage from "../../../components/messageTUI/index";
  95. import { imGroupNoticeDetail } from "../../../../api";
  96. export default defineComponent({
  97. props: {
  98. data: {
  99. type: Object,
  100. default: () => ({})
  101. }
  102. },
  103. setup(props: any, ctx: any) {
  104. const VuexStore =
  105. ((window as any)?.TUIKitTUICore?.isOfficial && useStore && useStore()) ||
  106. {};
  107. const data = reactive({
  108. data: {} as any,
  109. extension: {},
  110. isCustom: '',
  111. constant: constant
  112. });
  113. watchEffect(() => {
  114. data.data = props.data;
  115. const {
  116. message: { payload }
  117. } = props.data;
  118. data.isCustom = payload.data || ' ';
  119. data.isCustom = JSONToObject(payload.data);
  120. if (payload.data === constant.typeService) {
  121. data.extension = JSONToObject(payload.extension);
  122. }
  123. });
  124. const openLink = (url: any) => {
  125. window.open(url);
  126. };
  127. const handleCallMessageIcon = () => {
  128. const callType = JSON.parse(
  129. JSON.parse(data?.data?.message?.payload?.data)?.data
  130. )?.call_type;
  131. let className = '';
  132. switch (callType) {
  133. case 1:
  134. className = 'icon-call-voice';
  135. break;
  136. case 2:
  137. className = 'icon-call-video';
  138. break;
  139. default:
  140. break;
  141. }
  142. return className;
  143. };
  144. const handleCallAgain = async () => {
  145. const callType = JSON.parse(
  146. JSON.parse(props?.data?.message?.payload?.data)?.data
  147. )?.call_type;
  148. switch (data?.data?.message?.conversationType) {
  149. case (window as any).TUIKitTUICore.TIM.TYPES.CONV_C2C:
  150. // eslint-disable-next-line no-case-declarations, no-unsafe-optional-chaining
  151. const { flow, to, from } = data?.data?.message;
  152. if (to === from) break;
  153. try {
  154. await (window as any)?.TUIKitTUICore?.TUIServer?.TUICallKit?.call({
  155. userID: flow === 'out' ? to : from,
  156. type: callType
  157. });
  158. (window as any)?.TUIKitTUICore?.isOfficial &&
  159. VuexStore?.commit &&
  160. VuexStore?.commit('handleTask', 6);
  161. } catch (error) {
  162. console.warn(error);
  163. }
  164. break;
  165. case (window as any).TUIKitTUICore.TIM.TYPES.CONV_GROUP:
  166. break;
  167. default:
  168. break;
  169. }
  170. };
  171. const handleNotice = async () => {
  172. console.log(data.isCustom, 'data.isCustom')
  173. if(!data.isCustom?.msgId) return
  174. try {
  175. await imGroupNoticeDetail(data.isCustom?.msgId)
  176. eventGlobal.emit('handleNotice', data.isCustom?.msgId)
  177. } catch(e) {
  178. //
  179. TUIMessage({
  180. message: e.message,
  181. isH5: false,
  182. type: "error",
  183. });
  184. }
  185. }
  186. return {
  187. ...toRefs(data),
  188. isUrl,
  189. openLink,
  190. handleCallMessageIcon,
  191. handleNotice,
  192. handleCallAgain
  193. };
  194. }
  195. });
  196. </script>
  197. <style lang="scss" scoped>
  198. @import url('../../../styles/common.scss');
  199. @import url('../../../styles/icon.scss');
  200. a {
  201. color: #679ce1;
  202. }
  203. .custom {
  204. font-size: 14Px;
  205. h1 {
  206. font-size: 14Px;
  207. color: #000000;
  208. }
  209. h1,
  210. a,
  211. p {
  212. font-size: 14Px;
  213. }
  214. .evaluate {
  215. ul {
  216. display: flex;
  217. padding-top: 10Px;
  218. }
  219. }
  220. .order {
  221. display: flex;
  222. main {
  223. padding-left: 5Px;
  224. p {
  225. font-family: PingFangSC-Regular;
  226. width: 145Px;
  227. line-height: 17Px;
  228. font-size: 14Px;
  229. color: #999999;
  230. letter-spacing: 0;
  231. margin-bottom: 6Px;
  232. word-break: break-word;
  233. }
  234. span {
  235. font-family: PingFangSC-Regular;
  236. line-height: 25Px;
  237. color: #ff7201;
  238. }
  239. }
  240. img {
  241. width: 67Px;
  242. height: 67Px;
  243. }
  244. }
  245. .call {
  246. display: flex;
  247. flex-direction: row;
  248. align-items: center;
  249. &-C2C {
  250. cursor: pointer;
  251. }
  252. &-GROUP {
  253. cursor: default;
  254. }
  255. }
  256. .notice-message {
  257. max-width: 376px;
  258. cursor: pointer;
  259. .notice-title {
  260. display: flex;
  261. align-items: center;
  262. padding-bottom: 6px;
  263. span {
  264. font-weight: 600;
  265. font-size: 16px;
  266. color: #198CFE;
  267. line-height: 24px;
  268. }
  269. .iconNotice {
  270. width: 18px;
  271. height: 18px;
  272. display: inline-block;
  273. margin-right: 6px;
  274. }
  275. }
  276. .content {
  277. font-size: 16px;
  278. color: #131415;
  279. line-height: 24px;
  280. .content-title {
  281. font-weight: 600;
  282. }
  283. }
  284. }
  285. }
  286. </style>