```
//组件滑动处理视频
changeCurrent(e) {
let that = this;
console.error(e.detail.current)
// if (plus.os.name.toLowerCase() === 'ios') {
that.changVideo(e.detail.current);
// }
},
//统一处理视频加载问题
changVideo(index) {
let that = this;
this.$nextTick(() => {
this.index = index;
for (let item of this.videoList) {
item.video.flag = true
}
that.videoList[that.index].video.flag = false;
if (this.Page < this.totalPages) {
console.error('下标对比:', this.index, this.oldIndex)
console.error('当前视频位数:' + index)
this.dangqianvideoId = this.videoList[this.index].video.videoId
this.redCount = this.videoList[this.index].video.redCount
var len = this.videoList.filter(item => item.video.url).length
//剩余两条的时候加载视频
console.error('剩余两条的时候加载视频:' + len)
if (len - index - 1 <= 2 && index > 0) {
this.Page++
console.error('数据长度:' + this.videoList.length)
this.oldIndex = this.index
this.userList(this.Page);
}
this.music = this.videoList[this.index].music.musicId
this.musicid = this.videoList[this.index].music.musicId
this.musicName = this.videoList[this.index].music.musicName
this.musicList.push(this.videoList[this.index].music.musicName)
console.log('musicid:' + this.musicid)
} else {
this.Page = this.totalPages - 1;
}
// this.videoList[this.index].video.flag = true
this.listTouchDirection = null
this.goods = null
this.isCheck(this.videoList[index].video.videoId);
this.giftNum(this.videoList[index].video.videoId);
//获取视频用户信息
this.getUser(this.videoList[index].userInfo.userId); //用户信息
// 观看视频 记录
let userId = uni.getStorageSync("userId");
if (timer2) {
clearTimeout(timer2)
};
timer2 = setTimeout(() => {
that.viewVideo(userId, that.videoList[index].video.videoId)
}, 4000)
//获取用户分享
this.refresh(); //用户分享
this.getMusic();
// 视频评论数
this.getTotal(this.videoList[index].video.videoId);
let localId = uni.getStorageSync("userId");
console.log(localId, '`````````', that.videoList[index].userInfo.userId)
if (localId == that.videoList[index].userInfo.userId) {
that.who = 'my'
} else {
that.who = 'other'
}
//设置播放视频
setTimeout(() => {
if (this.videoList.length > 0) {
// that.videoList[that.index].video.flag = true;
}
}, 500)
setTimeout(() => {
// that.videoList[that.index-1].video.flag = false;
}, 2000)
})
},
// 视频列表
userList(page) {
let that = this;
uni.request({
url: config.APIHOST2 + '/video/userListByPraise',
data: {
page: page,
userId: uni.getStorageSync("userId"),
size: 10
},
sslVerify: false,
header: {
"content-type": "application/json"
},
method: "GET",
success: function(res) {
console.error('推荐视频:' + JSON.stringify(res.data.data))
uni.hideLoading();
if (res.data.status == 0 && res.data.data.length > 0) {
let dataArr = res.data.data;
that.totalPages = res.data.data.length;
// that.videoTotalElements = res.data.data.totalElements
console.log('推荐视频:', dataArr)
for (let i = 0; i < dataArr.length; i++) {
if (dataArr[i].videoStatistics.sumPraise == null || dataArr[i].videoStatistics
.sumPraise == '') {
dataArr[i].videoStatistics.sumPraise = 0
}
dataArr[i].video = Object.assign(dataArr[i].video, {
"flag": true,
"check": false,
"card": true
})
}
that.$nextTick(res => {
// let videoGroup = dataArr
let len = that.videoList.length
dataArr.forEach(val => {
that.videoList.push(val);
})
that.oldIndex = that.index + 1
that.dangqianvideoId = that.videoList[that.index].video.videoId
that.redCount = that.videoList[that.index].videoStatistics.redCount
console.error('检查集合数据' + that.videoList.length)
console.error('检查当前位置' + that.index, that.dangqianvideoId)
let localId = uni.getStorageSync("userId");
if (localId == that.videoList[that.index].userInfo.userId) {
that.who = 'my'
} else {
that.who = 'other'
}
that.music = that.videoList[that.index].music.musicId
that.videoList[that.index].video.flag = false;
that.refresh(); //用户分享
// 视频评论数
// that.getTotal(that.videoList[that.index].videoId)
that.blockShow = true;
that.getUser(that.videoList[that.index].userInfo.userId); //用户信息
setTimeout(() => {
// that.getUser(that.videoList[that.index].userInfo.userId); //用户信息
// that.videoList[that.index-1].video.flag = false;
}, 2000)
// 观看视频 记录
let userId = uni.getStorageSync("userId");
if (timer2) {
clearTimeout(timer2)
timer2 = null
};
timer2 = setTimeout(() => {
that.viewVideo(userId, that.videoList[that.index].video
.videoId)
}, 1000)
that.giftNum(that.videoList[that.index].video.videoId)
that.realyFollow(that.videoList[that.index].userInfo.userId); //关注检测
that.addVideoList(that.videoList); //共分享页面 共享数据
if(that.slideCurrentIndex==0){
that.videoList[that.index].video.flag = false;
}else{
that.videoList[that.index].video.flag = true;
}
})
}
},
fail: function(err) {
uni.hideLoading();
}
})
},