Browse Source

适配1440/页面优化

master
xuhuajiao 7 months ago
parent
commit
b32daeab69
  1. 117
      src/assets/styles/index.scss
  2. 7
      src/components/echart/barEcharts.vue
  3. 19
      src/components/echart/lineChart.vue
  4. 8
      src/components/echart/yearCircle.vue
  5. 55
      src/utils/resizeMixins.js
  6. 43
      src/views/map/index.vue
  7. 33
      src/views/pageThree/index.vue

117
src/assets/styles/index.scss

@ -1102,8 +1102,7 @@
overflow: hidden; overflow: hidden;
} }
.lib-text{ .lib-text{
position: absolute;
// transition: top 1s linear;
position: relative;
margin-right: .175rem; margin-right: .175rem;
font-size: .225rem; font-size: .225rem;
line-height: .35rem; line-height: .35rem;
@ -1111,6 +1110,22 @@
overflow: hidden; overflow: hidden;
} }
} }
.lib-animation {
animation: myLib 26s linear infinite;
animation-fill-mode: forwards;
}
@keyframes myLib {
0% {
transform: translateY(1rem);
}
100% {
transform: translateY(calc(-1 * var(--container-height)));
}
}
.map-hx-bg{ .map-hx-bg{
width: 16.325rem; width: 16.325rem;
height: 11.3125rem; height: 11.3125rem;
@ -1500,21 +1515,23 @@
text-indent: 2em; text-indent: 2em;
} }
} }
.scroll-animation {
}
}
.scroll-animation {
animation: myMove 16s linear infinite; animation: myMove 16s linear infinite;
animation-fill-mode: forwards; animation-fill-mode: forwards;
}
}
@keyframes myMove {
@keyframes myMove {
0% { 0% {
transform: translateY(1rem); transform: translateY(1rem);
} }
100% { 100% {
transform: translateY(calc(-1 * var(--container-height))); transform: translateY(calc(-1 * var(--container-height)));
} }
}
}
} }
.four-ranking{ .four-ranking{
height: 4.85rem; height: 4.85rem;
&.lending-ranking{ &.lending-ranking{
@ -1572,3 +1589,89 @@
text-align: center; text-align: center;
} }
} }
@media (max-width: 1440px) {
.pageOne-database{
margin-top: .375rem;
height: 6.5rem;
}
.pageOne-book {
.pageOne-book-content {
padding: .375rem 0;
.wechat-code{
width: 4.25rem;
height: 5.5rem;
.wechat-img{
width: 2.25rem;
height: 2.25rem;
line-height: 2.5rem;
}
span{
font-size: .275rem;
}
}
}
}
.scrollBox{
.seamless01{
margin-bottom: .5rem;
}
ul{
height: 2.3rem;
li{
width: 1.625rem;
height: 2.3rem;
margin-right: .7375rem;
.bord{
.book-img{
width: 1.625rem;
height: 2.3rem;
}
}
}
}
}
.page-three {
.three03,
.three04{
height: calc(100vh/2 - 1.375rem);
}
}
.four-video{
width: 16.625rem;
height: calc(100vh - 2.5rem);
background-size: 100% 100%;
}
.el-carousel__container{
height: calc(100vh - 4.5rem);
overflow: hidden;
}
.four-notice{
height: 4rem;
.seamless-warp{
height: 3.25rem;
}
}
.four-contact{
width: 5.9375rem;
height: 2.5rem;
background-size: 100% 100%;
.wechat-img{
width: 1.5rem;
height: 1.5rem;
}
span{
font-size: .275rem;
}
}
}

7
src/components/echart/barEcharts.vue

