import ColHeader from '@/components/col-header' import ColSearch from '@/components/col-search' import { Sticky, Image, List, Popup, Icon } from 'vant' import { defineComponent } from 'vue' import styles from './index.module.less' import VideoItem from '@/student/video-class/video-item' // import VideoItem from './video-item' import banner from './images/banner.png' import request from '@/helpers/request' import ColResult from '@/components/col-result' import { state } from '@/state' import OrganSearch from '@/student/practice-class/model/organ-search' export default defineComponent({ name: 'VideoClass', data() { const sessionSubjectId = sessionStorage.getItem('videoClassSubjectId') const subjectIds = state.user.data?.subjectId || '' const subjectId = subjectIds ? Number(subjectIds.split(',')[0]) : null return { apiSuffix: state.platformType === 'STUDENT' ? '/api-student' : '/api-teacher', search: '', list: [], dataShow: true, // 判断是否有数据 loading: false, finished: false, sessionSubjectId, params: { search: '', lessonSubject: (sessionSubjectId || subjectId || null) as any, subjectName: '全部', page: 1, rows: 20 }, searchStatus: false, openStatus: false, subjectList: [] } }, async mounted() { try { const res = await request.get( `${this.apiSuffix}/subject/subjectSelect?type=VIDEO` ) this.subjectList = res.data || [] } catch { // } const list = this.subjectList const userSubjectId = this.params.lessonSubject ? [this.params.lessonSubject] : state.user.data?.subjectId.split(',').map(n => parseInt(n)) || [ this.params.lessonSubject ] let isRest = true for (let i = 0; i < list.length; i++) { const subjects = (list[i] as any).subjects || [] for (let j = 0; j < subjects.length; j++) { if (userSubjectId.includes(subjects[j].id + '')) { this.params.lessonSubject = subjects[j].id this.params.subjectName = subjects[j].name isRest = false break } } } if (isRest && list.length && (list[0] as any).subjects) { this.params.lessonSubject = (list[0] as any).subjects[0].id this.params.subjectName = (list[0] as any).subjects[0].name } sessionStorage.removeItem('videoClassSubjectId') this.getList() }, methods: { async getList() { try { const params: any = { ...this.params } // 只有学生端会有version if (state.version) { params.version = state.version || '' // 处理ios审核版本 params.platform = state.platformType === 'STUDENT' ? 'ios-student' : 'ios-teacher' } const url = state.platformType === 'STUDENT' ? '/api-student/videoLesson/selectGroup' : '/api-teacher/videoLessonGroup/page' // 处理搜索,老师端分享用 // if (state.platformType === 'TEACHER') { params.myself = false // } const res = await request.post(url, { data: { ...params } }) 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 } }, onSort() { this.params.page = 1 this.list = [] this.dataShow = true // 判断是否有数据 this.loading = false this.finished = false this.searchStatus = false this.getList() }, onSearch(val: string) { this.params.search = val this.onSort() }, onDetail(item: any) { const params: any = { groupId: item.id } // 判断是否是老师端,如果是,则添加分享按钮 if (state.platformType === 'TEACHER') { params.share = 1 } this.$router.push({ path: '/videoDetail', query: params }) } }, render() { return (