Browse Source

文献/阅读之星接口更新

master
xuhuajiao 1 month ago
parent
commit
656420f774
  1. 44
      src/views/lengingRanking/index.vue
  2. 162
      src/views/lengingRanking/index2.vue
  3. 47
      src/views/readStar/index.vue

44
src/views/lengingRanking/index.vue

@ -17,8 +17,8 @@
<img :src="item.cover" :onerror="defaultImg">
</div>
<div class="book-info">
<h4 class="title-item">{{ item.TITLE }}</h4>
<p>{{ item.AUTHOR }}</p>
<h4 class="title-item">{{ item.bookName }}</h4>
<p>{{ item.author }}</p>
</div>
<div class="ranking-num">
<svg v-if="index === 0" class="icon" aria-hidden="true">
@ -38,7 +38,7 @@
</template>
<script>
import { FetchBorrowRank, FetchCoverByISBN, FetchSync36 } from '@/api/library'
import { FetchBorrowRank, FetchCoverByISBN } from '@/api/library'
export default {
name: 'LengingRanking',
@ -60,7 +60,7 @@ export default {
}
},
created() {
this.getBookRanking()
this.getBorrowRank()
},
mounted() {
},
@ -68,42 +68,14 @@ export default {
getBorrowRank() {
FetchBorrowRank().then((res) => {
if (res.errCode === 0) {
this.rankingList = res.data
this.rankingList.forEach(item => {
this.getCoverByISBN(item.isbn.replace(/\-/g, ''), item)
})
} else {
this.$message.error('接口错误')
}
})
},
getBookRanking() {
const currentDate = new Date() //
currentDate.setDate(currentDate.getDate() - 30) // 30
const year = currentDate.getFullYear() //
const month = currentDate.getMonth() + 1 // 01
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 = res.data
data.forEach(item => {
this.getCoverByISBN(item.ISBN.replace(/\-/g, ''), item)
this.getCoverByISBN(item.isbn.replace(/\-/g, ''), item)
})
} else {
throw new Error('Failed' + this.libcode)
this.$message.error('接口错误')
}
}).catch(error => {
console.error('Error', error)
})
},
getCoverByISBN(isbn, item) {
@ -113,13 +85,13 @@ export default {
FetchCoverByISBN(params).then((res) => {
console.log('RES', res)
if (res) {
// item.cover = window.URL.createObjectURL(res)
item.cover = res
} else {
item.cover = ''
}
console.log(item.cover)
this.rankingList.push(item)
console.log('this.rankingList', this.rankingList)
this.$refs.listData.reset()
})
}

162
src/views/lengingRanking/index2.vue

@ -0,0 +1,162 @@
<template>
<!-- 借阅排行榜 -->
<div class="screen-item lending-ranking">
<div class="common-title">借阅排行榜</div>
<vue-seamless-scroll
ref="listData"
:data="rankingList"
:class-option="defaultOption"
class="big-module module-content"
>
<div
v-for="(item, index) in rankingList"
:key="index"
class="book-list-item"
>
<div class="book-img">
<img :src="item.cover" :onerror="defaultImg">
</div>
<div class="book-info">
<h4 class="title-item">{{ item.TITLE }}</h4>
<p>{{ item.AUTHOR }}</p>
</div>
<div class="ranking-num">
<svg v-if="index === 0" class="icon" aria-hidden="true">
<use xlink:href="#icon-a-no1" />
</svg>
<svg v-if="index === 1" class="icon" aria-hidden="true">
<use xlink:href="#icon-a-no21" />
</svg>
<svg v-if="index === 2" class="icon" aria-hidden="true">
<use xlink:href="#icon-a-no3" />
</svg>
<p>NO.{{ index + 1 }}</p>
</div>
</div>
</vue-seamless-scroll>
</div>
</template>
<script>
import { FetchBorrowRank, FetchCoverByISBN, FetchSync36 } from '@/api/library'
export default {
name: 'LengingRanking',
data() {
return {
defaultImg: 'this.src="' + require('@/assets/images/default-img.png') + '"',
rankingList: []
}
},
computed: {
defaultOption() {
return {
step: 1.1, //
hoverStop: false, // stop
singleHeight: 102, // (0) direction => 0/1
openWatch: true,
waitTime: 2000 // (1000ms)
}
}
},
created() {
this.getBookRanking()
},
mounted() {
},
methods: {
getBorrowRank() {
FetchBorrowRank().then((res) => {
if (res.errCode === 0) {
this.rankingList = res.data
this.rankingList.forEach(item => {
this.getCoverByISBN(item.isbn.replace(/\-/g, ''), item)
})
} else {
this.$message.error('接口错误')
}
})
},
formatDateTime(date, type) {
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
let timePart = '00:00:00'
if (type === 'end') {
timePart = '23:59:59'
}
return `${year}-${month}-${day} ${timePart}`
},
getBookRanking() {
// const currentDate = new Date() //
// currentDate.setDate(currentDate.getDate() - 30) // 30
// const year = currentDate.getFullYear() //
// const month = currentDate.getMonth() + 1 // 01
// 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
// }
//
const currentDate = new Date()
currentDate.setDate(currentDate.getDate() - 30) // 30
// YYYY-MM-DD 00:00:00
const startDate = encodeURIComponent(this.formatDateTime(currentDate, 'start'))
// YYYY-MM-DD 23:59:59
const endDate = encodeURIComponent(this.formatDateTime(new Date(), 'end'))
const params = {
'libcode': this.libcode,
'starttime': startDate,
'endtime': endDate,
'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) {
const params = {
isbn: isbn
}
FetchCoverByISBN(params).then((res) => {
console.log('RES', res)
if (res) {
item.cover = res
} else {
item.cover = ''
}
console.log(item.cover)
this.rankingList.push(item)
console.log('this.rankingList', this.rankingList)
this.$refs.listData.reset()
})
}
}
}
</script>
<style lang="scss">
@import '~@/assets/styles/index.scss';
</style>

47
src/views/readStar/index.vue

@ -14,7 +14,7 @@
<use xlink:href="#icon-a-3" />
</svg>
<span v-else class="star-num">{{ index+1 }}</span>
<p class="star-info title-item"> 读者{{ item.RDNAME }}上周借阅图书{{ item.TOTALNUM }}</p>
<p class="star-info title-item"> 读者{{ item.RDNAME }}近30天借阅图书{{ item.TOTALNUM }}</p>
<p class="star-date">{{ mondayDate }}</p>
</div>
</div>
@ -38,21 +38,52 @@ export default {
this.getReadRanking()
},
methods: {
formatDateTime(date, type) {
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
let timePart = '00:00:00'
if (type === 'end') {
timePart = '23:59:59'
}
return `${year}-${month}-${day} ${timePart}`
},
getReadRanking() {
const currentDate = new Date() //
// const currentDate = new Date() //
// currentDate.setDate(currentDate.getDate() - 30) // 30
// const year = currentDate.getFullYear() //
// const month = currentDate.getMonth() + 1 // 01
// 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': 6,
// 'nordtype': 'JXTSG_E'
// }
//
const currentDate = new Date()
currentDate.setDate(currentDate.getDate() - 30) // 30
const year = currentDate.getFullYear() //
const month = currentDate.getMonth() + 1 // 01
const day = currentDate.getDate() //
const formattedDate = `${year}-${month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day}`
// YYYY-MM-DD 00:00:00
const startDate = encodeURIComponent(this.formatDateTime(currentDate, 'start'))
// YYYY-MM-DD 23:59:59
const endDate = encodeURIComponent(this.formatDateTime(new Date(), 'end'))
const params = {
'libcode': this.libcode,
'starttime': formattedDate,
'endtime': this.getFormattedDate(new Date()),
'starttime': startDate,
'endtime': endDate,
'rownum': 6,
'nordtype': 'JXTSG_E'
}
FetchReadRanking(params).then(res => {
const result = JSON.parse(res.data)

Loading…
Cancel
Save