|
@ -14,7 +14,7 @@ |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<ul class="hotbook-list"> |
|
|
<ul class="hotbook-list"> |
|
|
<li v-for="(item,index) in bookList" :key="index" @click="handleDetails(index)"> |
|
|
|
|
|
|
|
|
<li v-for="(item,index) in bookList" :key="index" @click="handleDetails(index+1)"> |
|
|
<img :src="item.cover ? item.cover : ''" :onerror="defaultImg"> |
|
|
<img :src="item.cover ? item.cover : ''" :onerror="defaultImg"> |
|
|
<p class="book-name">{{ item.nbName }}</p> |
|
|
<p class="book-name">{{ item.nbName }}</p> |
|
|
</li> |
|
|
</li> |
|
@ -25,6 +25,7 @@ |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import BookDetails from './bookDetails.vue' |
|
|
import BookDetails from './bookDetails.vue' |
|
|
|
|
|
import { getBookDetailsByISBN, FetchCoverByISBN } from '@/api/bookshelf' |
|
|
export default { |
|
|
export default { |
|
|
name: 'BookList', |
|
|
name: 'BookList', |
|
|
components: { BookDetails }, |
|
|
components: { BookDetails }, |
|
@ -49,9 +50,26 @@ export default { |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
handleDetails(index) { |
|
|
handleDetails(index) { |
|
|
this.$refs.detailDom.bookData = this.bookdata[index] |
|
|
|
|
|
|
|
|
console.log(this.bookdata[index]) |
|
|
|
|
|
const params = { |
|
|
|
|
|
isbn: this.bookdata[index].isbn.replace(/\-/g, '') |
|
|
|
|
|
} |
|
|
|
|
|
console.log(params) |
|
|
|
|
|
getBookDetailsByISBN(params).then(res => { |
|
|
|
|
|
console.log(res, '详情') |
|
|
|
|
|
this.$refs.detailDom.bookData = res |
|
|
this.$refs.detailDom.dialogVisible = true |
|
|
this.$refs.detailDom.dialogVisible = true |
|
|
console.log(this.bookdata[0]) |
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
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) |
|
|
|
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|