@ -1,6 +1,6 @@
<template> <template>
<!-- 近七日借阅统计 --> <!-- 近七日借阅统计 -->
<div id="main1" ref="chartContainer" :style="{height:height,width:width}" />
<div ref="barContainer" :style="{height:height,width:width}" />
</template> </template>
<script> <script>
@ -55,10 +55,11 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.initChart() this.initChart()
}) })
window.addEventListener('resize', this.__resizeHandler)
this.resetPieChartData() this.resetPieChartData()
}, },
methods: { methods: {
//
// bar
resetPieChartData() { resetPieChartData() {
clearInterval(this.timeRePie) clearInterval(this.timeRePie)
this.timeRePie = setInterval(() => { this.timeRePie = setInterval(() => {
@ -73,7 +74,7 @@ export default {
}, },
initChart() { initChart() {
// const dom = document.getElementById('main2') // const dom = document.getElementById('main2')
const dom = this.$refs.chartContainer
const dom = this.$refs.barContainer
this.chart = echarts.init(dom) this.chart = echarts.init(dom)
this.setOptions(this.chartWeeklyData) this.setOptions(this.chartWeeklyData)
}, },

19
src/components/echart/lineChart.vue

@ -1,5 +1,5 @@
<template> <template>
<div id="main2" ref="chartContainer" :style="{height:height,width:width}" />
<div ref="lineContainer" :style="{height:height,width:width}" />
</template> </template>
<script> <script>
@ -37,17 +37,11 @@ export default {
mmediate: true, mmediate: true,
handler(val) { handler(val) {
setTimeout(() => { setTimeout(() => {
this.setOptions(val)
this.initChart()
}, 100) }, 100)
} }
} }
}, },
mounted() {
this.$nextTick(() => {
this.initChart()
})
this.resetPiechartDayData()
},
beforeDestroy() { beforeDestroy() {
if (!this.chart) { if (!this.chart) {
return return
@ -55,6 +49,13 @@ export default {
this.chart.dispose() this.chart.dispose()
this.chart = null this.chart = null
}, },
mounted() {
this.$nextTick(() => {
this.initChart()
})
window.addEventListener('resize', this.__resizeHandler)
this.resetPiechartDayData()
},
methods: { methods: {
resetPiechartDayData() { resetPiechartDayData() {
clearInterval(this.timeRePie) clearInterval(this.timeRePie)
@ -70,7 +71,7 @@ export default {
}, },
initChart() { initChart() {
// const dom = document.getElementById('main2') // const dom = document.getElementById('main2')
const dom = this.$refs.chartContainer
const dom = this.$refs.lineContainer
this.chart = echarts.init(dom, 'dark') this.chart = echarts.init(dom, 'dark')
this.setOptions(this.chartDayData) this.setOptions(this.chartDayData)
}, },

8
src/components/echart/yearCircle.vue

@ -87,8 +87,12 @@ export default {
const count = arrCount(optionData) const count = arrCount(optionData)
if (optionData) { if (optionData) {
const flag = optionData?.find(item => name === item.name) const flag = optionData?.find(item => name === item.name)
if (flag) return [`{name|${name}}`, `{num|${((flag.value / count).toFixed(2)) * 100 + '%'}}`]
} else return name
if (flag) {
const percentage = count > 0 ? ((flag.value / count) * 100).toFixed(0) + '%' : '0%'
return [`{name|${name}}`, `{num|${percentage}}`]
}
}
return name
}, },
textStyle: { textStyle: {
rich: { rich: {

55
src/utils/resizeMixins.js

@ -1,26 +1,55 @@
// 混入代码 resize-mixins.js
import { debounce } from '@/utils/index'
const resizeChartMethod = '$__resizeChartMethod'
import { debounce } from '@/utils'
export default { export default {
data() { data() {
// 在组件内部将图表init的引用映射到chart属性上
return { return {
chart: null
$_sidebarElm: null,
$_resizeHandler: null
} }
}, },
created() {
window.addEventListener('resize', this[resizeChartMethod], false)
mounted() {
this.$_resizeHandler = debounce(() => {
if (this.chart) {
this.chart.resize()
}
}, 100)
this.$_initResizeEvent()
this.$_initSidebarResizeEvent()
}, },
beforeDestroy() { beforeDestroy() {
window.removeEventListener('reisze', this[resizeChartMethod])
this.$_destroyResizeEvent()
this.$_destroySidebarResizeEvent()
},
// to fixed bug when cached by keep-alive
// https://github.com/PanJiaChen/vue-element-admin/issues/2116
activated() {
this.$_initResizeEvent()
this.$_initSidebarResizeEvent()
},
deactivated() {
this.$_destroyResizeEvent()
this.$_destroySidebarResizeEvent()
}, },
methods: { methods: {
// 通过lodash的防抖函数来控制resize的频率
[resizeChartMethod]: debounce(function() {
if (this.chart) {
this.chart.resize()
// use $_ for mixins properties
// https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential
$_initResizeEvent() {
window.addEventListener('resize', this.$_resizeHandler)
},
$_destroyResizeEvent() {
window.removeEventListener('resize', this.$_resizeHandler)
},
$_sidebarResizeHandler(e) {
if (e.propertyName === 'width') {
this.$_resizeHandler()
}
},
$_initSidebarResizeEvent() {
this.$_sidebarElm = document.getElementsByClassName('sidebar-container')[0]
this.$_sidebarElm && this.$_sidebarElm.addEventListener('transitionend', this.$_sidebarResizeHandler)
},
$_destroySidebarResizeEvent() {
this.$_sidebarElm && this.$_sidebarElm.removeEventListener('transitionend', this.$_sidebarResizeHandler)
} }
}, 100)
} }
} }

43
src/views/map/index.vue

@ -42,7 +42,7 @@
</li> </li>
</ul> </ul>
<div ref="scrollInfo" class="scroll-container"> <div ref="scrollInfo" class="scroll-container">
<div ref="marquee" class="lib-text" :style="{ top: position + 'px' }">{{ libCurrent && libCurrent.explain }}</div>
<div ref="marquee" class="lib-text" v-html="libCurrent && libCurrent.explain" />
</div> </div>
</div> </div>
</div> </div>
@ -161,29 +161,42 @@ export default {
clearTimeout(this.timeTicket) clearTimeout(this.timeTicket)
clearInterval(this.rankInterval) clearInterval(this.rankInterval)
clearInterval(this.timer) clearInterval(this.timer)
localStorage.setItem('libIndexItem', this.libIndex)
localStorage.setItem('libCurrentItem', this.libCurrent)
// localStorage.setItem('libIndexItem', this.libIndex)
// localStorage.setItem('libCurrentItem', this.libCurrent)
localStorage.setItem('countItem', this.count) localStorage.setItem('countItem', this.count)
this.rankInterval = null this.rankInterval = null
this.timer = null this.timer = null
this.timeTicket = null this.timeTicket = null
}, },
// startScrolling() {
// this.timer = setInterval(() => {
// this.position -= this.speed
// //
// // const containerHeight = document.getElementsByClassName('scroll-container')[0].offsetHeight
// this.$nextTick(() => {
// const containerHeight = this.$refs.scrollInfo.offsetHeight
// const contentHeight = this.$refs.marquee.offsetHeight
// if (contentHeight <= containerHeight) {
// this.position = 20
// } else if (Math.abs(this.position) >= contentHeight) {
// this.position = containerHeight
// }
// })
// }, 120)
// },
startScrolling() { startScrolling() {
this.timer = setInterval(() => {
this.position -= this.speed
//
// const containerHeight = document.getElementsByClassName('scroll-container')[0].offsetHeight
this.$nextTick(() => { this.$nextTick(() => {
const containerHeight = this.$refs.scrollInfo.offsetHeight const containerHeight = this.$refs.scrollInfo.offsetHeight
const contentHeight = this.$refs.marquee.offsetHeight const contentHeight = this.$refs.marquee.offsetHeight
if (contentHeight <= containerHeight) {
this.position = 20
} else if (Math.abs(this.position) >= contentHeight) {
this.position = containerHeight
// CSS --container-height便 CSS 使
this.$refs.marquee.parentElement.style.setProperty('--container-height', `${contentHeight + 30}px`)
if (contentHeight > containerHeight) {
this.$refs.marquee.classList.add('lib-animation')
} else {
this.$refs.marquee.classList.remove('lib-animation')
} }
}) })
}, 40)
}, },
getReadRanking() { getReadRanking() {
const params = { const params = {
@ -372,12 +385,9 @@ export default {
this.initChart() // this.initChart() //
setTimeout(() => { setTimeout(() => {
this.updateChart() // this.updateChart() //
this.startScrolling()
window.addEventListener('resize', debounce(this.resize, 2000)) // 使 window.addEventListener('resize', debounce(this.resize, 2000)) // 使
}, 300) }, 300)
if (document.getElementsByClassName('scroll-container')[0]) {
this.startScrolling()
}
} }
} else { } else {
this.libInfoData = [] this.libInfoData = []
@ -945,6 +955,7 @@ export default {
console.log('_self.libCurrent', _self.libCurrent) console.log('_self.libCurrent', _self.libCurrent)
_self.updatePageWithData() _self.updatePageWithData()
_self.autohover() _self.autohover()
_self.startScrolling()
_self.currentIndex = 0 _self.currentIndex = 0
}, 3000) }, 3000)
} }

33
src/views/pageThree/index.vue

@ -96,14 +96,14 @@
</div> </div>
<div class="three-item three03"> <div class="three-item three03">
<div class="database-title">今日借阅趋势</div> <div class="database-title">今日借阅趋势</div>
<div class="chart-wrapper" style="width: 11.25rem;height: calc(100% - 35px);">
<div class="chart-wrapper" style="width: 11.25rem; height: calc(100% - 35px);">
<LineChart :chart-day-data="chartDayData" /> <LineChart :chart-day-data="chartDayData" />
</div> </div>
</div> </div>
<div class="three-item three04"> <div class="three-item three04">
<div class="database-title">近7日借阅统计</div> <div class="database-title">近7日借阅统计</div>
<div class="chart-wrapper" style="width: 11.25rem;height: calc(100% - 20px);">
<BarEcharts ref="weeklyRef" :chart-weekly-data="chartWeeklyData" />
<div class="chart-wrapper" style="width: 11.25rem; height: calc(100% - 20px);">
<BarEcharts :chart-weekly-data="chartWeeklyData" />
</div> </div>
</div> </div>
</div> </div>
@ -189,7 +189,7 @@ export default {
} }
return num return num
}, },
//
// /
getLendingTotal() { getLendingTotal() {
this.todayTotal = [] this.todayTotal = []
this.yearTotal = [] this.yearTotal = []
@ -297,13 +297,12 @@ export default {
// //
getTodayJH() { getTodayJH() {
FetchTodayJH().then(res => { FetchTodayJH().then(res => {
const result = res.data
if (result.length !== 0) {
this.chartDayData = { this.chartDayData = {
timeData: [], timeData: [],
returnData: [], returnData: [],
borrowedData: [] borrowedData: []
} }
const result = res.data
const time = ['07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00'] const time = ['07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00']
time.forEach((hour, index) => { time.forEach((hour, index) => {
// result logHour // result logHour
@ -320,21 +319,18 @@ export default {
this.chartDayData.borrowedData.push(0) // 0 this.chartDayData.borrowedData.push(0) // 0
} }
}) })
} else {
this.chartDayData = {
timeData: [],
returnData: [],
borrowedData: []
}
}
}).catch(error => { }).catch(error => {
console.error('Error', error) console.error('Error', error)
}) })
}, },
getWeekJH() { getWeekJH() {
FetchWeekJH().then(res => { FetchWeekJH().then(res => {
this.chartWeeklyData = {
date: [],
inchartWeeklyData: [],
outchartWeeklyData: []
}
const result = res.data const result = res.data
if (result.length !== 0) {
// //
const currentDate = new Date() const currentDate = new Date()
const today = currentDate.toISOString().slice(0, 10) const today = currentDate.toISOString().slice(0, 10)
@ -371,22 +367,15 @@ export default {
jccDayTotal: matchData[date] ? matchData[date].jccDayTotal : 0, jccDayTotal: matchData[date] ? matchData[date].jccDayTotal : 0,
hccDayTotal: matchData[date] ? matchData[date].hccDayTotal : 0 hccDayTotal: matchData[date] ? matchData[date].hccDayTotal : 0
})) }))
// //
completeData.sort((a, b) => new Date(a.date) - new Date(b.date)) completeData.sort((a, b) => new Date(a.date) - new Date(b.date))
// X // X
this.chartWeeklyData.date = completeData.map(item => item.date) this.chartWeeklyData.date = completeData.map(item => item.date)
// in // in
this.chartWeeklyData.inchartWeeklyData = completeData.map(item => item.hccDayTotal) this.chartWeeklyData.inchartWeeklyData = completeData.map(item => item.hccDayTotal)
// // out // // out
this.chartWeeklyData.outchartWeeklyData = completeData.map(item => item.jccDayTotal) this.chartWeeklyData.outchartWeeklyData = completeData.map(item => item.jccDayTotal)
} else {
this.chartWeeklyData = {
date: [],
inchartWeeklyData: [],
outchartWeeklyData: []
}
}
}).catch(error => { }).catch(error => {
console.error('Error', error) console.error('Error', error)
}) })

Loading…
Cancel
Save