|
@ -88,7 +88,7 @@ |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import { FetchInitScreenData, FetchTotalResource, FetchNoticeList, FetchSync36 } from '@/api/library' |
|
|
|
|
|
|
|
|
import { FetchInitScreenData, FetchVideo, FetchNoticeList, FetchSync36 } from '@/api/library' |
|
|
import { swiper, swiperSlide } from 'vue-awesome-swiper' |
|
|
import { swiper, swiperSlide } from 'vue-awesome-swiper' |
|
|
import 'swiper/dist/css/swiper.css' |
|
|
import 'swiper/dist/css/swiper.css' |
|
|
import { pageCrud } from '../mixins/index.js' |
|
|
import { pageCrud } from '../mixins/index.js' |
|
@ -123,33 +123,50 @@ export default { |
|
|
}, |
|
|
}, |
|
|
on: { |
|
|
on: { |
|
|
slideChange: function() { |
|
|
slideChange: function() { |
|
|
// 获取当前index |
|
|
|
|
|
_self.noticeIndex = this.activeIndex |
|
|
_self.noticeIndex = this.activeIndex |
|
|
// console.log('当前index:' + _self.noticeIndex) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
activatedBaseSetting: {} |
|
|
|
|
|
|
|
|
activatedBaseSetting: {}, |
|
|
|
|
|
activatedVideo: [] |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
computed: { |
|
|
computed: { |
|
|
}, |
|
|
}, |
|
|
|
|
|
watch: { |
|
|
|
|
|
videoData: { |
|
|
|
|
|
handler(newVal) { |
|
|
|
|
|
if (newVal && newVal.length !== 0) { |
|
|
|
|
|
this.activatedVideo = newVal |
|
|
|
|
|
this.getVideoResource() |
|
|
|
|
|
} else { |
|
|
|
|
|
this.activatedVideo = [] |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
immediate: true |
|
|
|
|
|
}, |
|
|
|
|
|
baseSetting: { |
|
|
|
|
|
handler(result) { |
|
|
|
|
|
if (!result) return |
|
|
|
|
|
this.activatedBaseSetting = result |
|
|
|
|
|
this.wecharQrCodeSrc = result.wechar_qr_code?.context || '' |
|
|
|
|
|
|
|
|
|
|
|
if (result.open_lib_appId && result.open_lib_secret && result.open_lib_http) { |
|
|
|
|
|
this.getBookRanking(this.activatedBaseSetting) |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
immediate: true |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
beforeDestroy() { |
|
|
beforeDestroy() { |
|
|
this.destroy() |
|
|
this.destroy() |
|
|
}, |
|
|
}, |
|
|
created() { |
|
|
created() { |
|
|
// this.getVideoResource() |
|
|
|
|
|
this.getNotice() |
|
|
this.getNotice() |
|
|
this.$watch('baseSetting', (newVal, oldVal) => { |
|
|
|
|
|
console.log('pageFour:', newVal) |
|
|
|
|
|
if (newVal && Object.keys(newVal).length > 0) { |
|
|
|
|
|
this.activatedBaseSetting = newVal |
|
|
|
|
|
this.getBookRanking(this.activatedBaseSetting) |
|
|
|
|
|
} |
|
|
|
|
|
}, { immediate: true }) |
|
|
|
|
|
}, |
|
|
}, |
|
|
activated() { |
|
|
activated() { |
|
|
this.getVideoResource() |
|
|
|
|
|
|
|
|
// this.getVideoResource() |
|
|
this.load() |
|
|
this.load() |
|
|
if (this.rankingData.length !== 0) { |
|
|
if (this.rankingData.length !== 0) { |
|
|
this.currentHover = -1 |
|
|
this.currentHover = -1 |
|
@ -236,39 +253,63 @@ export default { |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
// 视频资源 |
|
|
|
|
|
getVideoResource() { |
|
|
getVideoResource() { |
|
|
FetchTotalResource().then(res => { |
|
|
|
|
|
const result = JSON.parse(res.data) |
|
|
|
|
|
const linkSrc = process.env.NODE_ENV === 'production' ? window.g.ApiUrl : process.env.VUE_APP_BASE_API |
|
|
|
|
|
this.slideData = result.map((item, index) => { |
|
|
|
|
|
if (item.filePath) { |
|
|
|
|
|
item.cover = linkSrc + '/downloadFile' + item.filePath |
|
|
|
|
|
} else { |
|
|
|
|
|
item.cover = null |
|
|
|
|
|
|
|
|
console.log('activatedVideo中的视频数据:', this.activatedVideo) |
|
|
|
|
|
const videoIds = this.activatedVideo.map(item => item.videoImg) |
|
|
|
|
|
|
|
|
|
|
|
if (videoIds.length === 0) { |
|
|
|
|
|
this.slideData = [] |
|
|
|
|
|
console.log('没有需要请求的视频id') |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
const params = { |
|
|
|
|
|
'videoIds': videoIds |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FetchVideo(params).then(res => { |
|
|
|
|
|
const videoUrls = res |
|
|
|
|
|
console.log('获取到的视频URL列表:', videoUrls) |
|
|
|
|
|
|
|
|
|
|
|
this.slideData = this.activatedVideo.map((videoInfo, index) => { |
|
|
|
|
|
return { |
|
|
|
|
|
...videoInfo, |
|
|
|
|
|
cover: videoUrls[index] || null |
|
|
} |
|
|
} |
|
|
return item |
|
|
|
|
|
}) |
|
|
|
|
|
console.log('this.slideData', this.slideData) |
|
|
|
|
|
// 下次进入页面时优先缓存的部分 |
|
|
|
|
|
|
|
|
}).filter(item => item.cover) |
|
|
|
|
|
console.log('生成的视频播放数据:', this.slideData) |
|
|
|
|
|
|
|
|
if (localStorage.getItem('videoIndex')) { |
|
|
if (localStorage.getItem('videoIndex')) { |
|
|
this.videoIndex = parseInt(localStorage.getItem('videoIndex')) |
|
|
this.videoIndex = parseInt(localStorage.getItem('videoIndex')) |
|
|
|
|
|
if (this.videoIndex >= this.slideData.length) { |
|
|
|
|
|
this.videoIndex = 0 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
this.$nextTick(() => { |
|
|
this.$nextTick(() => { |
|
|
this.$refs.carousel.setActiveItem(this.videoIndex) |
|
|
this.$refs.carousel.setActiveItem(this.videoIndex) |
|
|
const videos = this.$refs.videos |
|
|
const videos = this.$refs.videos |
|
|
const nextVideo = videos[this.videoIndex] |
|
|
|
|
|
videos.forEach((video) => { |
|
|
|
|
|
video.pause() |
|
|
|
|
|
video.currentTime = 0 |
|
|
|
|
|
}) |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
nextVideo.currentTime = localStorage.getItem('videoCurrentTime') ? localStorage.getItem('videoCurrentTime') : 0 |
|
|
|
|
|
nextVideo.play() |
|
|
|
|
|
}, 2000) |
|
|
|
|
|
|
|
|
if (videos && videos[this.videoIndex]) { |
|
|
|
|
|
const targetVideo = videos[this.videoIndex] |
|
|
|
|
|
|
|
|
|
|
|
videos.forEach(video => { |
|
|
|
|
|
video.pause() |
|
|
|
|
|
video.currentTime = 0 |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
const savedTime = localStorage.getItem('videoCurrentTime') |
|
|
|
|
|
if (savedTime) { |
|
|
|
|
|
targetVideo.currentTime = parseFloat(savedTime) |
|
|
|
|
|
} |
|
|
|
|
|
targetVideo.play().catch(err => { |
|
|
|
|
|
console.error('视频自动播放失败:', err) |
|
|
|
|
|
}) |
|
|
|
|
|
}, 1000) |
|
|
|
|
|
} |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
}).catch(error => { |
|
|
}).catch(error => { |
|
|
console.error('Error', error) |
|
|
|
|
|
|
|
|
console.error('获取视频URL失败:', error) |
|
|
|
|
|
this.slideData = [] |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
playVideo() { |
|
|
playVideo() { |
|
|