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

97 lines
2.5 KiB

  1. <template>
  2. <div>
  3. <div :class="[isNewBook ? 'list-small' : (isOtherBook ? 'list-middle' : 'list-big') ]">
  4. <div v-for="(item,index) in listData" :key="item.ranking" class="list-item" @click="handleDetails(index)">
  5. <div class="book-img">
  6. <img :src="item.cover ? item.cover : ''" :onerror="defaultImg" />
  7. </div>
  8. <div class="book-info">
  9. <h4 :class="['book-title', {'title-item': !isOtherBook}]">{{ item.nbName }}</h4>
  10. <p class="book-author">{{ item.nbAuthor }}</p>
  11. <div v-if="!isNewBook" class="book-num">
  12. <svg class="icon" aria-hidden="true">
  13. <use xlink:href="#icon-remen" />
  14. </svg>
  15. <p>{{ item.num }}</p>
  16. </div>
  17. </div>
  18. </div>
  19. </div>
  20. <BookDetails ref="detailDom" />
  21. </div>
  22. </template>
  23. <script>
  24. import { getBookDetailsByISBN } from '@/api/bookshelf'
  25. import BookDetails from './bookDetails.vue'
  26. export default {
  27. name: 'BookListItem',
  28. components: { BookDetails },
  29. props: {
  30. listData: {
  31. type: Array,
  32. default: function() {
  33. return []
  34. }
  35. },
  36. isOtherBook: {
  37. type: Boolean,
  38. default: function() {
  39. return false
  40. }
  41. },
  42. isNewBook: {
  43. type: Boolean,
  44. default: function() {
  45. return false
  46. }
  47. }
  48. },
  49. data() {
  50. return {
  51. defaultImg: 'this.src="' + require('@/assets/images/default-img.png') + '"'
  52. }
  53. },
  54. watch: {
  55. listData: function(newValue, oldValue) {
  56. },
  57. isOtherBook: function(newValue, oldValue) {
  58. },
  59. isNewBook: function(newValue, oldValue) {
  60. }
  61. },
  62. created() {
  63. },
  64. mounted() {
  65. },
  66. methods: {
  67. handleDetails(index) {
  68. const params = {
  69. isbn: this.listData[index].isbn.replace(/\-/g, '')
  70. }
  71. getBookDetailsByISBN(params).then(res => {
  72. this.$refs.detailDom.dialogVisible = true
  73. if (res) {
  74. this.$refs.detailDom.bookData = res
  75. } else {
  76. this.$refs.detailDom.bookData = {
  77. srcUrl: this.listData[index].cover,
  78. bookName: this.listData[index].nbName,
  79. bookAuthor: this.listData[index].nbAuthor ? this.listData[index].nbAuthor : '暂无信息',
  80. gist: '暂无简介',
  81. Publish: '暂无信息',
  82. places: [
  83. { shelfName: '' }
  84. ]
  85. }
  86. }
  87. })
  88. }
  89. }
  90. }
  91. </script>
  92. <style lang="scss">
  93. @import "~@/assets/styles/index.scss";
  94. </style>