CircleCard.vue 3.4 KB

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