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 (
直播中
)}