import { Button, Cell, Icon, Image, Popup, Rate, Toast } from 'vant' import { defineComponent } from 'vue' import styles from './teacher-header.module.less' import { postMessage } from '@/helpers/native-message' import iconTeacher from '@common/images/icon_teacher.png' import request from '@/helpers/request' // import IconXueli from '@common/images/icon-xueli.png' // import IconJiaozi from '@common/images/icon-jiaozi.png' // import IconChat from '../images/icon-chat.png' import iconSmallLive from '../images/icon-small-live.png' export const getAssetsHomeFile = (fileName: string) => { const path = `../images/${fileName}` const modules = import.meta.globEager('../images/*') return modules[path].default } export default defineComponent({ name: 'teacher-header', props: { userInfo: { type: Object, default: () => ({}) }, teacherId: { type: String || Number, default: '' } }, emits: ['star'], data() { return { iconShow: false } }, computed: { subjectNameList() { const userInfo: any = this.userInfo const subjectName = userInfo.subjectName return subjectName ? subjectName.split(',') : [] }, starGrade() { const { starGrade } = this.userInfo as any return Number(starGrade) || 0 } }, methods: { async onStart() { // 关注与取消关注 try { const star = this.userInfo.isStar ? 0 : 1 await request.get('/api-student/teacher/starOrUnStar', { params: { userId: this.teacherId, starStatus: star } }) // const str = star ? '关注成功' : '已取消关注' // this.userInfo.isStar = star const count = star ? this.userInfo.fansNum + 1 : this.userInfo.fansNum - 1 // this.userInfo.fansNum = count <= 0 ? 0 : count this.$emit('star', { isStar: star, fansNum: count <= 0 ? 0 : count }) // Toast(str) } catch { // } }, // 检验是否有对应徽章 checkBadge(type: string) { // tag : 老师点亮图标 // STYLE:个人风采 // VIDEO:视频课 // LIVE:直播课, // MUSIC:曲目 逗号隔开 let status = false const { userInfo } = this switch (type) { case 'STYLE': case 'VIDEO': case 'LIVE': case 'MUSIC': if (userInfo.tag) { status = userInfo.tag.indexOf(type) > -1 } break case 'VIP': status = userInfo.userVip?.vipType === 'VIP' break case 'SVIP': status = userInfo.userVip?.vipType === 'SVIP' || userInfo.userVip?.vipType === 'PERMANENT_SVIP' break default: status = false break } return status }, openTeacherIcon() { this.iconShow = true } }, render() { const iconList = [ { icon: 'cert_active.png', title: '演奏Mlog老师', des: '个人风采中上传老师风采视频并通过审核' }, { icon: 'video_active.png', title: '教学视频老师', des: '发布您制作的教学视频课程并通过审核' }, { icon: 'live_active.png', title: '直播up老师', des: '达到开通直播权限标准并开通直播功能' }, { icon: 'music_active.png', title: '乐谱歌单老师', des: '上传您制作的乐谱并通过审核' } ] return ( <>
{ // 判断是否在直播中 if (this.userInfo.liveing === 1) { postMessage({ api: 'joinLiveRoom', content: { roomId: this.userInfo.roomUid, teacherId: this.userInfo.userId } }) } }} > {/* iy */} {this.userInfo.liveing === 1 && ( )} {(this.checkBadge('SVIP') || this.checkBadge('VIP')) && ( )}
{this.userInfo.username || `游客${this.userInfo.userId || ''}`}
{this.starGrade ? ( ) : ( '' )}
粉丝 {this.userInfo.fansNum || 0}
已上课时 {this.userInfo.expTime || 0}
{this.subjectNameList.map((item: any) => ( {item} ))}
{/*
{iconList.map(n => { return (
{n.title}
{n.des}
) })}
(this.iconShow = false)} class={styles.closeIcon} src={getAssetsHomeFile('icon-close.png')} />
*/} ) } })