|
@ -17,8 +17,8 @@ |
|
|
<img :src="item.cover" :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> |
|
|
|
|
|
<p>{{ item.author }}</p> |
|
|
|
|
|
|
|
|
<h4 class="title-item">{{ item.TITLE }}</h4> |
|
|
|
|
|
<p>{{ item.AUTHOR }}</p> |
|
|
</div> |
|
|
</div> |
|
|
<div class="ranking-num"> |
|
|
<div class="ranking-num"> |
|
|
<svg v-if="index === 0" class="icon" aria-hidden="true"> |
|
|
<svg v-if="index === 0" class="icon" aria-hidden="true"> |
|
@ -38,7 +38,7 @@ |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import { FetchBorrowRank, FetchCoverByISBN } from '@/api/library' |
|
|
|
|
|
|
|
|
import { FetchBorrowRank, FetchCoverByISBN, FetchSync36 } from '@/api/library' |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
name: 'LengingRanking', |
|
|
name: 'LengingRanking', |
|
@ -60,7 +60,7 @@ export default { |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
created() { |
|
|
created() { |
|
|
this.getBorrowRank() |
|
|
|
|
|
|
|
|
this.getBookRanking() |
|
|
}, |
|
|
}, |
|
|
mounted() { |
|
|
mounted() { |
|
|
}, |
|
|
}, |
|
@ -77,6 +77,35 @@ export default { |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
getBookRanking() { |
|
|
|
|
|
const currentDate = new Date() // 获取当前日期 |
|
|
|
|
|
currentDate.setDate(currentDate.getDate() - 30) // 将当前日期减去30天 |
|
|
|
|
|
const year = currentDate.getFullYear() // 获取年份 |
|
|
|
|
|
const month = currentDate.getMonth() + 1 // 获取月份(注意月份从0开始,需要加1) |
|
|
|
|
|
const day = currentDate.getDate() // 获取日期 |
|
|
|
|
|
const formattedDate = `${year}-${month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day}` |
|
|
|
|
|
|
|
|
|
|
|
const params = { |
|
|
|
|
|
'libcode': this.libcode, |
|
|
|
|
|
'starttime': formattedDate, |
|
|
|
|
|
'endtime': this.getFormattedDate(new Date()), |
|
|
|
|
|
'rownum': 10 |
|
|
|
|
|
} |
|
|
|
|
|
FetchSync36(params).then(res => { |
|
|
|
|
|
const result = JSON.parse(res.data) |
|
|
|
|
|
if (result.success && result.resultlist.length > 0) { |
|
|
|
|
|
let data = [] |
|
|
|
|
|
data = result.resultlist.sort((a, b) => b.TOTALNUM - a.TOTALNUM).slice(0, 10) |
|
|
|
|
|
data.forEach(item => { |
|
|
|
|
|
this.getCoverByISBN(item.ISBN.replace(/\-/g, ''), item) |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
throw new Error('Failed' + this.libcode) |
|
|
|
|
|
} |
|
|
|
|
|
}).catch(error => { |
|
|
|
|
|
console.error('Error', error) |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
getCoverByISBN(isbn, item) { |
|
|
getCoverByISBN(isbn, item) { |
|
|
const params = { |
|
|
const params = { |
|
|
isbn: isbn |
|
|
isbn: isbn |
|
@ -84,12 +113,13 @@ export default { |
|
|
FetchCoverByISBN(params).then((res) => { |
|
|
FetchCoverByISBN(params).then((res) => { |
|
|
console.log('RES', res) |
|
|
console.log('RES', res) |
|
|
if (res) { |
|
|
if (res) { |
|
|
// item.cover = window.URL.createObjectURL(res) |
|
|
|
|
|
item.cover = res |
|
|
item.cover = res |
|
|
} else { |
|
|
} else { |
|
|
item.cover = '' |
|
|
item.cover = '' |
|
|
} |
|
|
} |
|
|
console.log(item.cover) |
|
|
console.log(item.cover) |
|
|
|
|
|
this.rankingList.push(item) |
|
|
|
|
|
console.log('this.rankingList', this.rankingList) |
|
|
this.$refs.listData.reset() |
|
|
this.$refs.listData.reset() |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|