增加数据缓存,去除部分请求的重复/
This commit is contained in:
@@ -150,6 +150,7 @@
|
||||
<script>
|
||||
import config from '../../common/config.js'
|
||||
import tkiQrcode from '../../components/tki-qrcode/tki-qrcode.vue';
|
||||
import {$cache_video} from '@/store/cashe.js'
|
||||
export default {
|
||||
components: {
|
||||
tkiQrcode
|
||||
@@ -665,6 +666,30 @@
|
||||
}
|
||||
|
||||
},
|
||||
//首页视频初始化
|
||||
videoInit(){
|
||||
if(this.page==1){
|
||||
let numIdCurr = this.videoList[0].courseDetailsId;
|
||||
this.courseId = this.videoList[0].courseId
|
||||
this.courseDetailsId = this.videoList[0].courseDetailsId;
|
||||
this.videoContextId = 'myVideo' + numIdCurr;
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.videoContext = uni.createVideoContext(this.videoContextId, this);
|
||||
this.videoContext.play();
|
||||
})
|
||||
|
||||
if (uni.getStorageSync('token')) { //如果有token则插入
|
||||
//插入历史记录
|
||||
this.setHistor(this.videoList[this.current].courseId, this.videoList[this
|
||||
.current]
|
||||
.courseDetailsId)
|
||||
}
|
||||
}
|
||||
this.getsrc(this.videoList[this.current].videoUrl, this.videoList[this.current]
|
||||
.wxCourseDetailsId)
|
||||
this.$forceUpdate()
|
||||
},
|
||||
// 资源详情
|
||||
getDataList() {
|
||||
let data = {
|
||||
@@ -679,6 +704,11 @@
|
||||
// #ifdef MP-TOUTIAO
|
||||
data.dyShow = 1
|
||||
// #endif
|
||||
|
||||
if(this.page==1&&$cache_video.videoList){
|
||||
this.videoList=$cache_video.videoList
|
||||
return
|
||||
}
|
||||
this.$Request.getT('/app/course/selectCourseDetailsList', data).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.pages = res.data.totalPage
|
||||
@@ -691,30 +721,11 @@
|
||||
//菜单数组
|
||||
if (this.page == 1) {
|
||||
this.videoList = arr
|
||||
$cache_video.set('videoList',arr)
|
||||
} else {
|
||||
this.videoList = [...this.videoList, ...arr]
|
||||
}
|
||||
if (this.page == 1) {
|
||||
let numIdCurr = this.videoList[0].courseDetailsId;
|
||||
this.courseId = this.videoList[0].courseId
|
||||
this.courseDetailsId = this.videoList[0].courseDetailsId;
|
||||
this.videoContextId = 'myVideo' + numIdCurr;
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.videoContext = uni.createVideoContext(this.videoContextId, this);
|
||||
this.videoContext.play();
|
||||
})
|
||||
|
||||
if (uni.getStorageSync('token')) { //如果有token则插入
|
||||
//插入历史记录
|
||||
this.setHistor(this.videoList[this.current].courseId, this.videoList[this
|
||||
.current]
|
||||
.courseDetailsId)
|
||||
}
|
||||
}
|
||||
this.getsrc(this.videoList[this.current].videoUrl, this.videoList[this.current]
|
||||
.wxCourseDetailsId)
|
||||
this.$forceUpdate()
|
||||
this.videoInit()
|
||||
}
|
||||
} else {
|
||||
uni.showToast({
|
||||
|
||||
Reference in New Issue
Block a user