message.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. onShow() {
  37. //监听会话列表更新
  38. YeIMUniSDK.getInstance().addEventListener(YeIMUniSDKDefines.EVENT.CONVERSATION_LIST_CHANGED, (list) => {
  39. this.chatList = list;
  40. });
  41. },
  42. components: {
  43. pinappEmptyPage
  44. },
  45. onLoad() {
  46. },
  47. methods: {
  48. }
  49. }
  50. </script>
  51. <style lang="scss">
  52. .message {
  53. .message-list {
  54. margin-top: 20rpx;
  55. .message-item {
  56. background: #fff;
  57. display: flex;
  58. padding: 24rpx 30rpx;
  59. position: relative;
  60. }
  61. .message-image {
  62. width: 100rpx;
  63. height: 100rpx;
  64. border-radius: 16rpx;
  65. overflow: hidden;
  66. }
  67. .message-content {
  68. flex: 1;
  69. width: 0;
  70. margin-left: 20rpx;
  71. display: flex;
  72. flex-direction: column;
  73. justify-content: center;
  74. }
  75. .message-title {
  76. font-size: 32rpx;
  77. font-weight: 600;
  78. margin-bottom: 10rpx;
  79. }
  80. .message-sub-content {
  81. font-weight: 300;
  82. color: $uni-secondary-color;
  83. }
  84. .message-date {
  85. position: absolute;
  86. top: 34rpx;
  87. right: 30rpx;
  88. font-size: 24rpx;
  89. font-weight: 300;
  90. color: $uni-secondary-color;
  91. }
  92. }
  93. }
  94. </style>