Browse Source

公告需求更新

master
xuhuajiao 1 month ago
parent
commit
3c52a56c61
  1. 46
      src/assets/styles/index.scss
  2. 225
      src/views/notice/index.vue
  3. 28
      src/views/readStar/index-height.vue
  4. 28
      src/views/readStar/index.vue
  5. 16
      src/views/video/index.vue

46
src/assets/styles/index.scss

@ -305,6 +305,40 @@
} }
} }
// 通知公告
// .notice{
// .module-content{
// display: flex;
// justify-content: space-between;
// width: 100%;
// padding: 0.25rem 0.375rem 0.5rem 0.375rem;
// .notice-icon-gif{
// display: block;
// width: 2.375rem;
// height: 2.875rem;
// background: url('~@/assets/images/notice.gif') no-repeat left top;
// background-size: contain;
// margin-right: 0.15rem;
// }
// .seamless-warp{
// width: calc(100vw);
// height: 3.1rem;
// overflow: hidden;
// .notice-txt {
// animation: myMove 20s linear infinite;
// animation-fill-mode: forwards;
// }
// @keyframes myMove {
// 0% {
// transform: translateY(2rem);
// }
// 100% {
// transform: translateY(-6rem);
// }
// }
// }
// }
// }
// 通知公告 // 通知公告
.notice{ .notice{
.module-content{ .module-content{
@ -324,18 +358,6 @@
width: calc(100vw); width: calc(100vw);
height: 3.1rem; height: 3.1rem;
overflow: hidden; overflow: hidden;
.notice-txt {
animation: myMove 20s linear infinite;
animation-fill-mode: forwards;
}
@keyframes myMove {
0% {
transform: translateY(2rem);
}
100% {
transform: translateY(-6rem);
}
}
} }
} }
} }

225
src/views/notice/index.vue

@ -1,73 +1,152 @@
<template>
<!-- 通知公告 -->
<div class="screen-item notice">
<div class="common-title">通知公告</div>
<div class="small-module module-content">
<span class="notice-icon-gif" />
<div class="seamless-warp">
<div class="notice-txt" v-html="content" />
</div>
<!-- <vue-seamless-scroll :data="noticeData" :class-option="defaultOption" class="seamless-warp">
<p v-for="(item,index) in noticeData" :key="index"> {{ item.des }}</p>
</vue-seamless-scroll> -->
</div>
</div>
</template>
<script>
import { FetchInitNotice } from '@/api/library'
export default {
name: 'Notice',
data() {
return {
noticeData: [],
content: ''
}
},
computed: {
defaultOption() {
return {
step: 0.3, //
limitMoveNum: 1, //
hoverStop: false, // stop
direction: 1, // 0 1 2 3
openWatch: true // dom
}
}
},
created() {
},
mounted() {
this.getInitNotice()
},
methods: {
//
escapeHtml(str) {
var arrEntities = {
'lt': '<',
'gt': '>',
'nbsp': ' ',
'amp': '&',
'quot': '"'
}
return str.replace(/&(lt|gt|nbsp|amp|quot|pre);/ig, function(all, t) {
return arrEntities[t]
})
},
getInitNotice() {
FetchInitNotice().then((res) => {
if (res.errCode === 0) {
this.content = this.escapeHtml(res.data)
} else {
this.$message.error('接口错误')
}
})
}
}
}
</script>
<style lang="scss">
@import "~@/assets/styles/index.scss";
</style>
<template>
<!-- 通知公告 -->
<div class="screen-item notice">
<div class="common-title">通知公告</div>
<div class="small-module module-content">
<span class="notice-icon-gif" />
<!-- 核心给容器加固定宽度避免宽度溢出导致滚动失效 -->
<div ref="box" class="seamless-warp">
<div ref="text" class="notice-txt" v-html="content" />
</div>
</div>
</div>
</template>
<script>
import { FetchInitNotice } from '@/api/library'
export default {
name: 'Notice',
data() {
return {
content: '',
scrollTimer: null, //
transitionTimer: null, //
boxH: 0, //
textH: 0, //
duration: 40000 //
}
},
mounted() {
this.getInitNotice()
},
beforeDestroy() {
//
if (this.scrollTimer) clearInterval(this.scrollTimer)
if (this.transitionTimer) clearTimeout(this.transitionTimer)
},
methods: {
escapeHtml(str) {
if (!str) return ''
var arrEntities = {
'lt': '<',
'gt': '>',
'nbsp': ' ',
'amp': '&',
'quot': '"'
}
return str.replace(/&(lt|gt|nbsp|amp|quot);/ig, (all, t) => arrEntities[t])
.replace(/<pre>|<\/pre>/gi, '')
.replace(/\\r\\n/g, '') //
},
getInitNotice() {
FetchInitNotice().then(res => {
if (res.errCode === 0) {
this.content = this.escapeHtml(res.data)
// DOM
this.$nextTick(() => {
this.startScroll()
})
}
}).catch(err => {
console.log('接口请求失败:', err)
})
},
startScroll() {
const box = this.$refs.box
const text = this.$refs.text
// DOM
console.log('容器DOM:', box)
console.log('内容DOM:', text)
if (!box || !text) {
console.log('DOM未获取到,滚动启动失败')
return
}
// rem
this.boxH = box.clientHeight || parseInt(getComputedStyle(box).height)
this.textH = text.offsetHeight || parseInt(getComputedStyle(text).height)
console.log('容器高度:', this.boxH, '内容高度:', this.textH)
//
if (this.textH <= this.boxH) {
console.log('内容高度小于容器,无需滚动')
return
}
//
text.style.position = 'absolute'
text.style.top = '0px'
text.style.left = '0px'
text.style.width = '100%'
text.style.transition = 'none'
//
text.addEventListener('transitionend', this.handleTransitionEnd)
//
this.rollToBottom()
},
//
rollToBottom() {
const text = this.$refs.text
//
text.style.transition = 'none'
text.style.top = '0px'
//
setTimeout(() => {
text.style.transition = `top ${this.duration}ms linear`
text.style.top = `-${this.textH - this.boxH}px`
}, 100)
},
//
handleTransitionEnd() {
// const text = this.$refs.text
//
if (this.transitionTimer) clearTimeout(this.transitionTimer)
// 2
this.transitionTimer = setTimeout(() => {
this.rollToBottom()
}, 2000) // 2000 = 2
}
}
}
</script>
<style lang="scss">
@import "~@/assets/styles/index.scss";
.notice .module-content {
position: relative;
}
.notice .seamless-warp {
position: relative !important;
overflow: hidden !important;
height: 3.1rem !important;
}
.notice-txt table {
width: 100% !important;
border-collapse: collapse !important;
}
.notice-txt td {
word-break: break-all !important;
}
</style>

