|
|
@ -242,6 +242,12 @@ export default { |
|
|
|
} |
|
|
|
}, |
|
|
|
async created() { |
|
|
|
if (localStorage.getItem('yesterdayCountCache')) { |
|
|
|
localStorage.removeItem('yesterdayCountCache') |
|
|
|
} |
|
|
|
if (localStorage.getItem('lastMonthCountCache')) { |
|
|
|
localStorage.removeItem('lastMonthCountCache') |
|
|
|
} |
|
|
|
// this.getInitData() |
|
|
|
this.getMiddleAllData() |
|
|
|
this.getHotSearch() |
|
|
@ -269,7 +275,8 @@ export default { |
|
|
|
// visitBase 本年到馆基础数 |
|
|
|
// wecharQrCode 二维码 用/downloadFile/+wecharQrCode |
|
|
|
// iNotice 公告 |
|
|
|
const linkSrc = process.env.VUE_APP_BASE_API |
|
|
|
const linkSrc = process.env.NODE_ENV === 'production' ? window.g.ApiUrl : process.env.VUE_APP_BASE_API |
|
|
|
console.log('linkSrc', linkSrc) |
|
|
|
FetchInitSetting().then(res => { |
|
|
|
const result = JSON.parse(res.data) |
|
|
|
this.pageOneVisitBase = result.visitBase |
|
|
@ -302,10 +309,10 @@ export default { |
|
|
|
// lastMonthVisitBaseCheck 是否显示 |
|
|
|
|
|
|
|
const baseTotal = this.pageOneVisitBase // 本年到馆人数 |
|
|
|
// console.log('假设本年到馆人数', baseTotal) |
|
|
|
console.log('假设本年到馆人数', baseTotal) |
|
|
|
// 本年到馆/12个月 = 月基数 |
|
|
|
const monthBase = Math.floor(baseTotal / 12) // 月基数 |
|
|
|
// console.log('月基数', monthBase) |
|
|
|
console.log('月基数', monthBase) |
|
|
|
// 月随机数(-100到200之间) |
|
|
|
const randomMonth = Math.floor(Math.random() * (200 - (-100) + 1)) + (-100) |
|
|
|
|
|
|
@ -313,10 +320,10 @@ export default { |
|
|
|
const year = now.getFullYear() // 当前年份 |
|
|
|
const month = now.getMonth() + 1 // 当前月份 |
|
|
|
const daysInMonth = new Date(year, month, 0).getDate() // 当月天数 |
|
|
|
// console.log('当月天数', daysInMonth) |
|
|
|
console.log('当月天数', daysInMonth) |
|
|
|
// 月基数/当月天数(28、29、30、31)= 日基数 |
|
|
|
const dayBase = Math.floor(monthBase / daysInMonth) // 日基数 |
|
|
|
// console.log('日基数', dayBase) |
|
|
|
console.log('日基数', dayBase) |
|
|
|
// 本年累计=月基数*月份+月随机数(-100到200之间) |
|
|
|
let nowYearCount |
|
|
|
if (result.visitBaseCheck === '1') { |
|
|
@ -324,28 +331,30 @@ export default { |
|
|
|
} else { |
|
|
|
nowYearCount = Math.floor(monthBase * month + randomMonth) // 本年累计 |
|
|
|
} |
|
|
|
// console.log('本年累计', nowYearCount) |
|
|
|
console.log('本年累计', nowYearCount) |
|
|
|
// 昨日到馆=日基数+日随机数(-20到50之间) |
|
|
|
let yesterdayCount = 0 |
|
|
|
if (result.yesterdayVisitBaseCheck === '1') { |
|
|
|
yesterdayCount = result.yesterdayVisitBase |
|
|
|
} else { |
|
|
|
const randomDay = Math.floor(Math.random() * (50 - (-20) + 1)) + (-20) // 日随机数(-20到50之间) |
|
|
|
yesterdayCount = localStorage.getItem('yesterdayCountCache') ? localStorage.getItem('yesterdayCountCache') : dayBase + randomDay // 昨日到馆 |
|
|
|
// yesterdayCount = localStorage.getItem('yesterdayCountCache') ? localStorage.getItem('yesterdayCountCache') : dayBase + randomDay // 昨日到馆 |
|
|
|
yesterdayCount = dayBase + randomDay // 昨日到馆 |
|
|
|
} |
|
|
|
// console.log('昨日到馆', yesterdayCount) |
|
|
|
console.log('昨日到馆', yesterdayCount) |
|
|
|
// 上月到馆=月基数+月随机数(-100到200之间) |
|
|
|
let lastMonthCount = 0 |
|
|
|
if (result.lastMonthVisitBaseCheck === '1') { |
|
|
|
lastMonthCount = result.lastMonthVisitBase |
|
|
|
} else { |
|
|
|
lastMonthCount = localStorage.getItem('lastMonthCountCache') ? localStorage.getItem('lastMonthCountCache') : monthBase + randomMonth |
|
|
|
// lastMonthCount = localStorage.getItem('lastMonthCountCache') ? localStorage.getItem('lastMonthCountCache') : monthBase + randomMonth |
|
|
|
lastMonthCount = monthBase + randomMonth |
|
|
|
} |
|
|
|
// console.log('上月到馆', lastMonthCount) |
|
|
|
console.log('上月到馆', lastMonthCount) |
|
|
|
|
|
|
|
// 日基数/10小时=小时基数 |
|
|
|
const hourBase = Math.floor(dayBase / 10) // 小时基数 |
|
|
|
// console.log('小时基数', hourBase) |
|
|
|
console.log('小时基数', hourBase) |
|
|
|
// 图书馆营业时间(8:00-18:00共10小时) |
|
|
|
// 8:00-9:00 算第1个小时、9:00-10:00算第2个小时、以此类推 |
|
|
|
const openTime = 8 // 开门时间 |
|
|
@ -367,15 +376,19 @@ export default { |
|
|
|
todayCount = Math.floor(hourBase * N + randomHour) // 今日到馆 |
|
|
|
} |
|
|
|
} |
|
|
|
// console.log('今日到馆', todayCount) |
|
|
|
console.log('今日到馆', todayCount) |
|
|
|
// 本月到馆=月基数 * (当前月的日期dd/当前月的天数)+ 月随机数(-100到200之间) |
|
|
|
let nowMonthCount = 0 |
|
|
|
if (result.thisMonthVisitBaseCheck === '1') { |
|
|
|
nowMonthCount = result.thisMonthVisitBase |
|
|
|
} else { |
|
|
|
nowMonthCount = Math.floor(monthBase * (now.getDate() / daysInMonth) + randomMonth) // 本月到馆 |
|
|
|
if (now.getDate() === 1) { |
|
|
|
nowMonthCount = todayCount |
|
|
|
} else { |
|
|
|
nowMonthCount = Math.floor(monthBase * (now.getDate() / daysInMonth) + randomMonth) // 本月到馆 |
|
|
|
} |
|
|
|
} |
|
|
|
// console.log('本月到馆', nowMonthCount) |
|
|
|
console.log('本月到馆', nowMonthCount) |
|
|
|
|
|
|
|
this.progressData.push( |
|
|
|
{ |
|
|
@ -416,8 +429,8 @@ export default { |
|
|
|
this.$parent.timedRefresh(this.leftData, 'left') |
|
|
|
|
|
|
|
// 昨日到馆、上月到馆存一个缓存!当前第一次计算好之后就不变了! |
|
|
|
localStorage.setItem('yesterdayCountCache', yesterdayCount) |
|
|
|
localStorage.setItem('lastMonthCountCache', lastMonthCount) |
|
|
|
// localStorage.setItem('yesterdayCountCache', yesterdayCount) |
|
|
|
// localStorage.setItem('lastMonthCountCache', lastMonthCount) |
|
|
|
}, |
|
|
|
|
|
|
|
// 热门搜索 |
|
|
@ -553,7 +566,7 @@ export default { |
|
|
|
} |
|
|
|
FetchNewBook(params).then(res => { |
|
|
|
// 图片地址格式 http://192.168.99.67:8080/downloadFile/qytsg/ae281b90-b100-4541-9379-3e104854652c.png |
|
|
|
const linkSrc = process.env.VUE_APP_BASE_API |
|
|
|
const linkSrc = process.env.NODE_ENV === 'production' ? window.g.ApiUrl : process.env.VUE_APP_BASE_API |
|
|
|
this.newList = res.data.map(item => { |
|
|
|
if (item.nbImgPath) { |
|
|
|
item.nbImgPath = linkSrc + '/downloadFile' + item.nbImgPath |
|
|
|