message-product-card.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <div
  3. class="message-product-card"
  4. @click="jumpProductCard"
  5. >
  6. <image
  7. v-if="isApp"
  8. class="product-img"
  9. :src="props.payload.content.pic"
  10. />
  11. <img
  12. v-else
  13. class="product-img"
  14. :src="props.payload.content.pic"
  15. >
  16. <div class="product-card-information">
  17. <div class="product-card-title">
  18. {{ props.payload.content.header }}
  19. </div>
  20. <div class="product-card-description">
  21. {{ props.payload.content.desc }}
  22. </div>
  23. </div>
  24. </div>
  25. </template>
  26. <script lang="ts">
  27. import { customerServicePayloadType } from '../interface';
  28. import { isApp } from '../utils/env';
  29. // eslint-disable-next-line
  30. declare var uni: any;
  31. interface Props {
  32. payload: customerServicePayloadType;
  33. }
  34. export default {
  35. props: {
  36. payload: {
  37. type: Object as () => customerServicePayloadType,
  38. default: () => ({}),
  39. },
  40. },
  41. emits: ['sendMessage'],
  42. setup(props: Props) {
  43. const jumpProductCard = () => {
  44. if (window) {
  45. window.open(props.payload.content.url, '_blank');
  46. } else {
  47. uni && uni.navigateTo({ url: `/TUIKit/components/TUIChat/web-view?url=${props.payload.content.url}` });
  48. }
  49. };
  50. return {
  51. props,
  52. isApp,
  53. jumpProductCard,
  54. };
  55. },
  56. };
  57. </script>
  58. <style lang="scss" scoped>
  59. .message-product-card {
  60. min-width: 224px;
  61. max-width: 288px;
  62. background: #fff;
  63. border: 1px solid #ddd;
  64. display: flex;
  65. padding: 12px;
  66. border-radius: 5px;
  67. .product-img {
  68. width: 86px;
  69. height: 86px;
  70. }
  71. .product-card-information {
  72. margin-left: 12px;
  73. display: flex;
  74. flex-direction: column;
  75. justify-content: space-between;
  76. .product-card-title {
  77. font-size: 12px;
  78. max-width: 165px;
  79. display: -webkit-box;
  80. overflow: hidden;
  81. text-overflow: ellipsis;
  82. -webkit-line-clamp: 3;
  83. -webkit-box-orient: vertical;
  84. word-break: break-all;
  85. }
  86. .product-card-description {
  87. font-size: 16px;
  88. max-width: 165px;
  89. color: #ff6c2e;
  90. overflow: hidden;
  91. text-overflow: ellipsis;
  92. white-space: nowrap;
  93. }
  94. }
  95. }
  96. </style>