index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <view class="page_container">
  3. <view class="search_bar_wrap">
  4. <img
  5. @click="back"
  6. class="back_icon"
  7. width="12"
  8. height="20"
  9. src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/common_left_arrow.png"
  10. alt=""
  11. srcset=""
  12. />
  13. <u-search
  14. shape="square"
  15. placeholder="搜索"
  16. v-model="keyword"
  17. :showAction="false"
  18. />
  19. </view>
  20. <view class="content">
  21. <view @click="clickItem" class="result_item">
  22. <view class="wrap">
  23. <my-avatar
  24. :src="chatData.faceURL"
  25. :desc="chatData.showName"
  26. :isGroup="chatData.conversationType === 3"
  27. size="42"
  28. />
  29. <view class="result_item_details">
  30. <view class="title">{{ chatData.showName }}</view>
  31. <image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/common_right.png"></image>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="content">
  37. <u-list class="generic_list">
  38. <u-list-item
  39. v-for="item in chatData.messageList"
  40. :key="item.clientMsgID"
  41. >
  42. <global-result-item
  43. isPreview
  44. :item="item"
  45. @click="jumpToMessage(item)"
  46. />
  47. </u-list-item>
  48. </u-list>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import { mapGetters } from "vuex";
  54. import GlobalResultItem from "../globalSearch/components/GlobalResultItem.vue";
  55. import MyAvatar from "../../../components/MyAvatar/index.vue";
  56. export default {
  57. name: "",
  58. components: {
  59. GlobalResultItem,
  60. MyAvatar,
  61. },
  62. data() {
  63. return {
  64. chatData: {},
  65. keyword: "",
  66. };
  67. },
  68. computed: {
  69. ...mapGetters(["storeSelfInfo"]),
  70. },
  71. onLoad(options) {
  72. if (options.chatData) {
  73. this.chatData = JSON.parse(decodeURIComponent(options.chatData));
  74. }
  75. },
  76. methods: {
  77. clickItem() {
  78. if (this.chatData.conversationType === 3) {
  79. uni.$u.route("/pages/common/groupCard/index", {
  80. sourceID: this.chatData.groupID,
  81. });
  82. return;
  83. }
  84. if (this.chatData.conversationType === 1) {
  85. const ids = this.chatData.conversationID.split("_");
  86. console.log(ids, this.storeSelfInfo.userID);
  87. const id = ids[1] === this.storeSelfInfo.userID ? ids[2] : ids[1];
  88. uni.$u.route("/pages/common/userCard/index", {
  89. sourceID: id,
  90. });
  91. return;
  92. }
  93. },
  94. back() {
  95. uni.navigateBack();
  96. },
  97. jumpToMessage(message) {
  98. uni.$u.route("/pages/common/previewHistoryMessage/index", {
  99. conversationData: JSON.stringify({
  100. ...this.chatData,
  101. messageList: undefined,
  102. }),
  103. jumpMessage: JSON.stringify(message),
  104. });
  105. },
  106. },
  107. };
  108. </script>
  109. <style lang="scss" scoped>
  110. .page_container {
  111. background-color: #f8f8f8;
  112. overflow-x: hidden;
  113. margin-top: var(--status-bar-height);
  114. .search_bar_wrap {
  115. display: flex;
  116. flex-direction: row;
  117. justify-content: center;
  118. align-items: center;
  119. height: 68rpx;
  120. padding: 24rpx 44rpx;
  121. background-color: #fff;
  122. .back_icon {
  123. margin-right: 26rpx;
  124. }
  125. }
  126. .content {
  127. margin: 26rpx 26rpx 0;
  128. .result_item {
  129. display: flex;
  130. padding: 24rpx 36rpx;
  131. color: $uni-text-color;
  132. position: relative;
  133. background-color: #fff;
  134. .wrap {
  135. @include vCenterBox();
  136. flex: 1;
  137. overflow: hidden;
  138. }
  139. &_details {
  140. display: flex;
  141. flex: 1;
  142. flex-direction: row;
  143. align-items: center;
  144. justify-content: space-between;
  145. margin-left: 20rpx;
  146. overflow: hidden;
  147. .title {
  148. color: $uni-text-color;
  149. }
  150. image {
  151. width: 18px;
  152. height: 18px;
  153. }
  154. }
  155. }
  156. .generic_list {
  157. flex: 1;
  158. }
  159. }
  160. }
  161. </style>