PearlDiagram.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <view class="pearl-section">
  3. <view class="pearl-header">
  4. <text class="pearl-title">我的珍珠圈</text>
  5. <text class="pearl-discover-btn" @click="$emit('discover')">发现新圈子</text>
  6. </view>
  7. <view v-if="circles && circles.length > 0" class="pearl-scroll-wrap">
  8. <scroll-view class="pearl-scroll" scroll-x enable-flex>
  9. <view class="pearl-scroll-inner">
  10. <view
  11. class="pearl-item"
  12. v-for="item in circles"
  13. :key="item.id"
  14. @click="$emit('circleClick', item)">
  15. <view class="pearl-icon-wrap">
  16. <text class="pearl-icon">{{ typeIcon(item.type) }}</text>
  17. </view>
  18. <text class="pearl-name">{{ item.name }}</text>
  19. <text class="pearl-count">{{ item.memberCount || 0 }}人</text>
  20. </view>
  21. <view class="pearl-add-item" @click="$emit('discover')">
  22. <view class="pearl-add-icon-wrap">
  23. <text class="pearl-add-icon">+</text>
  24. </view>
  25. <text class="pearl-add-label">发现更多</text>
  26. </view>
  27. </view>
  28. </scroll-view>
  29. </view>
  30. <view v-else class="pearl-empty">
  31. <text class="pearl-empty-text">暂无圈子</text>
  32. <text class="pearl-empty-action" @click="$emit('discover')">去发现新圈子</text>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. export default {
  38. name: 'PearlDiagram',
  39. props: {
  40. circles: {
  41. type: Array,
  42. default: function() { return [] }
  43. },
  44. isLoggedIn: {
  45. type: Boolean,
  46. default: false
  47. }
  48. },
  49. methods: {
  50. typeIcon: function(type) {
  51. var map = {
  52. activity: '\u{1F3AF}',
  53. ability: '\u{1F9E0}',
  54. health: '\u{1F4AA}',
  55. product: '\u{1F6CD}',
  56. provider: '\u{1F468}\u200D\u{1F3EB}',
  57. topic: '\u{1F4AC}',
  58. hobby: '\u{1F3A8}'
  59. }
  60. return map[type] || '\u{1F30D}'
  61. }
  62. }
  63. }
  64. </script>
  65. <style scoped>
  66. .pearl-section {
  67. margin: 20rpx 20rpx 0;
  68. }
  69. .pearl-header {
  70. display: flex;
  71. justify-content: space-between;
  72. align-items: center;
  73. margin-bottom: 16rpx;
  74. }
  75. .pearl-title {
  76. font-size: 30rpx;
  77. font-weight: 600;
  78. color: #333;
  79. }
  80. .pearl-discover-btn {
  81. font-size: 24rpx;
  82. color: #F97316;
  83. font-weight: 500;
  84. }
  85. .pearl-scroll {
  86. white-space: nowrap;
  87. overflow: hidden;
  88. }
  89. .pearl-scroll-inner {
  90. display: flex;
  91. flex-direction: row;
  92. gap: 16rpx;
  93. padding: 8rpx 0 16rpx;
  94. }
  95. .pearl-item {
  96. flex-shrink: 0;
  97. width: 160rpx;
  98. background: #fff;
  99. border-radius: 16rpx;
  100. padding: 20rpx 12rpx;
  101. display: flex;
  102. flex-direction: column;
  103. align-items: center;
  104. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  105. }
  106. .pearl-item:active {
  107. opacity: 0.8;
  108. }
  109. .pearl-icon-wrap {
  110. width: 72rpx;
  111. height: 72rpx;
  112. border-radius: 50%;
  113. background: #FFF7ED;
  114. display: flex;
  115. align-items: center;
  116. justify-content: center;
  117. margin-bottom: 10rpx;
  118. }
  119. .pearl-icon {
  120. font-size: 36rpx;
  121. }
  122. .pearl-name {
  123. font-size: 24rpx;
  124. color: #333;
  125. font-weight: 500;
  126. text-align: center;
  127. white-space: normal;
  128. overflow: hidden;
  129. text-overflow: ellipsis;
  130. display: -webkit-box;
  131. -webkit-line-clamp: 2;
  132. -webkit-box-orient: vertical;
  133. max-width: 140rpx;
  134. }
  135. .pearl-count {
  136. font-size: 20rpx;
  137. color: #999;
  138. margin-top: 4rpx;
  139. }
  140. .pearl-add-item {
  141. flex-shrink: 0;
  142. width: 120rpx;
  143. display: flex;
  144. flex-direction: column;
  145. align-items: center;
  146. justify-content: center;
  147. padding: 20rpx 8rpx;
  148. }
  149. .pearl-add-item:active {
  150. opacity: 0.7;
  151. }
  152. .pearl-add-icon-wrap {
  153. width: 72rpx;
  154. height: 72rpx;
  155. border-radius: 50%;
  156. border: 2rpx dashed #ddd;
  157. display: flex;
  158. align-items: center;
  159. justify-content: center;
  160. margin-bottom: 10rpx;
  161. }
  162. .pearl-add-icon {
  163. font-size: 36rpx;
  164. color: #ccc;
  165. }
  166. .pearl-add-label {
  167. font-size: 22rpx;
  168. color: #999;
  169. }
  170. .pearl-empty {
  171. background: #fff;
  172. border-radius: 16rpx;
  173. padding: 40rpx 0;
  174. display: flex;
  175. flex-direction: column;
  176. align-items: center;
  177. gap: 12rpx;
  178. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  179. }
  180. .pearl-empty-text {
  181. font-size: 26rpx;
  182. color: #ccc;
  183. }
  184. .pearl-empty-action {
  185. font-size: 26rpx;
  186. color: #F97316;
  187. font-weight: 500;
  188. }
  189. </style>