diff --git a/.env.production b/.env.production index 9cb3545..d7310a7 100644 --- a/.env.production +++ b/.env.production @@ -2,7 +2,7 @@ ENV = 'production' # 如果使用 Nginx 代理后端接口,那么此处需要改为 '/',文件查看 Docker 部署篇,Nginx 配置 # 接口地址,注意协议,如果你没有配置 ssl,需要将 https 改为 http -VUE_APP_BASE_API = 'http://172.22.0.23:8080' +VUE_APP_BASE_API = 'http://192.168.1.80:7070' # VUE_APP_BASE_API = 'http://127.0.0.1:8080' # 如果接口是 http 形式, wss 需要改为 ws -VUE_APP_WS_API = 'ws://172.22.0.23:7071' +VUE_APP_WS_API = 'ws://192.168.1.80:7071' diff --git a/package.json b/package.json index 00aba97..30f0cc2 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "jquery": "^3.7.1", "svg-sprite-loader": "^6.0.11", "TagCloud": "^2.5.0", + "video.js": "^8.16.1", "vue": "^2.6.11", "vue-awesome": "^4.0.2", "vue-count-to": "^1.0.13", diff --git a/src/components/echart/barEcharts.vue b/src/components/echart/barEcharts.vue index cf6d714..8716a8f 100644 --- a/src/components/echart/barEcharts.vue +++ b/src/components/echart/barEcharts.vue @@ -1,6 +1,6 @@ diff --git a/src/views/map/index.vue b/src/views/map/index.vue index 6c3bce8..ccf4ccb 100644 --- a/src/views/map/index.vue +++ b/src/views/map/index.vue @@ -47,7 +47,7 @@ -
+
@@ -131,29 +131,44 @@ export default { } }, beforeDestroy() { - window.removeEventListener('resize', this.resize) - clearTimeout(this.timeTicket) - clearInterval(this.rankInterval) - clearInterval(this.timer) - localStorage.setItem('libIndexItem', this.libIndex) - localStorage.setItem('libCurrentItem', this.libCurrent) - localStorage.setItem('countItem', this.count) - - this.rankInterval = null - this.timer = null - this.timeTicket = null + this.destroy() }, created() { - this.getLibBookTotal() + // this.getLibBookTotal() this.getReadRanking() this.getLendingTotal() }, activated() { this.getLibBookTotal() + if (this.rankingData.length !== 0) { + this.currentHover = -1 + this.rankInterval = setInterval(() => { + this.currentHover = (this.currentHover + 1) % this.rankingData.length + }, 1000) + } + this.$nextTick(() => { + window.addEventListener('resize', debounce(this.resize, 2000)) + }) + }, + deactivated() { + this.destroy() }, mounted() { }, methods: { + destroy() { + window.removeEventListener('resize', this.resize) + clearTimeout(this.timeTicket) + clearInterval(this.rankInterval) + clearInterval(this.timer) + localStorage.setItem('libIndexItem', this.libIndex) + localStorage.setItem('libCurrentItem', this.libCurrent) + localStorage.setItem('countItem', this.count) + + this.rankInterval = null + this.timer = null + this.timeTicket = null + }, startScrolling() { this.timer = setInterval(() => { this.position -= this.speed @@ -244,7 +259,6 @@ export default { this.getUserTotal() .then(userTotals => { - // console.log('userTotals', userTotals) userTotals.forEach(userTotal => { const libCode = Object.keys(userTotal)[0] const count = userTotal[libCode] @@ -348,7 +362,7 @@ export default { }).sort((a, b) => a.sort - b.sort) this.libInfoData = updatedLibraries - console.log('this.libInfoData', this.libInfoData) + // console.log('this.libInfoData', this.libInfoData) if (localStorage.getItem('countItem')) { this.count = parseInt(localStorage.getItem('countItem')) } else { diff --git a/src/views/pageFour/index.vue b/src/views/pageFour/index.vue index 3b3d4ff..cce2ae0 100644 --- a/src/views/pageFour/index.vue +++ b/src/views/pageFour/index.vue @@ -20,13 +20,15 @@ class="tsgz-video" width="100%" height="100%" - controls="controls" + controls + preload="auto" :src="item.cover" :poster="poster" autoplay type="video/mp4" muted @ended="playNextVideo(index)" + @loadedmetadata="playVideo" > 您的浏览器不支持 video 标签。 @@ -135,19 +137,24 @@ export default { computed: { }, beforeDestroy() { - clearInterval(this.rankInterval) - localStorage.setItem('videoIndex', this.videoIndex) - localStorage.setItem('videoCurrentTime', this.$refs.videos[this.videoIndex].currentTime) - localStorage.setItem('noticeIndex', this.noticeIndex) - this.$refs.videos[this.videoIndex].pause() + this.destroy() }, created() { - this.getVideoResource() this.getNotice() this.getBookRanking() }, activated() { + this.getVideoResource() this.load() + if (this.rankingData.length !== 0) { + this.currentHover = -1 + this.rankInterval = setInterval(() => { + this.currentHover = (this.currentHover + 1) % this.rankingData.length + }, 1000) + } + }, + deactivated() { + this.destroy() }, mounted() { // 二维码部分 @@ -166,11 +173,25 @@ export default { }, methods: { load() { - const video = this.$refs.videos - if (video) { - video.load() + const videos = this.$refs.videos + if (videos) { + videos[this.videoIndex].load() + videos[this.videoIndex].currentTime = localStorage.getItem('videoCurrentTime') ? localStorage.getItem('videoCurrentTime') : 0 + // videos[this.videoIndex].pause() + // setTimeout(() => { + // // videos[this.videoIndex].play() + // }, 2000) } }, + destroy() { + clearInterval(this.rankInterval) + localStorage.setItem('videoIndex', this.videoIndex) + localStorage.setItem('videoCurrentTime', this.$refs.videos[this.videoIndex].currentTime) + localStorage.setItem('noticeIndex', this.noticeIndex) + this.$refs.videos[this.videoIndex].pause() + + this.rankInterval = null + }, getInitData() { // wecharQrCode 二维码 用/downloadFile/+wecharQrCode const linkSrc = process.env.VUE_APP_BASE_API @@ -233,13 +254,18 @@ export default { setTimeout(() => { nextVideo.currentTime = localStorage.getItem('videoCurrentTime') ? localStorage.getItem('videoCurrentTime') : 0 nextVideo.play() - }, 1000) + }, 2000) }) } }).catch(error => { console.error('Error', error) }) }, + playVideo() { + this.$refs.videos[this.videoIndex].play().catch(error => { + console.error(error) + }) + }, setActiveItem(index) { this.$refs.carousel.setActiveItem(index) }, diff --git a/src/views/pageOne/index.vue b/src/views/pageOne/index.vue index 4f74dfe..317400c 100644 --- a/src/views/pageOne/index.vue +++ b/src/views/pageOne/index.vue @@ -242,7 +242,7 @@ export default { } }, async created() { - this.getInitData() + // this.getInitData() this.getMiddleAllData() this.getHotSearch() this.getNewBook() @@ -256,7 +256,8 @@ export default { this.getInitData() }, deactivated() { - + clearInterval(this.intervalLeft) + this.intervalLeft = null }, mounted() { if (localStorage.getItem('wecharQrCodeSrc')) { diff --git a/src/views/pageThree/index.vue b/src/views/pageThree/index.vue index ff6a2eb..0bd54cb 100644 --- a/src/views/pageThree/index.vue +++ b/src/views/pageThree/index.vue @@ -96,14 +96,14 @@
今日借阅趋势
-
+
近7日借阅统计
-
- +
+
@@ -161,11 +161,26 @@ export default { this.rankInterval = null }, created() { + + }, + activated() { this.getLendingTotal() this.getTodayJH() - this.getWeekJH() + // if (this.rankingYearWithPercentage.length !== 0) { + // this.currentHover = -1 + // this.rankInterval = setInterval(() => { + // this.currentHover = (this.currentHover + 1) % this.rankingYearWithPercentage.length + // }, 1000) + // } + }, + deactivated() { + clearInterval(this.rankInterval) + this.rankInterval = null }, mounted() { + // this.getLendingTotal() + // this.getTodayJH() + this.getWeekJH() }, methods: { paddingNum(num, length) { @@ -176,6 +191,8 @@ export default { }, // 获取本年今年借阅情况 getLendingTotal() { + this.todayTotal = [] + this.yearTotal = [] FetchLendingTotal().then(res => { const result = JSON.parse(res.data) if (result.success & result.resultlist.length !== 0) { @@ -212,6 +229,9 @@ export default { this.$parent.timedRefresh(this.todayTotal, 'todayTotal') this.$parent.timedRefresh(this.yearTotal, 'yearTotal') + + console.log('this.todayTotal', this.todayTotal) + console.log('this.yearTotal', this.yearTotal) } else { this.todayTotal = [] this.yearTotal = []