import CourseVideoItem from '@/business-components/course-video-item' import SectionDetail from '@/business-components/section-detail' import ColHeader from '@/components/col-header' import ColVideo from '@/components/col-video' import request from '@/helpers/request' import { Cell, Icon, Rate, Tab, Tabs, Image, Button, Sticky, Field, List, Toast, Dialog } from 'vant' import { defineComponent } from 'vue' import styles from './video-class-detail.module.less' import { state } from '@/state' import iconTeacher from '@common/images/icon_teacher.png' import ColResult from '@/components/col-result' import dayjs from 'dayjs' import { onSubmitZero, orderStatus } from '@/views/order-detail/orderStatus' export default defineComponent({ name: 'VideoClassDetail', data() { const query = this.$route.query return { groupId: query.groupId, classId: query.classId, tabIndex: 1, title: '', lessonPrice: 0, useRelationType: '', alreadyBuy: false, videoDetail: {} as any, detailList: [], posterUrl: '', srcUrl: '', message: '', navHeight: 0 as any, currentClassIndex: 1, reload: false, videoContent: '', list: [], dataShow: true, // 判断是否有数据 loading: false, finished: false, params: { page: 1, rows: 20 }, freeRate: 0, // 试看百分比 trySee: false, // 是否试看 videoHeight: '212px' } }, computed: { users() { return state.user.data }, offsetTop() { const navHeight: number = this.navHeight const top = Number(navHeight) + 44 return top + 'px' } }, async mounted() { // 处理视频显示 const width = document.body.clientWidth || document.body.offsetWidth this.videoHeight = (width / 16) * 9 + 'px' this.navHeight = sessionStorage.getItem('navHeight') || 0 try { // await this.__init() const config = await request.get( '/api-student/sysConfig/queryByParamNameList', { params: { paramNames: 'video_lesson_free_rate' } } ) this.freeRate = config.data[0]?.paramValue || 0 } catch {} this.getList() }, methods: { async __init() { this.reload = true try { const res = await request.get( '/api-student/videoLesson/selectVideoLesson', { params: { groupId: this.groupId } } ) const result = res.data || {} this.videoDetail = result.lessonGroup this.title = result.lessonGroup.lessonName this.lessonPrice = result.lessonGroup.lessonPrice this.useRelationType = result.lessonGroup.relationType this.alreadyBuy = result.alreadyBuy this.detailList = result.detailList || [] this.trySee = !result.alreadyBuy this.detailList.forEach((item: any, index: number) => { if (item.id === Number(this.classId)) { this.posterUrl = item.coverUrl this.srcUrl = item.videoUrl this.title = item.videoTitle this.currentClassIndex = index + 1 this.videoContent = item.videoContent } }) } catch { // } this.reload = false }, onSearch() { this.params.page = 1 this.list = [] this.dataShow = true // 判断是否有数据 this.loading = false this.finished = false this.getList() }, async getList() { try { const params = this.params const res = await request.post('/api-student/videoLesson/page', { data: { ...params, videoId: this.classId } }) this.loading = false const result = res.data || {} // 处理重复请求数据 if (this.list.length > 0 && result.pageNo === 1) { return } this.list = this.list.concat(result.rows || []) this.finished = result.pageNo >= result.totalPage this.params.page = result.pageNo + 1 this.dataShow = this.list.length > 0 } catch { this.dataShow = false this.finished = true } }, onPlay(item: any) { // 判断是否点击的是当前播放的视频 if (item.id === Number(this.classId)) { return } this.reload = true this.posterUrl = item.imgUrl this.srcUrl = item.videoUrl this.title = item.title this.currentClassIndex = item.index this.videoContent = item.content this.classId = item.id this.onSearch() setTimeout(() => { this.reload = false }, 0) }, async onSubmit() { try { await request.post('/api-student/videoLesson/evaluate', { data: { isTeacher: 0, videoId: this.classId, content: this.message, studentId: state.user.data.userId } }) Toast('评论成功') this.message = '' setTimeout(() => { this.onSearch() }, 500) } catch {} } }, render() { return (
{/* */} !this.reload && ( 0 ? true : false} trySee={this.trySee} src={this.srcUrl} poster={this.posterUrl} height={this.videoHeight} isBuy onBuyEmit={async () => { if (this.lessonPrice > 0) { this.$router.back() return } try { const userInfo = this.videoDetail orderStatus.orderObject.orderType = 'VIDEO' orderStatus.orderObject.orderName = '视频课购买' orderStatus.orderObject.orderDesc = '视频课购买' orderStatus.orderObject.actualPrice = userInfo.lessonPrice orderStatus.orderObject.recomUserId = '' orderStatus.orderObject.orderNo = '' orderStatus.orderObject.orderList = [ { orderType: 'VIDEO', goodsName: '视频课购买', courseGroupId: userInfo.id, courseGroupName: userInfo.lessonName, coursePrice: userInfo.lessonPrice, teacherName: userInfo.username || `游客${userInfo.teacherId || ''}`, teacherId: userInfo.teacherId, avatar: userInfo.headUrl, relationType: userInfo.relationType, courseInfo: this.detailList, recomUserId: '' } ] await onSubmitZero(() => { Dialog.alert({ message: '领取成功', confirmButtonText: '确定', confirmButtonColor: '#2dc7aa' }).then(() => { this.__init() }) }) } catch { // } }} /> ) }} /> {/* */} ( ), value: () => (
{this.currentClassIndex}/{this.detailList.length} 课时
) }} >
{this.videoContent}
{this.detailList.map((item: any, index: number) => { const musicAlbumInfos = item.musicAlbumInfos || [] const temp = musicAlbumInfos.map((info: any) => { return { relationMusicAlbum: info.relationType, musicAlbumName: info.name, musicAlbumId: info.musicAlbumId, status: info.status, useRelationType: this.useRelationType } }) return ( { if (!this.alreadyBuy && !item.status) { Toast('数据正在更新,请稍后再试') return } if (item.relationMusicAlbum === 'MUSIC') { this.$router.push({ path: '/music-detail', query: { id: item.musicAlbumId } }) } else if (item.relationMusicAlbum === 'ALBUM') { this.$router.push({ path: '/music-album-detail/' + item.musicAlbumId }) } }} /> ) })}
{this.dataShow ? ( {this.list.map((item: any) => ( ( ), title: () => (
{item.userName}
{dayjs(item.evaluateTime).format( 'YYYY年MM月DD日' )}
), label: () => (
{item.content}
) }} /> ))}
) : ( )}
{/* */}
( ) }} />
{/*
*/}
) } })