message-custom.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <div class="custom">
  3. <template v-if="isCustom.businessID === 'order'">
  4. <div class="evaluate">
  5. <div @click="product(isCustom)">
  6. <div class="left">
  7. <img
  8. :src="isCustom.imageUrl"
  9. style="width: 80px; height: 80px; border-radius: 10px"
  10. />
  11. <div class="right">
  12. <div class="label">
  13. {{ isCustom.title }}
  14. </div>
  15. <div class="label">描述:{{ isCustom.spuDesc }}</div>
  16. <div style="font-weight: 400; font-size: 28rpx">
  17. 价格:{{ isCustom.price.toFixed(2) }}元/{{ isCustom.unit }}
  18. </div>
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. </template>
  24. <template v-else>
  25. <span v-html="content.custom" />
  26. </template>
  27. </div>
  28. </template>
  29. <script lang="ts" setup>
  30. import { watchEffect, ref } from "../../../../adapter-vue";
  31. import { TUITranslateService, IMessageModel } from "@tencentcloud/chat-uikit-engine";
  32. import { isUrl, JSONToObject } from "../../../../utils/index";
  33. import { CHAT_MSG_CUSTOM_TYPE } from "../../../../constant";
  34. import { ICustomMessagePayload } from "../../../../interface";
  35. import Icon from "../../../common/Icon.vue";
  36. import star from "../../../../assets/icon/star-light.png";
  37. import * as mesApi from "@/api/message/index";
  38. interface Props {
  39. messageItem: IMessageModel;
  40. content: any;
  41. }
  42. const props = withDefaults(defineProps<Props>(), {
  43. messageItem: undefined,
  44. content: undefined,
  45. });
  46. const custom = ref();
  47. const message = ref<IMessageModel>();
  48. const extension = ref();
  49. const isCustom = ref<ICustomMessagePayload>({
  50. businessID: "",
  51. });
  52. watchEffect(() => {
  53. custom.value = props.content;
  54. message.value = props.messageItem;
  55. const { payload } = props.messageItem;
  56. isCustom.value = payload.data || "";
  57. isCustom.value = JSONToObject(payload.data);
  58. if (payload.data === CHAT_MSG_CUSTOM_TYPE.SERVICE) {
  59. extension.value = JSONToObject(payload.extension);
  60. }
  61. });
  62. const openLink = (url: any) => {
  63. window.open(url);
  64. };
  65. const product = (record) => {
  66. if (record.saleType == 2) {
  67. webUni.webView.redirectTo({
  68. url: `/subpages/home/carpoolGoods/product-details?id=` + record.id,
  69. });
  70. } else {
  71. webUni.webView.redirectTo({
  72. url: `/subpages/home/supply-hall/product-details?id=` + record.id,
  73. });
  74. }
  75. };
  76. </script>
  77. <style lang="scss" scoped>
  78. @import "../../../../assets/styles/common";
  79. .name {
  80. font-weight: bold;
  81. font-size: 16px;
  82. margin-right: 10px;
  83. }
  84. .value {
  85. font-size: 16px;
  86. margin-right: 10px;
  87. }
  88. a {
  89. color: #679ce1;
  90. }
  91. .custom {
  92. font-size: 14px;
  93. h1 {
  94. font-size: 14px;
  95. color: #000;
  96. }
  97. h1,
  98. a,
  99. p {
  100. font-size: 14px;
  101. }
  102. .evaluate {
  103. min-width: 240px;
  104. width: 240px;
  105. .left {
  106. display: flex;
  107. flex-direction: row;
  108. align-items: center;
  109. justify-content: center;
  110. background: #7a7a7d29;
  111. border-radius: 15px;
  112. padding: 15px;
  113. }
  114. .right {
  115. display: flex;
  116. flex-direction: column;
  117. align-items: flex-start;
  118. height: 75px;
  119. width: 70%;
  120. justify-content: center;
  121. line-height: 25px;
  122. margin-left: 10px;
  123. .label {
  124. font-weight: bold;
  125. font-size: 14px;
  126. width: 100px;
  127. height: auto;
  128. word-wrap: break-word;
  129. overflow: hidden;
  130. text-overflow: ellipsis;
  131. white-space: nowrap;
  132. }
  133. }
  134. ul {
  135. display: flex;
  136. padding: 10px 0;
  137. }
  138. &-list {
  139. display: flex;
  140. flex-direction: row;
  141. &-item {
  142. padding: 0 2px;
  143. }
  144. }
  145. }
  146. .order {
  147. display: flex;
  148. main {
  149. padding-left: 5px;
  150. p {
  151. font-family: PingFangSC-Regular;
  152. width: 145px;
  153. line-height: 17px;
  154. font-size: 14px;
  155. color: #999;
  156. letter-spacing: 0;
  157. margin-bottom: 6px;
  158. word-break: break-word;
  159. }
  160. span {
  161. font-family: PingFangSC-Regular;
  162. line-height: 25px;
  163. color: #ff7201;
  164. }
  165. }
  166. img {
  167. width: 67px;
  168. height: 67px;
  169. }
  170. }
  171. }
  172. </style>