CircleCard.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <view class="circle-card" :class="{ compact: compact }" @click="$emit('click')">
  3. <view class="circle-card-left">
  4. <view class="circle-icon-wrap" :style="{ background: iconBg(type) }">
  5. <text class="circle-icon">{{ typeIcon(type) }}</text>
  6. </view>
  7. </view>
  8. <view class="circle-card-body">
  9. <text class="circle-name">{{ circle.name }}</text>
  10. <text class="circle-source">{{ sourceLabel(matchSource) }}</text>
  11. </view>
  12. <view class="circle-card-right">
  13. <text class="circle-count">{{ memberCount }}人</text>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. name: 'CircleCard',
  20. props: {
  21. circle: {
  22. type: Object,
  23. required: true
  24. },
  25. compact: {
  26. type: Boolean,
  27. default: false
  28. }
  29. },
  30. computed: {
  31. type: function() {
  32. return this.circle && this.circle.type || 'topic'
  33. },
  34. matchSource: function() {
  35. return this.circle && this.circle.matchSource || ''
  36. },
  37. memberCount: function() {
  38. return this.circle && this.circle.memberCount || 0
  39. }
  40. },
  41. methods: {
  42. typeIcon: function(type) {
  43. var map = {
  44. activity: '\u{1F3AF}',
  45. ability: '\u{1F9E0}',
  46. health: '\u{1F4AA}',
  47. product: '\u{1F6CD}',
  48. provider: '\u{1F468}\u200D\u{1F3EB}',
  49. topic: '\u{1F4AC}',
  50. hobby: '\u{1F3A8}'
  51. }
  52. return map[type] || '\u{1F30D}'
  53. },
  54. iconBg: function(type) {
  55. var map = {
  56. activity: '#E0F7FA',
  57. ability: '#F3E5F5',
  58. health: '#FFF3E0',
  59. product: '#E8F5E9',
  60. provider: '#E3F2FD',
  61. topic: '#FCE4EC',
  62. hobby: '#FFF8E1'
  63. }
  64. return map[type] || '#F5F5F5'
  65. },
  66. sourceLabel: function(source) {
  67. var map = {
  68. activity: '源于共同活动',
  69. assessment: '源于共同测评',
  70. health_report: '源于健康状况',
  71. product: '源于共同商品',
  72. teacher: '源于同一规划师',
  73. article: '源于共同阅读',
  74. game: '源于共同游戏'
  75. }
  76. return map[source] || '源于共同兴趣'
  77. }
  78. }
  79. }
  80. </script>
  81. <style scoped>
  82. .circle-card {
  83. display: flex;
  84. flex-direction: row;
  85. align-items: center;
  86. background: #fff;
  87. border-radius: 16rpx;
  88. padding: 20rpx;
  89. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  90. margin-bottom: 12rpx;
  91. }
  92. .circle-card:active {
  93. opacity: 0.8;
  94. }
  95. .circle-card.compact {
  96. padding: 12rpx;
  97. margin-bottom: 0;
  98. }
  99. .circle-card-left {
  100. margin-right: 16rpx;
  101. }
  102. .circle-icon-wrap {
  103. width: 64rpx;
  104. height: 64rpx;
  105. border-radius: 50%;
  106. display: flex;
  107. align-items: center;
  108. justify-content: center;
  109. }
  110. .circle-icon {
  111. font-size: 32rpx;
  112. }
  113. .circle-card-body {
  114. flex: 1;
  115. display: flex;
  116. flex-direction: column;
  117. gap: 4rpx;
  118. }
  119. .circle-name {
  120. font-size: 28rpx;
  121. font-weight: 600;
  122. color: #333;
  123. }
  124. .circle-source {
  125. font-size: 22rpx;
  126. color: #999;
  127. }
  128. .circle-card-right {
  129. margin-left: 12rpx;
  130. }
  131. .circle-count {
  132. font-size: 22rpx;
  133. color: #F97316;
  134. background: #FFF7ED;
  135. padding: 4rpx 12rpx;
  136. border-radius: 20rpx;
  137. }
  138. </style>