message.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view class="message">
  3. <pinapp-empty-page title="暂无消息" v-if="chatList.length === 0"></pinapp-empty-page>
  4. <view class="message-list" v-else>
  5. <!-- 消息提示 -->
  6. <view class="message-item" v-for="(item,index) in chatList" :key="index"
  7. @click="$navigateTo('/pages/chat/chat?userId='+item.conversationId+'&userName='+item.userInfo.nickname)">
  8. <image :src="item.userInfo.avatarUrl" class="message-image" mode="aspectFill">
  9. </image>
  10. <view class="message-content">
  11. <view class="message-title">{{item.userInfo.nickname}}</view>
  12. <view class="message-sub-content">
  13. {{item.lastMessage.type === 'image'?'[图片]':item.lastMessage.body.text}}
  14. </view>
  15. </view>
  16. <view class="message-date">
  17. <uni-dateformat class="visitor-time" :date="item.updatedAt" :threshold="[60000,3600000 * 24 * 365]">
  18. </uni-dateformat>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import {
  26. YeIMUniSDK,
  27. YeIMUniSDKDefines
  28. } from '@/uni_modules/wzJun1-YeIM-Uni-SDK/js_sdk/yeim-uni-sdk.min.js'
  29. import pinappEmptyPage from "@/components/pinapp-empty-page/pinapp-empty-page.vue"
  30. export default {
  31. data() {
  32. return {
  33. chatList: []
  34. }
  35. },
  36. onLoad() {
  37. this.$chat.getConversationList(res => {
  38. if (res.code == 200) {
  39. this.chatList = res.data;
  40. }
  41. })
  42. },
  43. onShow() {
  44. uni.$on('changeChatList', (res) => {
  45. this.chatList = res;
  46. })
  47. },
  48. components: {
  49. pinappEmptyPage
  50. },
  51. methods: {
  52. }
  53. }
  54. </script>
  55. <style lang="scss">
  56. .message {
  57. .message-list {
  58. margin-top: 20rpx;
  59. .message-item {
  60. background: #fff;
  61. display: flex;
  62. padding: 24rpx 30rpx;
  63. position: relative;
  64. }
  65. .message-image {
  66. width: 100rpx;
  67. height: 100rpx;
  68. border-radius: 16rpx;
  69. overflow: hidden;
  70. }
  71. .message-content {
  72. flex: 1;
  73. width: 0;
  74. margin-left: 20rpx;
  75. display: flex;
  76. flex-direction: column;
  77. justify-content: center;
  78. }
  79. .message-title {
  80. font-size: 32rpx;
  81. font-weight: 600;
  82. margin-bottom: 10rpx;
  83. }
  84. .message-sub-content {
  85. font-weight: 300;
  86. color: $uni-secondary-color;
  87. }
  88. .message-date {
  89. position: absolute;
  90. top: 34rpx;
  91. right: 30rpx;
  92. font-size: 24rpx;
  93. font-weight: 300;
  94. color: $uni-secondary-color;
  95. }
  96. }
  97. }
  98. </style>