UserProfileSummary.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import React from 'react'
  2. import { View, Text } from '@tarojs/components'
  3. import type { UserProfile } from '../types/settings'
  4. interface UserProfileSummaryProps {
  5. /** 用户信息 */
  6. profile: UserProfile
  7. }
  8. /**
  9. * 用户信息摘要组件
  10. * 显示用户头像、姓名、残疾类型和统计数据
  11. * 原型参考: docs/小程序原型/rencai.html (行770-906)
  12. */
  13. export const UserProfileSummary: React.FC<UserProfileSummaryProps> = ({ profile }) => {
  14. // 获取姓名首字作为头像
  15. const avatarText = profile.name?.charAt(0) || ''
  16. return (
  17. <View className="bg-white border-b border-gray-200">
  18. {/* 用户头像和基本信息 */}
  19. <View className="flex flex-row items-center p-4 mb-4">
  20. {/* 圆形头像 */}
  21. <View className="w-16 h-16 rounded-full bg-blue-500 flex items-center justify-center mr-4">
  22. <Text className="text-white text-xl font-bold">{avatarText}</Text>
  23. </View>
  24. {/* 姓名和残疾类型 */}
  25. <View className="flex flex-col">
  26. <Text className="font-semibold text-gray-800 text-base">{profile.name}</Text>
  27. <Text className="text-sm text-gray-500 mt-1">
  28. {profile.disabilityType} · {profile.disabilityLevel}
  29. </Text>
  30. </View>
  31. </View>
  32. {/* 3列统计数据 */}
  33. <View className="flex flex-row justify-around pb-4">
  34. {/* 本月出勤 */}
  35. <View className="flex flex-col items-center">
  36. <Text className="text-xl font-bold text-gray-800">{profile.stats.thisMonthAttendance}</Text>
  37. <Text className="text-xs text-gray-500 mt-1">本月出勤</Text>
  38. </View>
  39. {/* 累计出勤 */}
  40. <View className="flex flex-col items-center">
  41. <Text className="text-xl font-bold text-gray-800">{profile.stats.totalAttendance}</Text>
  42. <Text className="text-xs text-gray-500 mt-1">累计出勤</Text>
  43. </View>
  44. {/* 本月薪资 */}
  45. <View className="flex flex-col items-center">
  46. <Text className="text-xl font-bold text-gray-800">
  47. ¥{profile.stats.thisMonthSalary.toLocaleString()}
  48. </Text>
  49. <Text className="text-xs text-gray-500 mt-1">本月薪资</Text>
  50. </View>
  51. </View>
  52. </View>
  53. )
  54. }