import OHeader from '@/components/o-header' import { Button, Cell, CellGroup, Grid, GridItem, Icon, Image, Popup, showDialog, showToast, Tag } from 'vant' import { defineComponent, onMounted, reactive } from 'vue' import styles from './companion-detail.module.less' import { postMessage } from '@/helpers/native-message' import iconTeacher from '@common/images/icon_teacher.png' import iconMessage from '@common/images/icon-message.png' import iconCallPhone from '@common/images/icon-call-phone.png' import iconCallMessage from '@common/images/icon-call-message.png' import OSticky from '@/components/o-sticky' import request from '@/helpers/request' import { state as baseState } from '@/state' import { useRoute, useRouter } from 'vue-router' import OEmpty from '@/components/o-empty' export default defineComponent({ name: 'companion-detail', setup(props, { slots, attrs, emit }) { const route = useRoute() const router = useRouter() const state = reactive({ showMessage: false, detail: {} as any, classList: [] as any }) const getDetail = async () => { try { const query = route.query const { data } = await request.post('/api-school/teacher/detail', { data: { teacherId: query.id, schoolId: baseState.user.data.school.id } }) state.detail = data const subjects = data.subjectName ? data.subjectName.split(',') : [] state.detail.subjectNames = subjects } catch { // } } const getClassDetail = async () => { try { const query = route.query const { data } = await request.post('/api-school/classGroup/page', { data: { teacherId: query.id, schoolId: baseState.user.data.school.id, page: 1, rows: 100 } }) state.classList = data.rows || [] } catch { // } } const onDetail = async () => { if (state.classList.length > 0) { router.push({ path: '/companion-unbind', query: { id: route.query.id } }) return } try { showDialog({ title: '提示', message: '是否解除绑定', showCancelButton: true }).then(async () => { await request.post('/api-school/classGroup/handoverTeacher', { data: { teacherId: route.query.id } }) setTimeout(() => { showToast('解绑成功') }, 100) setTimeout(() => { router.back() }, 1000) }) } catch { // } } onMounted(() => { getDetail() getClassDetail() }) return () => ( <> {{ icon: () => , title: () => (

{state.detail.nickname}

{state.detail.subjectName ? (

{state.detail.subjectNames.map((subject: any) => ( {subject} ))}

) : ( '' )}

{state.detail.completedCourseScheduleNum || 0}/ {state.detail.totalCourseScheduleNum || 0}

课时

), value: () => ( (state.showMessage = true)} /> ) }}
基本信息
所在班级
{state.classList.map((item: any) => ( {{ title: () => (

{item.name}

{item.orchestraName}

), value: () => (

{item.completeCourseScheduleNum}/{item.courseScheduleNum}

总课时

) }}
))} {state.classList.length <= 0 && }
(state.showMessage = false)} />

联系方式

{ postMessage({ api: 'joinChatGroup', content: { type: 'single', // single 单人 multi 多人 id: state.detail.id } }) state.showMessage = false }} > {{ icon: () => , text: () =>
发送消息
}}
{ postMessage({ api: 'callPhone', content: { id: state.detail.phone } }) state.showMessage = false }} > {{ icon: () => , text: () =>
拨打电话
}}
) } })