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

106 lines
3.0 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 linkSrc = process.env.NODE_ENV === 'production' ? window.g.ApiUrl : process.env.VUE_APP_BASE_API
  69. const params = {
  70. isbn: this.listData[index].isbn.replace(/\-/g, '')
  71. }
  72. getBookDetailsByISBN(params).then(res => {
  73. this.$refs.detailDom.dialogVisible = true
  74. if (res) {
  75. // this.$refs.detailDom.bookData = res
  76. console.log('res', res)
  77. Object.keys(res).forEach(key => {
  78. if (key === 'srcUrl' && res[key]) {
  79. res[key] = linkSrc + '/downloadFile' + res[key]
  80. }
  81. })
  82. this.$refs.detailDom.bookData = res
  83. console.log('ddd', this.$refs.detailDom.bookData)
  84. } else {
  85. this.$refs.detailDom.bookData = {
  86. srcUrl: this.listData[index].cover,
  87. bookName: this.listData[index].nbName,
  88. bookAuthor: this.listData[index].nbAuthor ? this.listData[index].nbAuthor : '暂无信息',
  89. gist: '暂无简介',
  90. Publish: '暂无信息',
  91. places: [
  92. { shelfName: '' }
  93. ]
  94. }
  95. }
  96. })
  97. }
  98. }
  99. }
  100. </script>
  101. <style lang="scss">
  102. @import "~@/assets/styles/index.scss";
  103. </style>