bookdetails-recommend.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <view class="recommend_content">
  3. <view class="line">
  4. <image class="image" src="../../static/imgs/public/img_line.png" mode="aspectFill"></image>
  5. </view>
  6. <view class="top">
  7. <view class="top__title">同类推荐</view>
  8. <view class="top__change" @click="clickChangeBook()">
  9. <image class="image" src="../../static/imgs/public/img_change.png" mode="aspectFill"></image>
  10. </view>
  11. </view>
  12. <view class="book-content">
  13. <view class="book-content__box" v-for="(item,index) in book_list" :key="index" @click="clickBook(item)">
  14. <view class="book-content__box__book-cover">
  15. <image class="image" :src="item.book_cover" mode="aspectFill"></image>
  16. </view>
  17. <view class="book-content__box__book-name">{{ item.book_name }}</view>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script setup lang="ts">
  23. import { book_item_data } from '../../data/data';
  24. import { tools } from '../../framework/tools';
  25. defineProps({
  26. book_list: Array,
  27. })
  28. const emits = defineEmits(['clickChangeBook'])
  29. function clickChangeBook() {
  30. emits('clickChangeBook')
  31. }
  32. function clickBook(data:book_item_data) {
  33. tools.gotoBookdetails(data.book_id)
  34. }
  35. </script>
  36. <style lang="scss">
  37. .recommend_content{
  38. display: flex;
  39. flex-direction: column;
  40. padding: 0 20rpx;
  41. margin-top: 40rpx;
  42. .line{
  43. flex-shrink: 0;
  44. width: 670rpx;
  45. height: 17rpx;
  46. .image{
  47. width: 100%;
  48. height: 100%;
  49. }
  50. }
  51. .top{
  52. margin-top: 40rpx;
  53. display: flex;
  54. flex-direction: row;
  55. justify-content: space-between;
  56. align-items: center;
  57. &__title {
  58. font-size: 20px;
  59. }
  60. &__change {
  61. flex-shrink: 0;
  62. width: 220rpx;
  63. height: 80rpx;
  64. .image {
  65. width: 100%;
  66. height: 100%;
  67. }
  68. }
  69. }
  70. .book-content{
  71. display: flex;
  72. flex: 1;
  73. box-sizing: border-box;
  74. flex-direction: row;
  75. flex-wrap: wrap;
  76. text-align: center;
  77. // background-color: red;
  78. &__box{
  79. width: 33.3%;
  80. justify-content: center;
  81. margin-bottom: 20rpx;
  82. overflow: hidden;
  83. // background-color: greenyellow;
  84. &__book-cover{
  85. flex-shrink: 0;
  86. display: flex;
  87. box-sizing: border-box;
  88. margin: 20rpx;
  89. height: 260rpx;
  90. .image{
  91. width: 100%;
  92. height: 100%;
  93. }
  94. }
  95. &__book-name {
  96. font-size: 16px;
  97. margin: 0px 20rpx;
  98. display: -webkit-box;
  99. -webkit-line-clamp: 2;
  100. -webkit-box-orient: vertical;
  101. overflow: hidden;
  102. text-overflow: ellipsis;
  103. text-align: left;
  104. }
  105. }
  106. }
  107. }
  108. </style>