book-list.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <view class="book-list">
  3. <view class="header-info flex-a flex-j-b mb-20">
  4. <text class="common-title">共20本</text>
  5. <view class="common-text" @click="showRules">
  6. <text class="mr-10">卖书审核规则</text>
  7. <u-icon name="question-circle-fill" size="36" top="4rpx" color="#333"></u-icon>
  8. </view>
  9. </view>
  10. <detail-book-item :book="item" v-for="(item, index) in books" :key="index"
  11. v-if="isExpanded || (index < 3 && !isExpanded)"></detail-book-item>
  12. <!-- 添加底部展开/收起按钮 -->
  13. <view class="expand-btn" @click="toggleExpand">
  14. <text>{{ isExpanded ? '收起' : '查看全部' }}</text>
  15. <u-icon :name="isExpanded ? 'arrow-up' : 'arrow-down'" size="24" color="#666"></u-icon>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. import detailBookItem from './detail-book-item.vue';
  21. export default {
  22. components: {
  23. detailBookItem
  24. },
  25. name: 'book-list',
  26. data() {
  27. return {
  28. isExpanded: false
  29. }
  30. },
  31. props: {
  32. books: {
  33. type: Array,
  34. default: () => []
  35. }
  36. },
  37. methods: {
  38. showRules() {
  39. console.log('showRules');
  40. },
  41. toggleExpand() {
  42. this.isExpanded = !this.isExpanded;
  43. }
  44. }
  45. }
  46. </script>
  47. <style lang="scss" scoped>
  48. .book-list {
  49. background: #FFFFFF;
  50. padding: 20rpx 30rpx;
  51. margin: 30rpx;
  52. border-radius: 10rpx;
  53. box-sizing: border-box;
  54. .expand-btn {
  55. display: flex;
  56. align-items: center;
  57. justify-content: center;
  58. background: #fff;
  59. font-size: 28rpx;
  60. color: #333;
  61. height: 88rpx;
  62. background: #F8F8F8;
  63. border-radius: 10rpx;
  64. .u-icon {
  65. margin-left: 8rpx;
  66. }
  67. }
  68. }
  69. </style>