视频详情接口修改,部分代码优化增加节流

This commit is contained in:
2025-01-06 20:00:45 +08:00
parent 4ea69ba20b
commit 72562093fa
2 changed files with 212 additions and 170 deletions

View File

@@ -409,6 +409,8 @@
appearTimeout: null, appearTimeout: null,
isOrder: true, isOrder: true,
isGetDataList: false, isGetDataList: false,
dianzanTimer:null,
zhuijuTimer:null
}; };
}, },
onUnload() { onUnload() {
@@ -418,7 +420,6 @@
} }
}, },
onShow() { onShow() {
// console.log('onSHow video');
//当应用从后台进入前台时自动播放 //当应用从后台进入前台时自动播放
if (this.videoContext) { if (this.videoContext) {
this.videoContext.play() this.videoContext.play()
@@ -513,6 +514,17 @@
}) })
this.getScale() this.getScale()
}, },
onBackPress() {
console.log('onBackPress')
const {
courseId,
courseDetailsId,
videoUrl
} = this.videoList[this.current]
if (videoUrl) {
this.setHistor(courseId, courseDetailsId, true)
}
},
onLoad(e) { onLoad(e) {
//是开启整部购买 //是开启整部购买
this.zhengbu = uni.getStorageSync('zhengbu') ? uni.getStorageSync('zhengbu') : '否' this.zhengbu = uni.getStorageSync('zhengbu') ? uni.getStorageSync('zhengbu') : '否'
@@ -595,7 +607,7 @@
this.playFlag = false this.playFlag = false
httpsRequest.getT('app/course/viewCourse', { httpsRequest.getT('app/course/viewCourse', {
courseId: this.courseId, courseId: this.courseId,
courseDetailsId: this.courseDetailsId, courseDetailsId: this.videoList[this.current].courseDetailsId,
type: 'end' type: 'end'
}).then(res => { }).then(res => {
console.log('播放结束') console.log('播放结束')
@@ -813,7 +825,8 @@
if (ret.code == 0) { if (ret.code == 0) {
uni.hideLoading() uni.hideLoading()
uni.navigateTo({ 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 { } else {
uni.hideLoading() uni.hideLoading()
@@ -1081,6 +1094,7 @@
} }
console.log(this.current) console.log(this.current)
console.log(data) console.log(data)
this.setHistor()
httpsRequest.getT((num && num == 10) ? '/app/order/insertCourseOrders/limit10' : httpsRequest.getT((num && num == 10) ? '/app/order/insertCourseOrders/limit10' :
'/app/order/insertCourseOrders', data).then(res => { '/app/order/insertCourseOrders', data).then(res => {
console.log(res) console.log(res)
@@ -1204,16 +1218,23 @@
//收藏 //收藏
shoucang() { shoucang() {
if (uni.getStorageSync('token')) { if (uni.getStorageSync('token')) {
this.isCollect=!this.isCollect
let data = { let data = {
courseId: this.courseId, courseId: this.courseId,
classify: 1, classify: 1,
type: this.isCollect == false ? 1 : 0 type: this.isCollect == false ? 1 : 0
} }
clearTimeout(this.zhuijuTimer)
this.zhuijuTimer=setTimeout(()=>{
clearTimeout(this.zhuijuTimer)
this.zhuijuTimer=null;
httpsRequest.postJson('/app/courseCollect/insertCourseCollect', data).then(res => { httpsRequest.postJson('/app/courseCollect/insertCourseCollect', data).then(res => {
if (res.code == 0) { if (res.code == 0) {
this.getMyLoveStatus() // this.getMyLoveStatus()
} }
}) })
},500)
} else { } else {
uni.navigateTo({ uni.navigateTo({
url: "/pages/login/login" url: "/pages/login/login"
@@ -1230,8 +1251,6 @@
classify: 2, classify: 2,
type: item.isGood == 0 ? 1 : 0 type: item.isGood == 0 ? 1 : 0
}; };
httpsRequest.postJson('/app/courseCollect/insertCourseCollect', data).then(res => {
if (res.code == 0) {
if (data.type == 1) { if (data.type == 1) {
item.isGood = 1; item.isGood = 1;
item.goodNum += 1; item.goodNum += 1;
@@ -1239,8 +1258,16 @@
item.isGood = 0; item.isGood = 0;
item.goodNum -= 1; 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 { } else {
uni.navigateTo({ uni.navigateTo({
url: "/pages/login/login" url: "/pages/login/login"
@@ -1320,34 +1347,26 @@
*/ */
getDataList(courseId, courseDetailsId, type, t) { getDataList(courseId, courseDetailsId, type, t) {
let data = { let data = {
id: courseId, courseId: courseId,
token: uni.getStorageSync('token') ? uni.getStorageSync('token') : '' token: uni.getStorageSync('token') ? uni.getStorageSync('token') : ''
}; };
console.log("getDataList==="+courseDetailsId) httpsRequest.getT('/app/course/courseSets', data).then(res => {
console.log("getDataList===",data) console.log('getDataList')
httpsRequest.getT('/app/course/selectCourseDetailsById', data).then(res => {
if (res.code == 0) {
console.log(res) console.log(res)
if (res.data && res.data.isCollect && res.data.isCollect > 0) { if (res.code == 0) {
this.isCollect = true this.isCollect = res.data.collect ? true : false;
} else {
this.isCollect = false
}
if (res.data && res.data.courseDetailsId && !this.courseDetailsId && !courseDetailsId) { if (res.data && res.data.courseDetailsId && !this.courseDetailsId && !courseDetailsId) {
courseDetailsId = res.data.courseDetailsId courseDetailsId = res.data.courseDetailsId
} }
this.courseDetailsId = courseDetailsId this.courseDetailsId = courseDetailsId
console.log(courseDetailsId) if (res.data.list) {
if (res.data.listsDetail) {
this.info = res.data; this.info = res.data;
this.title = this.info.title; this.title = this.info.title;
let arr = JSON.parse(JSON.stringify(res.data.listsDetail)); const arr = res.data.list
const indexs = arr.findIndex(menu => menu.courseDetailsId == Number(courseDetailsId)); const indexs = arr.findIndex(v => v.courseDetailsId == (courseDetailsId ?
courseDetailsId : res.data.current.courseDetailsId));
//如果未找到将current值改为0否则会导致选集无法弹窗弹窗后点击相对应集数也无反应 //如果未找到将current值改为0否则会导致选集无法弹窗弹窗后点击相对应集数也无反应
this.current = indexs === -1 ? 0 : indexs; this.current = indexs === -1 ? 0 : indexs;
console.log(indexs)
console.log(this.current)
this.scrollIntoViews = 'video' + indexs this.scrollIntoViews = 'video' + indexs
this.scrollIntoView = 'video' + indexs this.scrollIntoView = 'video' + indexs
// this.scrollIntoView = 'video' + indexs // this.scrollIntoView = 'video' + indexs
@@ -1484,8 +1503,22 @@
}) })
}, },
//插入观看记录 //插入观看记录
setHistor(courseId, courseDetailsId) { setHistor(courseId, courseDetailsId, now) {
clearTimeout(this.timer)
if (uni.getStorageSync('token')) { 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 = { let data = {
courseId: courseId, courseId: courseId,
courseDetailsId: courseDetailsId, courseDetailsId: courseDetailsId,

View File

@@ -13,8 +13,8 @@
@waiting="waiting()" object-fit="cover" v-if="current === index && item.videoUrl" @waiting="waiting()" object-fit="cover" v-if="current === index && item.videoUrl"
:play-strategy="2" :show-loading="true" codec="software" :muted="false" :play-strategy="2" :show-loading="true" codec="software" :muted="false"
:show-center-play-btn="true" :loop="false" @ended="ended" :show-center-play-btn="true" :loop="false" @ended="ended"
@play="videoPlay('myVideo'+item.courseDetailsId)" :enable-progress-gesture="false" @play="videoPlay('myVideo'+item.courseDetailsId,item.courseDetailsId)"
:poster="item.titleImg" :ref="'myVideo'+item.courseDetailsId" :enable-progress-gesture="false" :poster="item.titleImg" :ref="'myVideo'+item.courseDetailsId"
:id="'myVideo'+item.courseDetailsId" :src="item.videoUrl" :autoplay="item.autoPlay" :id="'myVideo'+item.courseDetailsId" :src="item.videoUrl" :autoplay="item.autoPlay"
class="swipers-items-video"></video> class="swipers-items-video"></video>
<!-- #endif --> <!-- #endif -->
@@ -23,7 +23,7 @@
@controlstoggle="controlstoggles" @timeupdate="timeupdate" @waiting="waiting()" @controlstoggle="controlstoggles" @timeupdate="timeupdate" @waiting="waiting()"
object-fit="cover" v-if="current === index && item.videoUrl" :play-strategy="2" object-fit="cover" v-if="current === index && item.videoUrl" :play-strategy="2"
:show-loading="true" codec="software" :muted="false" :show-center-play-btn="true" :loop="false" :show-loading="true" codec="software" :muted="false" :show-center-play-btn="true" :loop="false"
@ended="ended" @play="videoPlay('myVideo'+item.courseDetailsId)" @ended="ended" @play="videoPlay('myVideo'+item.courseDetailsId,item.courseDetailsId)"
:enable-progress-gesture="false" :poster="item.titleImg" :ref="'myVideo'+item.courseDetailsId" :enable-progress-gesture="false" :poster="item.titleImg" :ref="'myVideo'+item.courseDetailsId"
:id="'myVideo'+item.courseDetailsId" :src="item.videoUrl" :autoplay="item.autoPlay" :id="'myVideo'+item.courseDetailsId" :src="item.videoUrl" :autoplay="item.autoPlay"
class="swipers-items-video" @contextmenu.prevent="disableContextMenu"></video> class="swipers-items-video" @contextmenu.prevent="disableContextMenu"></video>
@@ -41,8 +41,8 @@
<!-- #endif --> <!-- #endif -->
<!-- :autoplay="item.autoPlay" --> <!-- :autoplay="item.autoPlay" -->
<!-- 没有视频权限则显示封面图 --> <!-- 没有视频权限则显示封面图 -->
<image v-else @click="openShowPay(current,index,item.videoUrl);showControls = true" :src="item.titleImg" <image v-else @click="openShowPay(current,index,item.videoUrl);showControls = true"
class="swipers-items-imgsbg" mode="aspectFill"></image> :src="item.titleImg" class="swipers-items-imgsbg" mode="aspectFill"></image>
<!-- 返回图标 --> <!-- 返回图标 -->
<!-- #ifndef MP-TOUTIAO --> <!-- #ifndef MP-TOUTIAO -->
<view @click.stop="goBack()" style="color: #ffffff;"> <view @click.stop="goBack()" style="color: #ffffff;">
@@ -188,8 +188,8 @@
<!-- 购买视频 --> <!-- 购买视频 -->
<u-popup :closeable="true" :custom-style="customStyle" :safe-area-inset-bottom="true" close-icon="close" <u-popup :closeable="true" :custom-style="customStyle" :safe-area-inset-bottom="true" close-icon="close"
close-icon-size="30" @close="popupPyaClose" close-icon-color="#333333" :mask-custom-style="maskCustomStyle" v-model="showPay" close-icon-size="30" @close="popupPyaClose" close-icon-color="#333333" :mask-custom-style="maskCustomStyle"
border-radius="24" mode="bottom"> v-model="showPay" border-radius="24" mode="bottom">
<view class="list" :style="listStyle"> <view class="list" :style="listStyle">
<view class="list-title flex align-center"> <view class="list-title flex align-center">
<!-- <u-icon name="lock" class="list-title-icon" color="#efbb6b" size="40"></u-icon> --> <!-- <u-icon name="lock" class="list-title-icon" color="#efbb6b" size="40"></u-icon> -->
@@ -321,7 +321,9 @@
import { import {
returnIsSafari returnIsSafari
} from '@/utils/app.js' } from '@/utils/app.js'
import {cacheClear} from '@/store/cashe.js' import {
cacheClear
} from '@/store/cashe.js'
export default { export default {
components: { components: {
tkiQrcode, tkiQrcode,
@@ -329,6 +331,7 @@
}, },
data() { data() {
return { return {
timer: null,
isSafari: returnIsSafari(), isSafari: returnIsSafari(),
//记录未购买视频索引 //记录未购买视频索引
noBuyVideoIndex: null, noBuyVideoIndex: null,
@@ -446,7 +449,9 @@
getRedEnvelopeTips: '', getRedEnvelopeTips: '',
scale: 1, scale: 1,
isOrder: true, isOrder: true,
isGetDataList: false isGetDataList: false,
dianzanTimer: null,
zhuijuTimer:null
}; };
}, },
onShareAppMessage(res) { onShareAppMessage(res) {
@@ -532,7 +537,6 @@
// #endif // #endif
}, },
onLoad(e) { onLoad(e) {
//在苹果系统微信小程序是否开启支付 //在苹果系统微信小程序是否开启支付
this.isWxIosPay = uni.getStorageSync('isWxIosPay') this.isWxIosPay = uni.getStorageSync('isWxIosPay')
@@ -638,6 +642,9 @@
// }); // });
}, },
onHide() { onHide() {
//恢复录屏 //恢复录屏
// #ifdef MP-TOUTIAO // #ifdef MP-TOUTIAO
tt.enableUserScreenRecord({ tt.enableUserScreenRecord({
@@ -663,7 +670,6 @@
// #endif // #endif
}, },
onShow() { onShow() {
console.log('onSHow video');
//当应用从后台进入前台时自动播放 //当应用从后台进入前台时自动播放
if (this.videoContext) { if (this.videoContext) {
@@ -673,11 +679,9 @@
if (noBuyVideoIndex !== null && noBuyVideoIndex !== undefined) { if (noBuyVideoIndex !== null && noBuyVideoIndex !== undefined) {
this.noBuyVideoIndex = noBuyVideoIndex this.noBuyVideoIndex = noBuyVideoIndex
} }
try { try {
this.playType = Number(uni.getStorageSync('playType')) this.playType = Number(uni.getStorageSync('playType'))
} catch (e) { } catch (e) {
//TODO handle the exception
this.playType = 1 this.playType = 1
} }
let that = this let that = this
@@ -730,7 +734,6 @@
// #endif // #endif
this.isVips = uni.getStorageSync('isVips') ? uni.getStorageSync('isVips') : '否' this.isVips = uni.getStorageSync('isVips') ? uni.getStorageSync('isVips') : '否'
if (this.courseId) { if (this.courseId) {
console.log('has this.courseId getDataList()');
this.getDataList(this.courseId, this.courseDetailsId); this.getDataList(this.courseId, this.courseDetailsId);
} }
this.$Request.getT('app/course/getRedEnvelopeTips').then(res => { this.$Request.getT('app/course/getRedEnvelopeTips').then(res => {
@@ -773,6 +776,17 @@
// #endif // #endif
}, },
onBackPress() {
console.log('onBackPress')
const {
courseId,
courseDetailsId,
videoUrl
} = this.videoList[this.current]
if (videoUrl) {
this.setHistor(courseId, courseDetailsId, true)
}
},
watch: { watch: {
//监听当前播放的集数 //监听当前播放的集数
current() { current() {
@@ -1128,7 +1142,7 @@
this.playFlag = false this.playFlag = false
this.$Request.getT('app/course/viewCourse', { this.$Request.getT('app/course/viewCourse', {
courseId: this.courseId, courseId: this.courseId,
courseDetailsId: this.courseDetailsId, courseDetailsId: this.videoList[this.current].courseDetailsId,
type: 'end' type: 'end'
}).then(res => { }).then(res => {
console.log('播放结束') console.log('播放结束')
@@ -1295,6 +1309,7 @@
//子组件支付成功的回调 //子组件支付成功的回调
paySuccess(data) { paySuccess(data) {
console.log(data) console.log(data)
this.setHistor(this.courseId, this.videoList[this.current].courseDetailsId, true)
// data.h5Url 跳转地址 // data.h5Url 跳转地址
this.showMoney = false //显示充值弹窗 this.showMoney = false //显示充值弹窗
uni.setStorageSync('noBuyVideoIndex', this.current) uni.setStorageSync('noBuyVideoIndex', this.current)
@@ -1332,8 +1347,6 @@
this.$Request.getT((num && num == 10) ? '/app/order/insertCourseOrders/limit10' : this.$Request.getT((num && num == 10) ? '/app/order/insertCourseOrders/limit10' :
'/app/order/insertCourseOrders', data).then(res => { '/app/order/insertCourseOrders', data).then(res => {
if (res.code == 0) { if (res.code == 0) {
if (res.status && res.status == 1) { if (res.status && res.status == 1) {
this.showPay = false //关闭购买选择弹窗 this.showPay = false //关闭购买选择弹窗
this.getDataList(this.courseId, this.videoList[this.current].courseDetailsId, this.getDataList(this.courseId, this.videoList[this.current].courseDetailsId,
@@ -1415,16 +1428,23 @@
//收藏 //收藏
shoucang() { shoucang() {
if (uni.getStorageSync('token')) { if (uni.getStorageSync('token')) {
this.isCollect=!this.isCollect
let data = { let data = {
courseId: this.courseId, courseId: this.courseId,
classify: 1, classify: 1,
type: this.isCollect == false ? 1 : 0 type: this.isCollect == false ? 1 : 0
} }
clearTimeout(this.zhuijuTimer)
this.zhuijuTimer = setTimeout(() => {
clearTimeout(this.zhuijuTimer)
this.zhuijuTimer = null;
this.$Request.postJson('/app/courseCollect/insertCourseCollect', data).then(res => { this.$Request.postJson('/app/courseCollect/insertCourseCollect', data).then(res => {
if (res.code == 0) { if (res.code == 0) {
this.getMyLoveStatus() // this.getMyLoveStatus()
} }
}) })
}, 500)
} else { } else {
uni.navigateTo({ uni.navigateTo({
url: "/pages/login/login" url: "/pages/login/login"
@@ -1441,8 +1461,6 @@
classify: 2, classify: 2,
type: item.isGood == 0 ? 1 : 0 type: item.isGood == 0 ? 1 : 0
} }
this.$Request.postJson('/app/courseCollect/insertCourseCollect', data).then(res => {
if (res.code == 0) {
if (data.type == 1) { if (data.type == 1) {
item.isGood = 1 item.isGood = 1
item.goodNum += 1 item.goodNum += 1
@@ -1450,8 +1468,17 @@
item.isGood = 0 item.isGood = 0
item.goodNum -= 1 item.goodNum -= 1
} }
clearTimeout(this.dianzanTimer)
this.dianzanTimer = null
this.dianzanTimer = setTimeout(() => {
this.$Request.postJson('/app/courseCollect/insertCourseCollect', data).then(res => {
if (res.code == 0) {
} }
}) })
}, 500)
} else { } else {
uni.navigateTo({ uni.navigateTo({
url: "/pages/login/login" url: "/pages/login/login"
@@ -1511,7 +1538,6 @@
} }
//重新计算一下当前观看的是哪个视频 //重新计算一下当前观看的是哪个视频
this.comNumVideo() this.comNumVideo()
this.setWxUrl()
// 把选择的视频的自动播放设置为true // 把选择的视频的自动播放设置为true
this.videoList[this.current].autoPlay = true this.videoList[this.current].autoPlay = true
//让当前选择的视频播放 //让当前选择的视频播放
@@ -1541,33 +1567,24 @@
}, },
// 资源详情 // 资源详情
getDataList(id, courseDetailsId, type, t) { getDataList(id, courseDetailsId, type, t) {
console.log('getDataList');
let data = { let data = {
id, courseId: id
token: uni.getStorageSync('token') ? uni.getStorageSync('token') : ''
} }
// // #ifdef MP-WEIXIN
// data.courseDetailsId = courseDetailsId
// // #endif
this.$u.api.selectCourseDetailsById(data).then(res => { this.$u.api.selectCourseDetailsById(data).then(res => {
if (res.code == 0) { if (res.code == 0) {
this.isCollect = res.data.collect ? true : false;
console.log(this.isCollect);
if (res.data && res.data.dyCourseId) { if (res.data && res.data.dyCourseId) {
this.dyCourseId = "" + res.data.dyCourseId; this.dyCourseId = "" + res.data.dyCourseId;
console.log("dyCourseId__" + this.dyCourseId)
} }
if (res.data && res.data.courseDetailsId && !this.courseDetailsId && !courseDetailsId) { if (res.data && res.data.courseDetailsId && !this.courseDetailsId && !courseDetailsId) {
this.courseDetailsId = res.data.courseDetailsId this.courseDetailsId = res.data.courseDetailsId
courseDetailsId = res.data.courseDetailsId courseDetailsId = res.data.courseDetailsId
} }
if (res.data && res.data.isCollect && res.data.isCollect > 0) { if (res.data.list) {
this.isCollect = true
} else {
this.isCollect = false
}
if (res.data.listsDetail) {
this.info = res.data this.info = res.data
this.title = this.info.title this.title = this.info.title
let arr = res.data.listsDetail let arr = res.data.list
arr.map((item, index) => { arr.map((item, index) => {
item.num = index + 1 item.num = index + 1
// #ifdef MP-TOUTIAO // #ifdef MP-TOUTIAO
@@ -1592,7 +1609,6 @@
this.videoList[this.current].videoUrl = item.videoUrl this.videoList[this.current].videoUrl = item.videoUrl
//自动播放 //自动播放
this.startPlay(this.current) this.startPlay(this.current)
this.setWxUrl()
return true return true
} }
}) })
@@ -1701,12 +1717,9 @@
indexs = 0 indexs = 0
} }
console.log(this.videoList); const currentIndex = this.videoList.findIndex(v => v.courseDetailsId == (
this.videoList.map((item, index) => { courseDetailsId ? courseDetailsId : res.data.current.courseDetailsId))
if (item.courseDetailsId == courseDetailsId) { this.current = currentIndex == -1 ? 0 : currentIndex
this.current = index
}
})
//重新计算当前在播放哪个视频 //重新计算当前在播放哪个视频
this.comNumVideo() this.comNumVideo()
if (indexs != -1 && this.meunList.length > 0) { if (indexs != -1 && this.meunList.length > 0) {
@@ -1741,7 +1754,6 @@
this.setHistor(this.videoList[this.current].courseId, this.videoList[this.current] this.setHistor(this.videoList[this.current].courseId, this.videoList[this.current]
.courseDetailsId) .courseDetailsId)
this.$nextTick(() => { this.$nextTick(() => {
this.setWxUrl()
if (!this.videoList[this.current].videoUrl) { //不能播放的显示购买弹窗 if (!this.videoList[this.current].videoUrl) { //不能播放的显示购买弹窗
this.zongPrice = this.info.price this.zongPrice = this.info.price
this.countPrice = this.videoList[this.current].price this.countPrice = this.videoList[this.current].price
@@ -1765,32 +1777,27 @@
}) })
}, },
setWxUrl() { setHistor(courseId, courseDetailsId, now = false) {
// // #ifdef MP-WEIXIN
// if (!this.videoList[this.current].wxUrl) {
// let data = {
// wxCourseDetailsIds: this.videoList[this.current].wxCourseDetailsId
// }
// this.$Request.postJson('/app/course/selectWxVideoUrl', data).then(res => {
// if (res.code == 0 && res.data) {
// this.videoList[this.current].wxUrl = res.data[0].mp4_url
// }
// })
// }
// // #endif
},
setHistor(courseId, courseDetailsId) {
if (uni.getStorageSync('token')) {
let data = { let data = {
courseId: courseId, courseId: courseId,
courseDetailsId: courseDetailsId, courseDetailsId: courseDetailsId,
classify: 3, classify: 3,
type: 1 type: 1
} }
this.$Request.postJson('/app/courseCollect/insertCourseCollect', data).then(res => {}) if (uni.getStorageSync('token')) {
} clearTimeout(this.timer)
if (now) {
this.$Request.postJson('/app/courseCollect/insertCourseCollect', data).then(res => {
})
return
}
this.timer = setTimeout(() => {
this.$Request.postJson('/app/courseCollect/insertCourseCollect', data).then(res => {
})
}, 3000)
}
}, },
//swiper上下切换事件 //swiper上下切换事件
change(e) { change(e) {
@@ -1914,27 +1921,30 @@
} }
this.$nextTick(() => { this.$nextTick(() => {
//插入历史记录 //插入历史记录
this.setHistor(this.videoList[this.current].courseId, this.videoList[this.current] clearTimeout(this.timer)
.courseDetailsId) const {
this.setWxUrl() courseId,
courseDetailsId,
videoUrl
} = this.videoList[this.current]
if (videoUrl) {
this.setHistor(courseId, courseDetailsId)
}
// #ifndef MP-TOUTIAO // #ifndef MP-TOUTIAO
// 把选择的视频的自动播放设置为true // 把选择的视频的自动播放设置为true
this.videoList[this.current].autoPlay = true this.videoList[this.current].autoPlay = true
//让当前选择的视频播放 //让当前选择的视频播放
this.startPlay(this.current) this.startPlay(this.current)
// #endif // #endif
//更新视图 //更新视图
this.$forceUpdate() this.$forceUpdate()
}) })
}, },
startPlay(current) { startPlay(current) {
console.log(222222)
if (this.videoContext) { //判断之前是否有视频的上下文 if (this.videoContext) { //判断之前是否有视频的上下文
this.videoContext.stop() this.videoContext.stop()
this.videoContext = null this.videoContext = null
} }
console.log(this.videoList[current])
let numIdCurr = this.videoList[current].courseDetailsId let numIdCurr = this.videoList[current].courseDetailsId
if (this.videoList[current].videoUrl) { //已经购买可直接播放 if (this.videoList[current].videoUrl) { //已经购买可直接播放
// 播放时记录当前播放的id // 播放时记录当前播放的id
@@ -1946,7 +1956,6 @@
//播放当前的 //播放当前的
this.videoContext.play() this.videoContext.play()
this.$forceUpdate() this.$forceUpdate()
this.setWxUrl()
}) })
} }
} else { //没有视频链接则表示没有权限,需要购买 弹出购买弹窗 } else { //没有视频链接则表示没有权限,需要购买 弹出购买弹窗
@@ -1957,17 +1966,17 @@
} }
}, },
//播放时的回掉 //播放时的回掉
videoPlay(videoId) { videoPlay(videoId, courseDetailsId) {
// this.courseDetailsId = courseDetailsId // this.courseDetailsId = courseDetailsId
if (!this.playFlag) { if (!this.playFlag) {
if (this.isGetDataList) { if (this.isGetDataList) {
this.getDataList(this.courseId, this.videoList[this.current].courseDetailsId,true); this.getDataList(this.courseId, courseDetailsId, true);
} }
this.isGetDataList = true; this.isGetDataList = true;
this.playFlag = true this.playFlag = true
this.$Request.getT('app/course/viewCourse', { this.$Request.getT('app/course/viewCourse', {
courseId: this.courseId, courseId: this.courseId,
courseDetailsId: this.videoList[this.current].courseDetailsId, courseDetailsId: courseDetailsId,
type: 'start' type: 'start'
}).then(res => { }).then(res => {
console.log('播放开始') console.log('播放开始')