SearchMediaRow.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <view class="search_data_row">
  3. <text class="row_title">{{ getTitle }}</text>
  4. <u-row gutter="12" customStyle="flex-wrap:wrap;">
  5. <u-col v-for="item in source" :key="item.clientMsgID" span="3">
  6. <u--image
  7. height="94"
  8. width="100%"
  9. :showLoading="true"
  10. :src="getSrc(item)"
  11. @click="clickItem(item)"
  12. ></u--image>
  13. <image
  14. v-if="isVideo"
  15. class="play_icon"
  16. src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/chating_message_video_play.png"
  17. alt=""
  18. srcset=""
  19. @click.stop="clickItem(item)"
  20. />
  21. </u-col>
  22. </u-row>
  23. </view>
  24. </template>
  25. <script>
  26. import { myPreview } from "../../../../util/preview";
  27. export default {
  28. name: "",
  29. components: {},
  30. props: {
  31. source: Array,
  32. idx: Number,
  33. isVideo: Boolean,
  34. },
  35. data() {
  36. return {};
  37. },
  38. computed: {
  39. getTitle() {
  40. switch (this.idx) {
  41. case 0:
  42. return "本周";
  43. case 1:
  44. return "本月";
  45. case 2:
  46. return "更久";
  47. default:
  48. return "更久";
  49. }
  50. },
  51. getSrc() {
  52. return (message) => {
  53. if (this.isVideo) {
  54. return message.videoElem.snapshotUrl;
  55. }
  56. return message.pictureElem.sourcePicture.url;
  57. };
  58. },
  59. },
  60. methods: {
  61. clickItem(message) {
  62. if (this.isVideo) {
  63. uni.navigateTo({
  64. url: `/pages/conversation/previewVideo/index?previewVideoUrl=${message.videoElem.videoUrl}&snapshotUrl=${message.videoElem.snapshotUrl}`,
  65. });
  66. } else {
  67. const list = this.source.map(
  68. (message) => message.pictureElem.sourcePicture.url,
  69. );
  70. const idx = list.findIndex((item) => item === this.getSrc(message));
  71. // uni.previewImage({
  72. // current: idx,
  73. // urls: list,
  74. // fail(err) {
  75. // console.log(err);
  76. // },
  77. // });
  78. myPreview(idx, list)
  79. }
  80. },
  81. },
  82. };
  83. </script>
  84. <style lang="scss" scoped>
  85. .search_data_row {
  86. margin-top: 12rpx;
  87. .row_title {
  88. margin-left: 44rpx;
  89. margin-bottom: 12rpx;
  90. color: #666;
  91. }
  92. .u-row {
  93. margin-top: 16rpx;
  94. }
  95. .u-col {
  96. margin-bottom: 24rpx;
  97. position: relative;
  98. .play_icon {
  99. width: 24px;
  100. height: 24px;
  101. position: absolute;
  102. top: 50%;
  103. left: 50%;
  104. transform: translate(-50%, -50%);
  105. }
  106. }
  107. }
  108. </style>