lrj
2 天以前 c61d4fe27c97d2ecc907756aa571a4ef14a7b9b6
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<template>
  <div class="player-info-card">
    <h3>学员信息</h3>
    
    <div class="player-header">
      <!-- 头像 -->
      <div class="avatar-container">
        <el-avatar 
          :size="80" 
          :src="playerInfo.avatarUrl"
          :style="{ backgroundColor: avatarBgColor }"
        >
          {{ playerInfo.name ? playerInfo.name.charAt(0) : '?' }}
        </el-avatar>
      </div>
      
      <!-- 基本信息 -->
      <div class="basic-info">
        <h4>{{ playerInfo.name || '未知' }}</h4>
        <p v-if="playerInfo.phone" class="phone">
          <el-icon><Phone /></el-icon>
          {{ playerInfo.phone }}
        </p>
      </div>
    </div>
    
    <!-- 详细信息 -->
    <div class="detail-info">
      <div v-if="playerInfo.description" class="info-item">
        <label>个人简介:</label>
        <p>{{ playerInfo.description }}</p>
      </div>
    </div>
  </div>
</template>
 
<script setup>
import { computed } from 'vue'
import { ElAvatar, ElIcon } from 'element-plus'
import { Phone } from '@element-plus/icons-vue'
 
const props = defineProps({
  playerInfo: {
    type: Object,
    required: true,
    default: () => ({})
  }
})
 
// 根据姓名生成头像背景色
const avatarBgColor = computed(() => {
  if (!props.playerInfo.name) return '#409EFF'
  
  const colors = [
    '#409EFF', '#67C23A', '#E6A23C', '#F56C6C', 
    '#909399', '#C71585', '#FF6347', '#32CD32',
    '#1E90FF', '#FF69B4', '#8A2BE2', '#00CED1'
  ]
  
  let hash = 0
  for (let i = 0; i < props.playerInfo.name.length; i++) {
    hash = props.playerInfo.name.charCodeAt(i) + ((hash << 5) - hash)
  }
  
  return colors[Math.abs(hash) % colors.length]
})
</script>
 
<style scoped>
.player-info-card {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
 
.player-info-card h3 {
  margin: 0 0 16px 0;
  color: #303133;
  font-size: 18px;
  font-weight: 600;
}
 
.player-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
 
.avatar-container {
  flex-shrink: 0;
}
 
.basic-info h4 {
  margin: 0 0 8px 0;
  color: #303133;
  font-size: 20px;
  font-weight: 600;
}
 
.phone {
  margin: 0;
  color: #606266;
  display: flex;
  align-items: center;
  gap: 4px;
}
 
.detail-info {
  border-top: 1px solid #EBEEF5;
  padding-top: 16px;
}
 
.info-item {
  margin-bottom: 12px;
}
 
.info-item label {
  font-weight: 600;
  color: #606266;
  margin-right: 8px;
}
 
.info-item p {
  margin: 4px 0 0 0;
  color: #303133;
  line-height: 1.6;
}
</style>