祁阳图书馆智慧大屏
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.3 KiB

  1. <template>
  2. <!-- 新书推荐 -->
  3. <div class="screen-item read-star">
  4. <div class="common-title">阅读之星</div>
  5. <div ref="starList" class="medium-module module-content">
  6. <div v-for="(item,index) in readstarList" :key="index" :class="['readstart-item', {'star1-bg':index === 0}, {'star2-bg':index === 1}, {'star3-bg':index === 2}]">
  7. <svg v-if="index === 0" class="icon icon-star-1" aria-hidden="true">
  8. <use xlink:href="#icon-a-1" />
  9. </svg>
  10. <svg v-else-if="index === 1" class="icon icon-star-2" aria-hidden="true">
  11. <use xlink:href="#icon-a-21" />
  12. </svg>
  13. <svg v-else-if="index === 2" class="icon icon-star-3" aria-hidden="true">
  14. <use xlink:href="#icon-a-3" />
  15. </svg>
  16. <span v-else class="star-num">{{ index+1 }}</span>
  17. <p class="star-info title-item"> 读者{{ item.readerName }}上周借阅图书{{ item.borrowNum }}</p>
  18. <p class="star-date">{{ mondayDate }}</p>
  19. </div>
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. import { FetchBorrowStar } from '@/api/library'
  25. import { parseTime } from '@/utils/index.js'
  26. export default {
  27. name: 'ReadStar',
  28. data() {
  29. return {
  30. readstarList: [],
  31. mondayDate: null
  32. }
  33. },
  34. created() {
  35. },
  36. mounted() {
  37. this.getBorrowStar()
  38. },
  39. methods: {
  40. // 获取list
  41. getBorrowStar() {
  42. FetchBorrowStar().then(res => {
  43. if (res.errCode === 0) {
  44. console.log(res)
  45. this.readstarList = res.data
  46. this.getMondayTime()
  47. } else {
  48. this.$message.error('接口错误')
  49. }
  50. })
  51. },
  52. // 获取本周一
  53. getMondayTime() {
  54. const today = new Date()
  55. const year = today.getFullYear()
  56. const month = today.getMonth() + 1
  57. const day = today.getDate()
  58. const newDate = new Date(year + '-' + month + '-' + day + ' 00:00:00')
  59. const nowTime = newDate.getTime()
  60. const weekDay = newDate.getDay()
  61. const oneDayTime = 24 * 60 * 60 * 1000
  62. const mondayTime = (1 - weekDay) * oneDayTime + nowTime
  63. this.mondayDate = parseTime(mondayTime, '{y}-{m}-{d}')
  64. }
  65. }
  66. }
  67. </script>
  68. <style lang="scss">
  69. @import "~@/assets/styles/index.scss";
  70. </style>