四零语境前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

163 lines
3.7 KiB

  1. <template>
  2. <view class="book-list">
  3. <view v-for="(book, index) in list" :key="index" class="book-item" @click="goToDetail(book)">
  4. <view class="book-cover">
  5. <image :src="book.booksImg" mode="aspectFill"></image>
  6. </view>
  7. <view class="book-info">
  8. <view class="book-title">{{ book.booksName }}</view>
  9. <view class="book-author">{{ book.booksAuthor }}</view>
  10. <view class="book-meta">
  11. <view class="book-duration">
  12. <image src="/static/play-icon.png" mode="aspectFill" class="book-icon"></image>
  13. <text>{{ book.duration }}</text>
  14. </view>
  15. <view class="book-membership" :class="classMap[book.vipInfo.title]">
  16. {{ book.vipInfo.title }}
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. <uv-loading-icon text="加载中" textSize="30rpx" v-if="isLoading"></uv-loading-icon>
  22. <uv-empty v-else-if="list.length === 0"></uv-empty>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. name: 'BookList',
  28. props: {
  29. list: {
  30. type: Array,
  31. default: () => []
  32. },
  33. isLoading: {
  34. type: Boolean,
  35. default: false
  36. }
  37. },
  38. data() {
  39. return {
  40. // 类型映射表
  41. classMap: {
  42. '蕾朵会员': 'book-membership-premium',
  43. '盛放会员': 'book-membership-vip',
  44. '萌芽会员': 'book-membership-basic',
  45. }
  46. }
  47. },
  48. methods: {
  49. goToDetail(book) {
  50. uni.navigateTo({
  51. url: '/subPages/home/directory?id=' + book.id
  52. })
  53. }
  54. }
  55. }
  56. </script>
  57. <style scoped lang="scss">
  58. .book-list {
  59. display: flex;
  60. flex-direction: column;
  61. gap: 32rpx;
  62. }
  63. .book-item {
  64. display: flex;
  65. align-items: center;
  66. background: #F8F8F8;
  67. height: 212rpx;
  68. gap: 16rpx;
  69. border-radius: 16rpx;
  70. padding: 0rpx 16rpx;
  71. &:last-child {
  72. border-bottom: none;
  73. }
  74. .book-cover {
  75. width: 136rpx;
  76. height: 180rpx;
  77. border-radius: 16rpx;
  78. overflow: hidden;
  79. margin-right: 16rpx;
  80. image {
  81. width: 100%;
  82. height: 100%;
  83. }
  84. }
  85. .book-info {
  86. flex: 1;
  87. display: flex;
  88. flex-direction: column;
  89. justify-content: space-between;
  90. }
  91. .book-title {
  92. font-size: 32rpx;
  93. font-weight: 600;
  94. color: $primary-text-color;
  95. line-height: 48rpx;
  96. letter-spacing: 0;
  97. margin-bottom: 12rpx;
  98. overflow: hidden;
  99. text-overflow: ellipsis;
  100. }
  101. .book-author {
  102. font-size: 24rpx;
  103. color: $secondary-text-color;
  104. margin-bottom: 16rpx;
  105. overflow: hidden;
  106. text-overflow: ellipsis;
  107. white-space: nowrap;
  108. }
  109. .book-meta {
  110. display: flex;
  111. align-items: center;
  112. justify-content: space-between;
  113. }
  114. .book-duration {
  115. display: flex;
  116. align-items: center;
  117. font-size: 22rpx;
  118. color: #999;
  119. .book-icon {
  120. width: 18rpx;
  121. height: 18rpx;
  122. }
  123. text {
  124. margin-left: 8rpx;
  125. }
  126. }
  127. .book-membership {
  128. padding: 8rpx 16rpx;
  129. border-radius: 8rpx;
  130. font-size: 24rpx;
  131. color: #211508;
  132. flex-shrink: 0;
  133. }
  134. }
  135. .book-membership-premium {
  136. background: #E9F1FF;
  137. border: 2rpx solid #C4DAFF
  138. }
  139. .book-membership-vip {
  140. background: #FFF4E9;
  141. border: 2rpx solid #FFE2C4
  142. }
  143. .book-membership-basic {
  144. background: #FFE9E9;
  145. border: 2rpx solid #FFDBC4
  146. }
  147. </style>