Browse Source

大屏列表封面

master
xuhuajiao 2 years ago
parent
commit
0a5db6ca7e
  1. BIN
      src/assets/images/default-img.png
  2. 22
      src/views/lengingRanking/index.vue
  3. 9
      src/views/newBookRecommend/index.vue

BIN
src/assets/images/default-img.png

Before

Width: 66  |  Height: 83  |  Size: 6.8 KiB

After

Width: 66  |  Height: 83  |  Size: 4.2 KiB

22
src/views/lengingRanking/index.vue

@ -3,6 +3,7 @@
<div class="screen-item lending-ranking"> <div class="screen-item lending-ranking">
<div class="common-title">借阅排行榜</div> <div class="common-title">借阅排行榜</div>
<vue-seamless-scroll <vue-seamless-scroll
ref="listData"
:data="rankingList" :data="rankingList"
:class-option="defaultOption" :class-option="defaultOption"
class="big-module module-content" class="big-module module-content"
@ -13,7 +14,7 @@
class="book-list-item" class="book-list-item"
> >
<div class="book-img"> <div class="book-img">
<img :src="coverUrl" :onerror="defaultImg">
<img :src="item.cover" :onerror="defaultImg">
</div> </div>
<div class="book-info"> <div class="book-info">
<h4 class="title-item">{{ item.bookName }}</h4> <h4 class="title-item">{{ item.bookName }}</h4>
@ -44,42 +45,45 @@ export default {
data() { data() {
return { return {
defaultImg: 'this.src="' + require('@/assets/images/default-img.png') + '"', defaultImg: 'this.src="' + require('@/assets/images/default-img.png') + '"',
rankingList: [],
coverUrl: null
rankingList: []
} }
}, },
computed: { computed: {
defaultOption() { defaultOption() {
return { return {
step: 1.1, //
hoverStop: false, // stop hoverStop: false, // stop
singleHeight: 102 // (0) direction => 0/1
singleHeight: 102, // (0) direction => 0/1
openWatch: true,
waitTime: 2000 // (1000ms)
} }
} }
}, },
created() { created() {
this.getBorrowRank()
}, },
mounted() { mounted() {
this.getBorrowRank()
}, },
methods: { methods: {
getBorrowRank() { getBorrowRank() {
FetchBorrowRank().then((res) => { FetchBorrowRank().then((res) => {
if (res.errCode === 0) { if (res.errCode === 0) {
this.rankingList = res.data this.rankingList = res.data
res.data.forEach(item => {
this.getCoverByISBN(item.isbn.replace(/\-/g, ''))
this.rankingList.forEach(item => {
this.getCoverByISBN(item.isbn.replace(/\-/g, ''), item)
}) })
} else { } else {
this.$message.error('接口错误') this.$message.error('接口错误')
} }
}) })
}, },
getCoverByISBN(isbn) {
getCoverByISBN(isbn, item) {
const params = { const params = {
isbn: isbn isbn: isbn
} }
FetchCoverByISBN(params).then((res) => { FetchCoverByISBN(params).then((res) => {
this.coverUrl = window.URL.createObjectURL(res)
item.cover = window.URL.createObjectURL(res)
this.$refs.listData.reset()
}) })
} }
} }

9
src/views/newBookRecommend/index.vue

@ -47,7 +47,6 @@ export default {
return { return {
defaultImg: 'this.src="' + require('@/assets/images/default-img.png') + '"', defaultImg: 'this.src="' + require('@/assets/images/default-img.png') + '"',
rankingList: [], rankingList: [],
coverUrl: null,
swiperOptionThumbs: { swiperOptionThumbs: {
direction: 'vertical', direction: 'vertical',
autoplay: true, autoplay: true,
@ -74,20 +73,20 @@ export default {
FetchNewBookRecommend().then(res => { FetchNewBookRecommend().then(res => {
if (res.errCode === 0) { if (res.errCode === 0) {
this.rankingList = res.data this.rankingList = res.data
res.data.forEach(item => {
this.getCoverByISBN(item.isbn.replace(/\-/g, ''))
this.rankingList.forEach(item => {
this.getCoverByISBN(item.isbn.replace(/\-/g, ''), item)
}) })
} else { } else {
this.$message.error('接口错误') this.$message.error('接口错误')
} }
}) })
}, },
getCoverByISBN(isbn) {
getCoverByISBN(isbn, item) {
const params = { const params = {
isbn: isbn isbn: isbn
} }
FetchCoverByISBN(params).then((res) => { FetchCoverByISBN(params).then((res) => {
this.coverUrl = window.URL.createObjectURL(res)
item.cover = window.URL.createObjectURL(res)
}) })
} }
} }

Loading…
Cancel
Save