28
src/views/readStar/index-height.vue

@ -128,19 +128,21 @@ export default {
} }
FetchReadRanking(params).then(res => { FetchReadRanking(params).then(res => {
const result = JSON.parse(res.data)
if (result.success && result.resultlist.length > 0) {
this.readstarList = result.resultlist.sort((a, b) => b.TOTALNUM - a.TOTALNUM).slice(0, 10)
// this.rankingDataComputed()
// this.rankInterval = setInterval(() => {
// this.currentHover = (this.currentHover + 1) % this.rankingData.length
// }, 1000)
console.log('this.readstarList', this.readstarList)
this.getMondayDate()
} else {
throw new Error('Failed' + this.libcode)
if (res.data !== null) {
const result = JSON.parse(res.data)
if (result.success && result.resultlist.length > 0) {
this.readstarList = result.resultlist.sort((a, b) => b.TOTALNUM - a.TOTALNUM).slice(0, 10)
// this.rankingDataComputed()
// this.rankInterval = setInterval(() => {
// this.currentHover = (this.currentHover + 1) % this.rankingData.length
// }, 1000)
console.log('this.readstarList', this.readstarList)
this.getMondayDate()
} else {
throw new Error('Failed' + this.libcode)
}
} }
}).catch(error => { }).catch(error => {
console.error('Error', error) console.error('Error', error)

28
src/views/readStar/index.vue

@ -85,19 +85,21 @@ export default {
} }
FetchReadRanking(params).then(res => { FetchReadRanking(params).then(res => {
const result = JSON.parse(res.data)
if (result.success && result.resultlist.length > 0) {
this.readstarList = result.resultlist.sort((a, b) => b.TOTALNUM - a.TOTALNUM).slice(0, 10)
// this.rankingDataComputed()
// this.rankInterval = setInterval(() => {
// this.currentHover = (this.currentHover + 1) % this.rankingData.length
// }, 1000)
console.log('this.readstarList', this.readstarList)
this.getMondayDate()
} else {
throw new Error('Failed' + this.libcode)
if (res.data !== null) {
const result = JSON.parse(res.data)
if (result.success && result.resultlist.length > 0) {
this.readstarList = result.resultlist.sort((a, b) => b.TOTALNUM - a.TOTALNUM).slice(0, 10)
// this.rankingDataComputed()
// this.rankInterval = setInterval(() => {
// this.currentHover = (this.currentHover + 1) % this.rankingData.length
// }, 1000)
console.log('this.readstarList', this.readstarList)
this.getMondayDate()
} else {
throw new Error('Failed' + this.libcode)
}
} }
}).catch(error => { }).catch(error => {
console.error('Error', error) console.error('Error', error)

16
src/views/video/index.vue

@ -37,12 +37,16 @@ export default {
FetchShowFileList(params).then(res => { FetchShowFileList(params).then(res => {
if (res.errCode === 0) { if (res.errCode === 0) {
// this.src = res.data[0].filePath.replace('D://', 'http://172.16.0.23:8888/')
this.srcList = res.data.map(x => x.filePath.replace('D://', 'http://172.22.0.23:8888/'))
// this.srcList = res.data.map(x => x.filePath.replace('D://uploadFile', 'http://localhost:8080/static/'))
// console.log(22222, this.srcList)
// this.src = 'D://uploadFile/11503339-b829-4357-8379-d2b49106431f.mp4'.replace('D://', 'http://127.0.0.1:8888/')
// this.src = 'http://127.0.0.1:8888/uploadFile/9f904de6-0f5e-498e-8e5d-b7e14ea15496.mp4'
if (res.data.length > 0) {
// this.src = res.data[0].filePath.replace('D://', 'http://172.16.0.23:8888/')
this.srcList = res.data.map(x => x.filePath.replace('D://', 'http://172.22.0.23:8888/'))
// this.srcList = res.data.map(x => x.filePath.replace('D://uploadFile', 'http://localhost:8080/static/'))
// console.log(22222, this.srcList)
// this.src = 'D://uploadFile/11503339-b829-4357-8379-d2b49106431f.mp4'.replace('D://', 'http://127.0.0.1:8888/')
// this.src = 'http://127.0.0.1:8888/uploadFile/9f904de6-0f5e-498e-8e5d-b7e14ea15496.mp4'
} else {
console.log('暂无视频资源')
}
} else { } else {
this.$message.error('接口错误') this.$message.error('接口错误')
} }

Loading…
Cancel
Save