123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- import CourseVideoItem from '@/business-components/course-video-item'
- import SectionDetail from '@/business-components/section-detail'
- import UserDetail from '@/business-components/user-detail'
- import { Button, Dialog, Toast } from 'vant'
- import { defineComponent } from 'vue'
- import styles from './index.module.less'
- import request from '@/helpers/request'
- import ColSticky from '@/components/col-sticky'
- import { shareCall } from '../share'
- import { browser } from '@/helpers/utils'
- import { postMessage } from '@/helpers/native-message'
- import { state } from '@/state'
- import qs from 'query-string'
- export const getAssetsHomeFile = (fileName: string) => {
- const path = `../images/${fileName}`
- const modules = import.meta.globEager('../images/*')
- return modules[path].default
- }
- export default defineComponent({
- name: 'VideoDetail',
- data() {
- const query = this.$route.query
- return {
- userInfo: {} as any,
- detailList: [],
- buyUserList: [], // 购买学生数
- dataShow: true, // 判断是否有数据
- loading: false,
- finished: false,
- recomUserId: query.recomUserId, // 分享人编号
- params: {
- videoLessonGroupId: query.groupId,
- page: 1,
- rows: 20
- },
- wxStatus: false
- }
- },
- created() {
- if (browser().isApp) {
- if (state.platformType === 'STUDENT') {
- // 自动跳转到学生端视频课详情购买页
- window.location.replace(
- `${location.origin}/student/#/videoDetail?${qs.stringify(
- this.$route.query
- )}`
- )
- } else if (state.platformType === 'TEACHER') {
- Dialog.alert({
- title: '提示',
- message: '请使用酷乐秀学生端扫码打开',
- confirmButtonColor: '#2dc7aa'
- }).then(() => {
- postMessage({ api: 'back' })
- })
- }
- } else {
- // 如果不在app里面则不需要唤起操作
- this.reCall()
- }
- },
- async mounted() {
- try {
- const res = await request.post(`/api-teacher/open/videoShareProfit`, {
- data: {
- bizId: this.params.videoLessonGroupId,
- userId: this.recomUserId
- }
- })
- const result = res.data || {}
- const { lessonGroup, detailList } = result.videoGroup
- this.userInfo = {
- username: result.name,
- headUrl: result.avatar,
- buyNum: lessonGroup.countStudent,
- lessonNum: lessonGroup.lessonCount,
- lessonName: lessonGroup.lessonName,
- lessonDesc: lessonGroup.lessonDesc,
- lessonPrice: lessonGroup.lessonPrice,
- lessonCoverUrl: lessonGroup.lessonCoverUrl
- }
- this.detailList = detailList || []
- } catch {
- //
- }
- console.log()
- },
- methods: {
- reCall() {
- const { origin } = location
- let str = origin + '/student/#/videoDetail'
- const params = this.$route.query
- str += `?recomUserId=${this.recomUserId}&groupId=${params.groupId}`
- console.log(str)
- shareCall(str, {})
- },
- onShare() {
- if (browser().weixin) {
- this.wxStatus = true
- return
- }
- this.reCall()
- setTimeout(() => {
- window.location.href = location.origin + '/student/#/download'
- }, 3000)
- }
- },
- render() {
- return (
- <div class={[styles['video-detail'], 'mb12']}>
- <UserDetail userInfo={this.userInfo} />
- <SectionDetail border>
- <p class={styles.introduction}>{this.userInfo.lessonDesc}</p>
- </SectionDetail>
- <SectionDetail
- title="课程列表"
- icon="courseList"
- contentStyle={{ paddingTop: '0' }}
- >
- {this.detailList.map((item: any) => (
- <CourseVideoItem
- class={'mb12'}
- detail={{
- id: item.id,
- title: item.videoTitle,
- content: item.videoContent,
- imgUrl: item.coverUrl
- }}
- />
- ))}
- </SectionDetail>
- <ColSticky position="bottom">
- <div class={['btnGroup']} style={{ paddingTop: '12px' }}>
- <Button block round type="primary" onClick={this.onShare}>
- 下载酷乐秀进入课程
- </Button>
- </div>
- </ColSticky>
- {this.wxStatus && (
- <div
- class={styles.wxpopup}
- onClick={() => {
- this.wxStatus = false
- }}
- >
- <img src={getAssetsHomeFile('wx_bg.png')} alt="" />
- </div>
- )}
- </div>
- )
- }
- })
|