Browse Source

获取首页书架基本信息

master
z_yu 2 years ago
parent
commit
942c7903cb
  1. 37
      src/views/index.vue

37
src/views/index.vue

@ -62,7 +62,6 @@
</template> </template>
<script> <script>
import data from './data'
import BookListItem from '@/views/module/bookListItem.vue' import BookListItem from '@/views/module/bookListItem.vue'
import { FetchNewBookRecommend, FetchCoverByISBN, initSmartBookshelf } from '@/api/bookshelf' import { FetchNewBookRecommend, FetchCoverByISBN, initSmartBookshelf } from '@/api/bookshelf'
export default { export default {
@ -72,7 +71,7 @@ export default {
}, },
data() { data() {
return { return {
shelfName: '',
shelfName: '1',
leftShelfMsg: '', leftShelfMsg: '',
rightShelfMsg: '', rightShelfMsg: '',
rackList: [], // rackList: [], //
@ -81,13 +80,11 @@ export default {
} }
}, },
created() { created() {
this.initSmartBookshelf()
this.getNewBookList() this.getNewBookList()
this.rackList = data.bookList.splice(0, 1)
this.otherList = data.bookList.splice(-2)
// +
this.initSmartBookshelf()
}, },
mounted() { mounted() {
}, },
methods: { methods: {
toPath(path) { toPath(path) {
@ -124,11 +121,37 @@ export default {
// //
initSmartBookshelf() { initSmartBookshelf() {
const params = { leftShelfNo: '1201-03-001-A-01', rightShelfNo: '1201-03-001-B-01' } const params = { leftShelfNo: '1201-03-001-A-01', rightShelfNo: '1201-03-001-B-01' }
// const _this = this
initSmartBookshelf(params).then((res) => { initSmartBookshelf(params).then((res) => {
console.log(res)
this.shelfName = res.shelfName this.shelfName = res.shelfName
this.leftShelfMsg = res.leftShelf.sortMsg this.leftShelfMsg = res.leftShelf.sortMsg
this.rightShelfMsg = res.rightShelf.sortMsg this.rightShelfMsg = res.rightShelf.sortMsg
Promise.all(this.initBookData(res.bookList.splice(0, 1))).then((res) => {
this.rackList = res
})
Promise.all(this.initBookData(res.bookList.splice(-2))).then((res) => {
this.otherList = res
})
})
},
initBookData(bookList) {
return bookList.map(async(item, index) => {
const newItem = {
ranking: item.bookUID,
nbName: item.bookName,
isOtherBook: index !== 0,
nbAuthor: item.bookAuthor,
isNewBook: false,
num: 0,
isbn: item.isbn
}
// return newItem
const params = {
isbn: item.isbn
}
const res = await FetchCoverByISBN(params)
newItem.cover = window.URL.createObjectURL(res)
return newItem
}) })
} }
} }

Loading…
Cancel
Save