book-list.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <view class="book-list">
  3. <view class="header-info flex-a flex-j-b mb-20">
  4. <text class="common-title">共{{ totalNum }}本</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)" :isReturn="isReturn"></detail-book-item>
  12. <!-- 添加底部展开/收起按钮 -->
  13. <view class="expand-btn" @click="toggleExpand" v-if="books.length > 3">
  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. totalNum: {
  37. type: Number,
  38. default: 0
  39. },
  40. isReturn: {
  41. type: Boolean,
  42. default: false
  43. }
  44. },
  45. methods: {
  46. showRules() {
  47. uni.navigateTo({
  48. url: '/pages-mine/pages/rules-for-sellbooks'
  49. })
  50. },
  51. toggleExpand() {
  52. this.isExpanded = !this.isExpanded;
  53. }
  54. }
  55. }
  56. </script>
  57. <style lang="scss" scoped>
  58. .book-list {
  59. background: #FFFFFF;
  60. padding: 20rpx 30rpx;
  61. margin: 30rpx;
  62. border-radius: 10rpx;
  63. box-sizing: border-box;
  64. .expand-btn {
  65. display: flex;
  66. align-items: center;
  67. justify-content: center;
  68. background: #fff;
  69. font-size: 28rpx;
  70. color: #333;
  71. height: 88rpx;
  72. background: #F8F8F8;
  73. border-radius: 10rpx;
  74. .u-icon {
  75. margin-left: 8rpx;
  76. }
  77. }
  78. }
  79. </style>