zhengyiming
2025-02-10 0f686ea1fe4700a909a6159efcf1fcb0e1f88a17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<template>
  <Card class="message-card-wrapper">
    <div class="message-card-inner">
      <nut-badge :value="badge" :max="99" top="6" right="10" :hidden="!badge">
        <Avatar :size="40" class="message-card-avatar" :src="avatarUrl" />
      </nut-badge>
      <div class="message-card-content">
        <div class="message-card-content-top">
          <div class="message-card-title">{{ contact }}</div>
          <div class="message-card-time">
            {{ dayjs(latestMessageCreationTime).format('YYYY-MM-DD') }}
          </div>
        </div>
        <div class="message-card-content-bottom">{{ latestMessageContent }}</div>
      </div>
    </div>
  </Card>
</template>
 
<script setup lang="ts">
import Card from './Card.vue';
import { Avatar } from '@12333/components';
import dayjs from 'dayjs';
import { MessageChatTypeEnum } from '@12333/constants';
import { MessageChatTypeAvatarMap } from '@/constants';
 
defineOptions({
  name: 'MessageCard',
});
 
type Props = {
  badge?: number;
  avatarUrl?: string;
  latestMessageCreationTime?: string;
  latestMessageContent?: string;
  contact?: string;
  chatType?: MessageChatTypeEnum;
};
 
const props = withDefaults(defineProps<Props>(), {});
</script>
 
<style lang="scss">
@import '@/styles/common.scss';
 
.message-card-wrapper {
  border-radius: 0;
  padding: 0 boleGetCssVar('size', 'body-padding-h');
  margin-bottom: 0;
 
  &:last-child {
    .message-card-inner {
      border-bottom: none;
    }
  }
 
  .message-card-inner {
    border-bottom: 2px solid #f6f6f6;
    padding: 32px 0;
    display: flex;
 
    .message-card-avatar {
      margin-right: 16px;
    }
 
    .message-card-content {
      flex: 1;
      min-width: 0;
 
      .message-card-content-top {
        display: flex;
        align-items: center;
        margin-bottom: 8px;
 
        .message-card-title {
          font-weight: 600;
          font-size: 28px;
          color: #555555;
          line-height: 40px;
          @include ellipsis;
          flex: 1;
          min-width: 0;
        }
 
        .message-card-time {
          font-weight: 400;
          font-size: 22px;
          color: boleGetCssVar('text-color', 'regular');
          line-height: 32px;
        }
      }
 
      .message-card-content-bottom {
        font-weight: 400;
        font-size: 24px;
        color: boleGetCssVar('text-color', 'regular');
        line-height: 34px;
        @include ellipsis;
      }
    }
  }
}
</style>