视频详情接口修改,部分代码优化增加节流
This commit is contained in:
@@ -409,6 +409,8 @@
|
||||
appearTimeout: null,
|
||||
isOrder: true,
|
||||
isGetDataList: false,
|
||||
dianzanTimer:null,
|
||||
zhuijuTimer:null
|
||||
};
|
||||
},
|
||||
onUnload() {
|
||||
@@ -418,7 +420,6 @@
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
// console.log('onSHow video');
|
||||
//当应用从后台进入前台时自动播放
|
||||
if (this.videoContext) {
|
||||
this.videoContext.play()
|
||||
@@ -513,6 +514,17 @@
|
||||
})
|
||||
this.getScale()
|
||||
},
|
||||
onBackPress() {
|
||||
console.log('onBackPress')
|
||||
const {
|
||||
courseId,
|
||||
courseDetailsId,
|
||||
videoUrl
|
||||
} = this.videoList[this.current]
|
||||
if (videoUrl) {
|
||||
this.setHistor(courseId, courseDetailsId, true)
|
||||
}
|
||||
},
|
||||
onLoad(e) {
|
||||
//是开启整部购买
|
||||
this.zhengbu = uni.getStorageSync('zhengbu') ? uni.getStorageSync('zhengbu') : '否'
|
||||
@@ -536,7 +548,7 @@
|
||||
// 记录跳转过来的视频总id跟单集id
|
||||
if (e.id) {
|
||||
this.courseId = e.id;
|
||||
|
||||
|
||||
// this.getMyLoveStatus()
|
||||
this.getMoneyList()
|
||||
this.getMyMoney()
|
||||
@@ -545,7 +557,7 @@
|
||||
if (e.allId) {
|
||||
const arr = e.allId.split('-')
|
||||
this.courseId = arr[0];
|
||||
|
||||
|
||||
// this.getMyLoveStatus()
|
||||
this.getMoneyList()
|
||||
this.getMyMoney()
|
||||
@@ -573,8 +585,8 @@
|
||||
videoPlay(videoId, courseDetailsId) {
|
||||
if (!this.playFlag) {
|
||||
this.playFlag = true
|
||||
if ( this.isGetDataList) {
|
||||
this.getDataList(this.courseId, courseDetailsId,true);
|
||||
if (this.isGetDataList) {
|
||||
this.getDataList(this.courseId, courseDetailsId, true);
|
||||
}
|
||||
this.isGetDataList = true;
|
||||
httpsRequest.getT('app/course/viewCourse', {
|
||||
@@ -595,7 +607,7 @@
|
||||
this.playFlag = false
|
||||
httpsRequest.getT('app/course/viewCourse', {
|
||||
courseId: this.courseId,
|
||||
courseDetailsId: this.courseDetailsId,
|
||||
courseDetailsId: this.videoList[this.current].courseDetailsId,
|
||||
type: 'end'
|
||||
}).then(res => {
|
||||
console.log('播放结束')
|
||||
@@ -810,10 +822,11 @@
|
||||
console.log('nvue payType=' + paytype);
|
||||
httpsRequest.getT("/app/wuyou/payOrder/" + this.ordersId + '?payType=' + paytype, {}).then(ret => {
|
||||
// plus.runtime.openURL(ret.data.h5Url)
|
||||
if(ret.code == 0 ) {
|
||||
if (ret.code == 0) {
|
||||
uni.hideLoading()
|
||||
uni.navigateTo({
|
||||
url: '/pages/pays/pays?ordersId=' + this.ordersId + '&url=' + ret.data.h5Url
|
||||
url: '/pages/pays/pays?ordersId=' + this.ordersId + '&url=' + ret.data
|
||||
.h5Url
|
||||
});
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
@@ -822,7 +835,7 @@
|
||||
title: '支付失败!'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// uni.navigateTo({
|
||||
// url: '/pages/index/webView?ordersId='+this.ordersId+'url=' + ret.data.h5Url
|
||||
@@ -1054,7 +1067,7 @@
|
||||
*/
|
||||
payVideo(type, num) {
|
||||
console.log(this.isOrder)
|
||||
if(!this.isOrder){
|
||||
if (!this.isOrder) {
|
||||
return;
|
||||
}
|
||||
uni.showLoading({
|
||||
@@ -1081,11 +1094,12 @@
|
||||
}
|
||||
console.log(this.current)
|
||||
console.log(data)
|
||||
this.setHistor()
|
||||
httpsRequest.getT((num && num == 10) ? '/app/order/insertCourseOrders/limit10' :
|
||||
'/app/order/insertCourseOrders', data).then(res => {
|
||||
console.log(res)
|
||||
if (res.code == 0) {
|
||||
|
||||
|
||||
if (res.status && res.status == 1) {
|
||||
uni.hideLoading()
|
||||
this.showPay = false //关闭购买选择弹窗
|
||||
@@ -1093,7 +1107,7 @@
|
||||
this.getDataList(this.courseId, this.videoList[this.current].courseDetailsId,
|
||||
true);
|
||||
return;
|
||||
} else{
|
||||
} else {
|
||||
this.ordersId = res.data.orders.ordersId //记录订单id
|
||||
this.payMoney = res.data.orders.payMoney //记录订单价格
|
||||
if (type == 1) { //金币
|
||||
@@ -1104,10 +1118,10 @@
|
||||
this.payPrice = res.data.orders.payMoney //需要支付的价格
|
||||
this.openPopusPay() //显示充值弹窗
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
console.log(this.isOrder)
|
||||
|
||||
|
||||
// this.payOrder(res.data.orders.ordersId, res.data.orders.payMoney)
|
||||
} else {
|
||||
this.isOrder = true
|
||||
@@ -1123,7 +1137,7 @@
|
||||
console.log("orderId==" + orderId)
|
||||
httpsRequest.postT("/app/order/payOrders", {
|
||||
orderId: orderId,
|
||||
}).then(res => {
|
||||
}).then(res => {
|
||||
console.log("orderIds==", res)
|
||||
if (res.code == 0) {
|
||||
uni.hideLoading()
|
||||
@@ -1204,16 +1218,23 @@
|
||||
//收藏
|
||||
shoucang() {
|
||||
if (uni.getStorageSync('token')) {
|
||||
this.isCollect=!this.isCollect
|
||||
let data = {
|
||||
courseId: this.courseId,
|
||||
classify: 1,
|
||||
type: this.isCollect == false ? 1 : 0
|
||||
}
|
||||
httpsRequest.postJson('/app/courseCollect/insertCourseCollect', data).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.getMyLoveStatus()
|
||||
}
|
||||
})
|
||||
clearTimeout(this.zhuijuTimer)
|
||||
this.zhuijuTimer=setTimeout(()=>{
|
||||
clearTimeout(this.zhuijuTimer)
|
||||
this.zhuijuTimer=null;
|
||||
httpsRequest.postJson('/app/courseCollect/insertCourseCollect', data).then(res => {
|
||||
if (res.code == 0) {
|
||||
// this.getMyLoveStatus()
|
||||
}
|
||||
})
|
||||
},500)
|
||||
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: "/pages/login/login"
|
||||
@@ -1230,17 +1251,23 @@
|
||||
classify: 2,
|
||||
type: item.isGood == 0 ? 1 : 0
|
||||
};
|
||||
httpsRequest.postJson('/app/courseCollect/insertCourseCollect', data).then(res => {
|
||||
if (res.code == 0) {
|
||||
if (data.type == 1) {
|
||||
item.isGood = 1;
|
||||
item.goodNum += 1;
|
||||
} else {
|
||||
item.isGood = 0;
|
||||
item.goodNum -= 1;
|
||||
if (data.type == 1) {
|
||||
item.isGood = 1;
|
||||
item.goodNum += 1;
|
||||
} else {
|
||||
item.isGood = 0;
|
||||
item.goodNum -= 1;
|
||||
}
|
||||
clearTimeout(this.dianzanTimer)
|
||||
this.dianzanTimer = null
|
||||
this.dianzanTimer = setTimeout(() => {
|
||||
httpsRequest.postJson('/app/courseCollect/insertCourseCollect', data).then(res => {
|
||||
if (res.code == 0) {
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}, 500)
|
||||
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: "/pages/login/login"
|
||||
@@ -1320,34 +1347,26 @@
|
||||
*/
|
||||
getDataList(courseId, courseDetailsId, type, t) {
|
||||
let data = {
|
||||
id: courseId,
|
||||
courseId: courseId,
|
||||
token: uni.getStorageSync('token') ? uni.getStorageSync('token') : ''
|
||||
};
|
||||
console.log("getDataList==="+courseDetailsId)
|
||||
console.log("getDataList===",data)
|
||||
httpsRequest.getT('/app/course/selectCourseDetailsById', data).then(res => {
|
||||
|
||||
httpsRequest.getT('/app/course/courseSets', data).then(res => {
|
||||
console.log('getDataList')
|
||||
console.log(res)
|
||||
if (res.code == 0) {
|
||||
console.log(res)
|
||||
if (res.data && res.data.isCollect && res.data.isCollect > 0) {
|
||||
this.isCollect = true
|
||||
} else {
|
||||
this.isCollect = false
|
||||
}
|
||||
if( res.data && res.data.courseDetailsId && !this.courseDetailsId && !courseDetailsId) {
|
||||
this.isCollect = res.data.collect ? true : false;
|
||||
if (res.data && res.data.courseDetailsId && !this.courseDetailsId && !courseDetailsId) {
|
||||
courseDetailsId = res.data.courseDetailsId
|
||||
}
|
||||
this.courseDetailsId = courseDetailsId
|
||||
console.log(courseDetailsId)
|
||||
if (res.data.listsDetail) {
|
||||
if (res.data.list) {
|
||||
this.info = res.data;
|
||||
this.title = this.info.title;
|
||||
let arr = JSON.parse(JSON.stringify(res.data.listsDetail));
|
||||
const indexs = arr.findIndex(menu => menu.courseDetailsId == Number(courseDetailsId));
|
||||
//如果未找到将current值改为0,否则会导致选集无法弹窗,弹窗后点击相对应集数也无反应
|
||||
this.current = indexs===-1?0:indexs;
|
||||
console.log(indexs)
|
||||
console.log(this.current)
|
||||
const arr = res.data.list
|
||||
const indexs = arr.findIndex(v => v.courseDetailsId == (courseDetailsId ?
|
||||
courseDetailsId : res.data.current.courseDetailsId));
|
||||
//如果未找到将current值改为0,否则会导致选集无法弹窗,弹窗后点击相对应集数也无反应
|
||||
this.current = indexs === -1 ? 0 : indexs;
|
||||
this.scrollIntoViews = 'video' + indexs
|
||||
this.scrollIntoView = 'video' + indexs
|
||||
// this.scrollIntoView = 'video' + indexs
|
||||
@@ -1398,7 +1417,7 @@
|
||||
})
|
||||
} else {
|
||||
console.log('播放')
|
||||
this.$nextTick(()=>{
|
||||
this.$nextTick(() => {
|
||||
console.log('myVideo' + courseDetailsIds)
|
||||
this.videoContextId = 'myVideo' + courseDetailsIds;
|
||||
this.videoContext = uni.createVideoContext(this
|
||||
@@ -1406,12 +1425,12 @@
|
||||
this);
|
||||
if (this.videoList[this.current].videoUrl) {
|
||||
this.videoContext.play();
|
||||
}else {
|
||||
} else {
|
||||
console.log("播放失败")
|
||||
this.getDataList(this.courseId, courseDetailsIds, true);
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
// console.log('this.noBuyVideoIndex', this.noBuyVideoIndex)
|
||||
|
||||
@@ -1484,8 +1503,22 @@
|
||||
})
|
||||
},
|
||||
//插入观看记录
|
||||
setHistor(courseId, courseDetailsId) {
|
||||
setHistor(courseId, courseDetailsId, now) {
|
||||
clearTimeout(this.timer)
|
||||
|
||||
if (uni.getStorageSync('token')) {
|
||||
clearTimeout(this.timer)
|
||||
if (now) {
|
||||
let data = {
|
||||
courseId: courseId,
|
||||
courseDetailsId: courseDetailsId,
|
||||
classify: 3,
|
||||
type: 1
|
||||
};
|
||||
console.log(data, '记录了')
|
||||
httpsRequest.postJson('/app/courseCollect/insertCourseCollect', data).then(res => {})
|
||||
return
|
||||
}
|
||||
let data = {
|
||||
courseId: courseId,
|
||||
courseDetailsId: courseDetailsId,
|
||||
|
||||
Reference in New Issue
Block a user