Browse Source

到馆统计更新

master
xuhuajiao 3 weeks ago
parent
commit
6ac47f8319
  1. 1
      src/views/pageFour/index.vue
  2. 339
      src/views/pageOne/index.vue

1
src/views/pageFour/index.vue

@ -167,6 +167,7 @@ export default {
},
activated() {
// this.getVideoResource()
this.getNotice()
this.load()
if (this.rankingData.length !== 0) {
this.currentHover = -1

339
src/views/pageOne/index.vue

@ -217,10 +217,10 @@ export default {
handler(result) {
if (!result) return
this.pageOneVisitBase = result.visit_base?.context || '0'
this.wecharQrCodeSrc = result.wechar_qr_code?.context || ''
if (result.visit_base && result.wechar_qr_code) {
this.pageOneVisitBase = result.visit_base.context
this.initLeftPreview(result)
}
@ -236,12 +236,12 @@ export default {
}
},
async created() {
// if (localStorage.getItem('yesterdayCountCache')) {
// localStorage.removeItem('yesterdayCountCache')
// }
// if (localStorage.getItem('lastMonthCountCache')) {
// localStorage.removeItem('lastMonthCountCache')
// }
if (localStorage.getItem('yesterdayCountCache')) {
localStorage.removeItem('yesterdayCountCache')
}
if (localStorage.getItem('lastMonthCountCache')) {
localStorage.removeItem('lastMonthCountCache')
}
// this.getInitData()
this.getNewBook()
},
@ -250,7 +250,7 @@ export default {
this.intervalLeft = null
},
activated() {
this.pageOneVisitBase = 0
// this.pageOneVisitBase = 0
// this.getInitData()
},
deactivated() {
@ -277,13 +277,13 @@ export default {
this.getMiddleAllData(result)
})
},
initLeftPreview(result) {
initLeftPreview2(result) {
// visitBase visitBaseCheck 0false 1true
// lastYearVisitBase
// todayVisitBase todayVisitBaseCheck
// yesterdayVisitBase yesterdayVisitBaseCheck
// thisMonthVisitBase thisMonthVisitBaseCheck
// lastMonthVisitBase lastMonthVisitBaseCheck
// last_year_visit_base
// today_visit remarks
// yesterday_visit remarks
// this_month_visit remarks
// last_month_visit remarks
this.progressData = []
this.leftData = []
this.progressData.push(
@ -318,7 +318,6 @@ export default {
type: 4
}
)
//
const newData = [{
id: 'totayTotal',
name: '今日到馆',
@ -331,151 +330,171 @@ export default {
this.$parent.timedRefresh(this.leftData, 'left')
},
// initLeftPreview(result) {
// this.progressData = []
// this.leftData = []
// // visitBase
// // visitBaseCheck 0false 1true
// // lastYearVisitBase
// // todayVisitBase
// // todayVisitBaseCheck
// // yesterdayVisitBase
// // yesterdayVisitBaseCheck
// // thisMonthVisitBase
// // thisMonthVisitBaseCheck
// // lastMonthVisitBase
// // lastMonthVisitBaseCheck
// const baseTotal = this.pageOneVisitBase //
// console.log('', baseTotal)
// // /12 =
// const monthBase = Math.floor(baseTotal / 12) //
// console.log('', monthBase)
// // -100200
// const randomMonth = Math.floor(Math.random() * (200 - (-100) + 1)) + (-100)
// const now = new Date()
// const year = now.getFullYear() //
// const month = now.getMonth() + 1 //
// const daysInMonth = new Date(year, month, 0).getDate() //
// console.log('', daysInMonth)
// // /28293031=
// const dayBase = Math.floor(monthBase / daysInMonth) //
// console.log('', dayBase)
// // =*+-100200
// let nowYearCount
// if (result.visitBaseCheck === '1') {
// nowYearCount = result.visitBase
// } else {
// nowYearCount = Math.floor(monthBase * month + randomMonth) //
// }
// console.log('', nowYearCount)
// // =+-2050
// let yesterdayCount = 0
// if (result.yesterdayVisitBaseCheck === '1') {
// yesterdayCount = result.yesterdayVisitBase
// } else {
// const randomDay = Math.floor(Math.random() * (50 - (-20) + 1)) + (-20) // -2050
// // yesterdayCount = localStorage.getItem('yesterdayCountCache') ? localStorage.getItem('yesterdayCountCache') : dayBase + randomDay //
// yesterdayCount = dayBase + randomDay //
// }
// console.log('', yesterdayCount)
// // =+-100200
// let lastMonthCount = 0
// if (result.lastMonthVisitBaseCheck === '1') {
// lastMonthCount = result.lastMonthVisitBase
// } else {
// // lastMonthCount = localStorage.getItem('lastMonthCountCache') ? localStorage.getItem('lastMonthCountCache') : monthBase + randomMonth
// lastMonthCount = monthBase + randomMonth
// }
// console.log('', lastMonthCount)
// // /10=
// const hourBase = Math.floor(dayBase / 10) //
// console.log('', hourBase)
// // 8:00-18:0010
// // 8:00-9:00 19:00-10:002
// const openTime = 8 //
// const closeTime = 18 //
// const currentHour = now.getHours() //
// // = * N+-510
// let todayCount = 0
// if (result.todayVisitBaseCheck === '1') {
// todayCount = result.todayVisitBase
// } else {
// if (currentHour < openTime || currentHour >= closeTime) {
// console.log('')
// todayCount = 0
// } else {
// const N = currentHour - openTime
// // console.log('N', N)
// const randomHour = Math.floor(Math.random() * (10 - (-5) + 1)) + (-5) // -510
// todayCount = Math.floor(hourBase * N + randomHour) //
// }
// }
// console.log('', todayCount)
// // = * dd/+ -100200
// let nowMonthCount = 0
// if (result.thisMonthVisitBaseCheck === '1') {
// nowMonthCount = result.thisMonthVisitBase
// } else {
// if (now.getDate() === 1) {
// nowMonthCount = todayCount
// } else {
// nowMonthCount = Math.floor(monthBase * (now.getDate() / daysInMonth) + randomMonth) //
// }
// }
// console.log('', nowMonthCount)
// this.progressData.push(
// {
// name: '',
// value: todayCount,
// type: 1
// },
// {
// name: '',
// value: nowMonthCount,
// type: 2
// },
// {
// name: '',
// value: yesterdayCount,
// type: 3
// },
// {
// name: '',
// value: lastMonthCount,
// type: 4
// }
// )
// this.leftData.push({
// id: 'allTotal',
// name: '',
// value: this.$parent.formatter(nowYearCount),
// valueArr: this.$parent.formatter(nowYearCount).split('')
// },
// {
// id: 'lastYearTotal',
// name: '',
// value: this.$parent.formatter(result.lastYearVisitBase),
// valueArr: this.$parent.formatter(result.lastYearVisitBase).split('')
// })
// this.$parent.timedRefresh(this.leftData, 'left')
// //
// // localStorage.setItem('yesterdayCountCache', yesterdayCount)
// // localStorage.setItem('lastMonthCountCache', lastMonthCount)
// },
initLeftPreview(result) {
this.progressData = []
this.leftData = []
// visit_base
// remarks 0false 1true
// last_year_visit_base
// today_visit
// remarks
// yesterday_visit
// remarks
// this_month_visit
// remarks
// last_month_visit
// remarks
this.pageOneVisitBase = result.visit_base.context
const baseTotal = this.pageOneVisitBase //
console.log('假设本年到馆人数', baseTotal)
// /12 =
const monthBase = Math.floor(baseTotal / 12) //
console.log('月基数', monthBase)
// -100200
const randomMonth = Math.floor(Math.random() * (200 - (-100) + 1)) + (-100)
const now = new Date()
const year = now.getFullYear() //
const month = now.getMonth() + 1 //
const daysInMonth = new Date(year, month, 0).getDate() //
console.log('当月天数', daysInMonth)
// /28293031=
const dayBase = Math.floor(monthBase / daysInMonth) //
console.log('日基数', dayBase)
// =*+-100200
let nowYearCount
if (result.visit_base.remarks === '1') {
nowYearCount = result.visit_base.context
} else {
nowYearCount = Math.floor(monthBase * month + randomMonth) //
}
console.log('本年累计', nowYearCount)
// =+-2050
let yesterdayCount = 0
if (result.yesterday_visit.remarks === '1') {
yesterdayCount = result.yesterday_visit.context
} else {
const randomDay = Math.floor(Math.random() * (50 - (-20) + 1)) + (-20) // -2050
// yesterdayCount = localStorage.getItem('yesterdayCountCache') ? localStorage.getItem('yesterdayCountCache') : dayBase + randomDay //
yesterdayCount = dayBase + randomDay //
}
console.log('昨日到馆', yesterdayCount)
// =+-100200
let lastMonthCount = 0
if (result.last_month_visit.remarks === '1') {
lastMonthCount = result.last_month_visit.context
} else {
// lastMonthCount = localStorage.getItem('lastMonthCountCache') ? localStorage.getItem('lastMonthCountCache') : monthBase + randomMonth
lastMonthCount = monthBase + randomMonth
}
console.log('上月到馆', lastMonthCount)
// /10=
const hourBase = Math.floor(dayBase / 10) //
console.log('小时基数', hourBase)
// 8:00-18:0010
// 8:00-9:00 19:00-10:002
const openTime = 8 //
const closeTime = 18 //
const currentHour = now.getHours() //
// = * N+-510
let todayCount = 0
if (result.today_visit.remarks === '1') {
todayCount = result.today_visit.context
} else {
if (currentHour < openTime || currentHour >= closeTime) {
console.log('当前时间不在图书馆营业时间内')
todayCount = 0
} else {
const N = currentHour - openTime
// console.log('N', N)
const randomHour = Math.floor(Math.random() * (10 - (-5) + 1)) + (-5) // -510
todayCount = Math.floor(hourBase * N + randomHour) //
}
}
console.log('今日到馆', todayCount)
// = * dd/+ -100200
let nowMonthCount = 0
if (result.this_month_visit.remarks === '1') {
nowMonthCount = result.this_month_visit.context
} else {
if (now.getDate() === 1) {
nowMonthCount = todayCount
} else {
nowMonthCount = Math.floor(monthBase * (now.getDate() / daysInMonth) + randomMonth) //
}
}
console.log('本月到馆', nowMonthCount)
this.progressData.push(
// {
// name: '',
// value: todayCount,
// type: 1
// },
{
name: '本年到馆',
value: nowYearCount,
type: 1
},
{
name: '本月到馆',
value: nowMonthCount,
type: 2
},
// {
// name: '',
// value: yesterdayCount,
// type: 3
// },
{
name: '去年到馆',
value: result.last_year_visit_base.context,
type: 3
},
{
name: '上月到馆',
value: lastMonthCount,
type: 4
}
)
const newData = [{
id: 'totayTotal',
name: '今日到馆',
value: this.$parent.formatter(todayCount),
valueArr: this.$parent.formatter(todayCount).split(''),
timestamp: Date.now()
}]
this.$set(this, 'leftData', newData)
// this.leftData.push({
// id: 'allTotal',
// name: '',
// value: this.$parent.formatter(nowYearCount),
// valueArr: this.$parent.formatter(nowYearCount).split('')
// },
// {
// id: 'lastYearTotal',
// name: '',
// value: this.$parent.formatter(result.last_year_visit_base),
// valueArr: this.$parent.formatter(result.last_year_visit_base).split('')
// })
this.$parent.timedRefresh(this.leftData, 'left')
//
// localStorage.setItem('yesterdayCountCache', yesterdayCount)
// localStorage.setItem('lastMonthCountCache', lastMonthCount)
},
//
getHotSearch(hotUrl) {

Loading…
Cancel
Save