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

58 lines
1.4 KiB

  1. <template>
  2. <div id="bookshelf">
  3. <!-- <HeaderTop /> -->
  4. <div class="bookshelf-header" style="height:120px">
  5. <router-link to="/">
  6. <span class="icon iconfont icon-l">&#xe631;</span>
  7. </router-link>
  8. <h2>热门图书</h2>
  9. </div>
  10. <BookList :bookdata="bookData" />
  11. </div>
  12. </template>
  13. <script>
  14. // import HeaderTop from '@/views/module/headerTop.vue'
  15. import BookList from '@/views/module/bookList.vue'
  16. import { FetchNewBookRecommend, FetchCoverByISBN } from '@/api/bookshelf'
  17. export default {
  18. name: 'NewBook',
  19. components: { BookList },
  20. data() {
  21. return {
  22. bookData: []
  23. }
  24. },
  25. created() {
  26. this.getBookData()
  27. },
  28. methods: {
  29. getBookData() {
  30. FetchNewBookRecommend().then(res => {
  31. console.log(res, 'res')
  32. let data = []
  33. data = res
  34. data.forEach(item => {
  35. this.getCoverByISBN(item.isbn.replace(/\-/g, ''), item)
  36. })
  37. }).catch(() => {
  38. this.$message.error('接口错误')
  39. })
  40. },
  41. getCoverByISBN(isbn, item) {
  42. const params = {
  43. isbn: isbn
  44. }
  45. FetchCoverByISBN(params).then((res) => {
  46. item.cover = window.URL.createObjectURL(res)
  47. this.bookData.push(item)
  48. })
  49. }
  50. }
  51. }
  52. </script>
  53. <style lang="scss" scoped>
  54. @import "~@/assets/styles/index.scss";
  55. </style>