大数据展示系统-前端
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.

133 lines
2.9 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div class="hotbook-box">
  3. <div class="most-book" @click="handleDetails(0)">
  4. <div class="most-book-img">
  5. <img :src="bookdata[0].cover ? bookdata[0].cover : ''" :onerror="defaultImg">
  6. </div>
  7. <div class="most-book-txt book-rack">
  8. <div class="txt">
  9. <h3>书名{{ bookdata[0].nbName }}</h3>
  10. <p>作者{{ bookdata[0].nbAuthor }}</p>
  11. <p>出版社{{ bookdata[0].nbAuthor }}</p>
  12. <p>出版时间{{ bookdata[0].nbPublisherdate }}</p>
  13. </div>
  14. </div>
  15. </div>
  16. <ul class="hotbook-list">
  17. <li v-for="(item,index) in bookList" :key="index" @click="handleDetails(index)">
  18. <img :src="item.cover ? item.cover : ''" :onerror="defaultImg">
  19. <p class="book-name">{{ item.nbName }}</p>
  20. </li>
  21. </ul>
  22. <BookDetails ref="detailDom" />
  23. </div>
  24. </template>
  25. <script>
  26. import BookDetails from './bookDetails.vue'
  27. export default {
  28. name: 'BookList',
  29. components: { BookDetails },
  30. props: {
  31. bookdata: {
  32. type: Array,
  33. default: function() {
  34. return []
  35. }
  36. }
  37. },
  38. data() {
  39. return {
  40. defaultImg: 'this.src="' + require('@/assets/images/default-img.png') + '"'
  41. }
  42. },
  43. computed: {
  44. bookList() {
  45. const arr = this.bookdata.slice(1)
  46. return arr
  47. }
  48. },
  49. methods: {
  50. handleDetails(index) {
  51. this.$refs.detailDom.bookData = this.bookdata[index]
  52. this.$refs.detailDom.dialogVisible = true
  53. console.log(this.bookdata[0])
  54. }
  55. }
  56. }
  57. </script>
  58. <style lang="scss" scoped>
  59. @import "~@/assets/styles/index.scss";
  60. .hotbook-box{
  61. overflow: hidden;
  62. overflow-y: auto;
  63. height: calc(100vh - 180px);
  64. }
  65. .book-rack{
  66. margin: 160px 40px 28px 40px;
  67. padding: 38px 40px 40px 400px;
  68. height: 272px;
  69. }
  70. .most-book{
  71. position: relative;
  72. .most-book-img{
  73. position: absolute;
  74. left: 90px;
  75. bottom: 20px;
  76. width: 318px;
  77. height: 382px;
  78. overflow: hidden;
  79. img{
  80. width: 100%;
  81. vertical-align: middle;
  82. }
  83. }
  84. .txt{
  85. // margin-left: 452px;
  86. color: #333;
  87. h3{
  88. font-size: 40px;
  89. font-weight: normal;
  90. overflow: hidden;
  91. white-space: nowrap;
  92. text-overflow: ellipsis;
  93. }
  94. p{
  95. font-size: 30px;
  96. margin-top: 8px;
  97. overflow: hidden;
  98. white-space: nowrap;
  99. text-overflow: ellipsis;
  100. }
  101. }
  102. }
  103. .hotbook-list{
  104. margin: 0 40px;
  105. display: flex;
  106. flex-wrap: wrap;
  107. // justify-content: space-between;
  108. li{
  109. margin-bottom: 20px;
  110. margin-left: 48px;
  111. width: 300px;
  112. overflow: hidden;
  113. // text-align: center;
  114. img{
  115. width: 100%;
  116. vertical-align: middle;
  117. height: 360px;
  118. }
  119. .book-name{
  120. width: 100%;
  121. overflow: hidden;
  122. text-overflow:ellipsis;
  123. white-space: nowrap;
  124. }
  125. }
  126. & li:nth-child(3n+1){
  127. margin-left: 0;
  128. }
  129. }
  130. </style>