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
104
105
106
107
108
109
110
111
112
<template>
  <div class="card-avatar-wrapper">
    <Avatar
      class="card-avatar"
      :size="30"
      :src="src ? setOSSLink(src) : ''"
      @click.stop="goUserHomePage"
    />
    <div class="card-avatar-name-wrapper">
      <div class="card-avatar-name">
        {{ name }}
        <template v-if="jobTitle">·{{ jobTitle }}</template>
      </div>
      <!-- <template v-if="jobTitle">
        <div class="card-avatar-dot"></div>
        <div class="card-avatar-jobTitle">{{ jobTitle }}</div>
      </template> -->
      <div :class="['card-avatar-certified', { isCertified }]">
        {{ isCertified ? '已认证' : '未认证' }}
      </div>
    </div>
  </div>
</template>
 
<script setup lang="ts">
import { Avatar } from '@12333/components';
import { setOSSLink } from '@12333/utils';
import Taro from '@tarojs/taro';
 
defineOptions({
  name: 'CardAvatar',
});
 
type Props = {
  src?: string;
  name?: string;
  jobTitle?: string;
  userId?: string;
  isCertified?: boolean;
};
 
const props = withDefaults(defineProps<Props>(), {});
 
function goUserHomePage() {
  if (props.userId) {
    Taro.navigateTo({
      url: `${RouterPath.userHomePage}?userId=${props.userId}`,
    });
  }
}
</script>
 
<style lang="scss">
@import '@/styles/common.scss';
 
.card-avatar-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
 
  .card-avatar {
    margin-right: 16px;
  }
 
  .card-avatar-name-wrapper {
    color: boleGetCssVar('text-color', 'primary');
    line-height: 40px;
    font-size: 0;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
  }
 
  .card-avatar-name {
    font-weight: bold;
    font-size: 28px;
    vertical-align: middle;
    @include ellipsis;
  }
 
  .card-avatar-dot {
    width: 4px;
    height: 4px;
    background: boleGetCssVar('text-color', 'primary');
    vertical-align: middle;
    border-radius: 50%;
    margin: 0 8px;
    flex-shrink: 0;
  }
 
  .card-avatar-jobTitle {
    font-weight: 400;
    font-size: 28px;
    vertical-align: middle;
    flex-shrink: 0;
  }
 
  .card-avatar-certified {
    font-weight: 400;
    font-size: 28px;
    vertical-align: middle;
    flex-shrink: 0;
    margin-left: 8px;
 
    &.isCertified {
      color: boleGetCssVar('color', 'success');
    }
  }
}
</style>