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

59 lines
1.4 KiB

<template>
<div id="bookshelf">
<!-- <HeaderTop /> -->
<!-- <div class="top-bg" /> -->
<div class="bookshelf-header" style="height:120px">
<router-link to="/">
<span class="icon iconfont icon-l">&#xe631;</span>
</router-link>
<h2>新书推荐</h2>
</div>
<BookList :bookdata="bookData" />
</div>
</template>
<script>
// import HeaderTop from '@/views/module/headerTop.vue'
import BookList from '@/views/module/bookList.vue'
import { FetchNewBookRecommend, FetchCoverByISBN } from '@/api/bookshelf'
export default {
name: 'NewBook',
components: { BookList },
data() {
return {
bookData: []
}
},
created() {
this.getBookData()
},
methods: {
async getBookData() {
const res = await FetchNewBookRecommend().then(res => {
console.log(res, 'res')
return res
}).catch(() => {
this.$message.error('接口错误')
})
await res.forEach(item => {
this.getCoverByISBN(item.isbn.replace(/\-/g, ''), item)
})
},
getCoverByISBN(isbn, item) {
const params = {
isbn: isbn
}
FetchCoverByISBN(params).then((res) => {
item.cover = window.URL.createObjectURL(res)
console.log(res, 'res')
this.bookData.push(item)
})
}
}
}
</script>
<style lang="scss" scoped>
@import "~@/assets/styles/index.scss";
</style>