index.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <view
  3. :class="[
  4. 'user_card_msg_container',
  5. isSelf ? 'user_card_msg_container_mine' : 'user_card_msg_container_other',
  6. ]"
  7. >
  8. <view class="user_card_content">
  9. <view class="user_card_content_header">
  10. <u-avatar shape="square" :src="avatarUrl" size="30"></u-avatar>
  11. <text class="nickName">{{ nickName }}</text>
  12. </view>
  13. <u-line></u-line>
  14. <text class="user_card_footer">个人名片</text>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. props: {
  21. msgBody: {
  22. type: Object,
  23. default: () => ({}),
  24. },
  25. },
  26. data() {
  27. return {
  28. defaultAvatar: '/static/images/new_ui/defaultAvatar.png',
  29. };
  30. },
  31. computed: {
  32. isSelf() {
  33. const { from } = this.msgBody;
  34. return (
  35. from === this.$store.state.LoginStore.loginUserBaseInfos.loginUserId
  36. );
  37. },
  38. avatarUrl() {
  39. return this.msgBody?.customExts?.avatarurl || this.defaultAvatar;
  40. },
  41. nickName() {
  42. return (
  43. this.msgBody?.customExts?.nickname || this.msgBody?.customExts?.uid
  44. );
  45. },
  46. },
  47. };
  48. </script>
  49. <style scoped>
  50. .user_card_msg_container {
  51. width: 245px;
  52. height: 60px;
  53. padding: 5px 8px;
  54. box-sizing: border-box;
  55. flex-direction: column;
  56. align-items: center;
  57. }
  58. .user_card_msg_container_mine {
  59. flex-direction: row-reverse;
  60. color: #f9fafa;
  61. background-color: #009eff;
  62. border-radius: 16px 12px 4px 16px;
  63. }
  64. .user_card_msg_container_other {
  65. color: #171a1c;
  66. background-color: #e5f5ff;
  67. border-radius: 12px 16px 16px 4px;
  68. }
  69. .user_card_content {
  70. height: 100%;
  71. display: flex;
  72. flex-direction: column;
  73. justify-content: space-around;
  74. }
  75. .user_card_content_header {
  76. display: flex;
  77. align-items: center;
  78. justify-content: flex-start;
  79. }
  80. .user_card_content_header text {
  81. font-family: 'PingFang SC';
  82. font-style: normal;
  83. font-weight: 400;
  84. font-size: 16px;
  85. line-height: 22px;
  86. margin: 0 4px;
  87. }
  88. .user_card_footer {
  89. font-size: 12px;
  90. }
  91. </style>