DimensionArticles.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <view class="section">
  3. <view class="section-header">
  4. <text class="section-title">🔥 推荐阅读</text>
  5. <text class="section-more" @click="$emit('moreArticles')">更多 ›</text>
  6. </view>
  7. <view v-if="!displayArticles || displayArticles.length === 0" class="empty-state">
  8. <text class="empty-tip">{{ isLoggedIn ? '暂无阅读推荐' : '登录后查看更多文章' }}</text>
  9. </view>
  10. <view class="article-list">
  11. <view class="article-card" v-for="article in displayArticles" :key="article.id" @click="$emit('articleClick', article)">
  12. <view class="article-category" :style="{ background: article.categoryColor || defaultColors[0] }">
  13. <text class="article-category-text">{{ article.category || '推荐文章' }}</text>
  14. </view>
  15. <text class="article-title">{{ article.title }}</text>
  16. <text class="article-summary" v-if="article.summary">{{ article.summary }}</text>
  17. <view class="article-meta">
  18. <view class="meta-item">
  19. <text class="meta-icon">&#x1F4D6;</text>
  20. <text class="meta-text">{{ article.views || '0' }}</text>
  21. </view>
  22. <view class="meta-item">
  23. <text class="meta-icon">&#x1F44D;</text>
  24. <text class="meta-text">{{ article.likes || '0' }}</text>
  25. </view>
  26. <text class="article-date" v-if="article.date">{{ article.date }}</text>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. var defaultGradientColors = [
  34. 'linear-gradient(135deg, #6366F1, #818CF8)',
  35. 'linear-gradient(135deg, #8B5CF6, #A78BFA)',
  36. 'linear-gradient(135deg, #5B9BD5, #8FC5E8)',
  37. 'linear-gradient(135deg, #10B981, #34D399)',
  38. 'linear-gradient(135deg, #F97316, #FB923C)'
  39. ]
  40. export default {
  41. props: {
  42. dimensionCode: { type: String, required: true },
  43. articles: { type: Array, default: function() { return [] } },
  44. isLoggedIn: { type: Boolean, default: false },
  45. colors: { type: Array, default: function() { return defaultGradientColors } }
  46. },
  47. computed: {
  48. defaultColors: function() {
  49. return defaultGradientColors
  50. },
  51. displayArticles: function() {
  52. return this.articles
  53. }
  54. }
  55. }
  56. </script>
  57. <style scoped>
  58. .section {
  59. margin: 20rpx 20rpx;
  60. }
  61. .section-header {
  62. display: flex;
  63. justify-content: space-between;
  64. align-items: center;
  65. margin-bottom: 20rpx;
  66. }
  67. .section-title {
  68. font-size: 30rpx;
  69. font-weight: bold;
  70. color: #333;
  71. }
  72. .section-more {
  73. font-size: 24rpx;
  74. color: #999;
  75. }
  76. .article-list {
  77. display: flex;
  78. flex-direction: column;
  79. }
  80. .article-card {
  81. background: #fff;
  82. border-radius: 20rpx;
  83. padding: 28rpx 24rpx;
  84. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  85. margin-bottom: 20rpx;
  86. }
  87. .article-card:active {
  88. opacity: 0.8;
  89. }
  90. .article-category {
  91. display: inline-block;
  92. padding: 4rpx 18rpx;
  93. border-radius: 20rpx;
  94. margin-bottom: 14rpx;
  95. }
  96. .article-category-text {
  97. font-size: 20rpx;
  98. color: #fff;
  99. font-weight: 500;
  100. }
  101. .article-title {
  102. font-size: 28rpx;
  103. font-weight: bold;
  104. color: #333;
  105. display: block;
  106. margin-bottom: 10rpx;
  107. }
  108. .article-summary {
  109. font-size: 24rpx;
  110. color: #888;
  111. line-height: 1.5;
  112. display: block;
  113. margin-bottom: 20rpx;
  114. }
  115. .article-meta {
  116. display: flex;
  117. flex-direction: row;
  118. align-items: center;
  119. }
  120. .meta-item {
  121. display: flex;
  122. flex-direction: row;
  123. align-items: center;
  124. margin-right: 24rpx;
  125. }
  126. .meta-icon {
  127. font-size: 24rpx;
  128. margin-right: 6rpx;
  129. }
  130. .meta-text {
  131. font-size: 22rpx;
  132. color: #999;
  133. }
  134. .article-date {
  135. font-size: 22rpx;
  136. color: #bbb;
  137. margin-left: auto;
  138. }
  139. .empty-state {
  140. display: flex;
  141. justify-content: center;
  142. padding: 40rpx 0;
  143. }
  144. .empty-tip {
  145. font-size: 24rpx;
  146. color: #999;
  147. }
  148. </style>