import { Cell, Dialog, Icon, Image, List, Rate, Sticky, Toast } from 'vant' import { defineComponent } from 'vue' import styles from './model/teacher-header.module.less' import iconTeacher from '@common/images/icon_teacher.png' import musicCert from '@common/images/music_cert.png' import teacherCert from '@common/images/teacher_cert.png' import request from '@/helpers/request' import ColResult from '@/components/col-result' import { postMessage } from '@/helpers/native-message' import ColSearch from '@/components/col-search' import IconXueli from '@common/images/icon-xueli.png' import IconJiaozi from '@common/images/icon-jiaozi.png' import dayjs from 'dayjs' export const getAssetsHomeFile = (fileName: string) => { const path = `./images/${fileName}` const modules = import.meta.globEager('./images/*') return modules[path].default } export default defineComponent({ name: 'teacher-follow', data() { return { userInfo: {} as any, starGrade: 0, subjectNameList: [], list: [], dataShow: true, // 判断是否有数据 loading: false, finished: false, params: { username: '', page: 1, rows: 20 } } }, mounted() { this.getList() }, methods: { getSubjectNameList(subject: string) { const subjectList = subject.split(',') return subjectList || [] }, onSearch(val: string) { this.params.username = val this.onSort() }, onSort() { 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/student/queryMyFollow', { 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 } }, async onUnLike(item: any) { Dialog.confirm({ message: '确定取消关注吗?', confirmButtonColor: 'var(--van-primary)' }).then(async () => { try { await request.get('/api-student/teacher/starOrUnStar', { params: { userId: item.userId, starStatus: 0 } }) Toast('取消关注成功') setTimeout(() => { this.onSort() }, 1000) } catch {} }) }, // 检验是否有对应徽章 checkBadge(type: string, item: any) { // tag : 老师点亮图标 // STYLE:个人风采 // VIDEO:视频课 // LIVE:直播课, // MUSIC:曲目 逗号隔开 let status = false switch (type) { case 'STYLE': case 'VIDEO': case 'LIVE': case 'MUSIC': if (item.tag) { status = item.tag.indexOf(type) > -1 } break case 'VIP': if (item.membershipStartTime && item.membershipEndTime) { const startTime = dayjs(item.membershipStartTime).valueOf() const endTime = dayjs(item.membershipEndTime).valueOf() const nowTime = dayjs().valueOf() status = nowTime >= startTime && nowTime <= endTime } else { status = false } break case 'DEGREE': case 'TEACHER': status = item.tag.includes(type) break default: status = false break } return status } }, render() { return (
{this.dataShow ? ( {this.list.map((item: any) => (
{ e.stopPropagation() sessionStorage.removeItem('teacherHomeTabs') this.$router.push({ path: '/teacherHome', query: { teacherId: item.userId, tabs: 'single' } }) }} >
{ // 判断是否在直播中 if (item.liveFlag === 1) { e.stopPropagation() postMessage({ api: 'joinLiveRoom', content: { roomId: item.roomUid, teacherId: item.userId } }) } }} > {item.liveFlag === 1 && (

直播中

)}
{item.userName || `游客${item.userId || ''}`}
{this.checkBadge('TEACHER', item.teacher) && ( )} {this.checkBadge('DEGREE', item.teacher) && ( )}
勋章:
评分:
{this.starGrade ? ( ) : ( 暂无评分 )}
{this.getSubjectNameList(item.subjectName).map( (item: any) => ( {item} ) )}
粉丝 {item.fansNum || 0}
已上课时 {item.expTime || 0}
{ e.stopPropagation() this.onUnLike(item) }} > 取消关注
))}
) : ( )}
) } })