import { defineComponent, ref, onMounted, nextTick, onUnmounted, reactive, computed } from 'vue'; import styles from './index.module.less'; import { NImage, NBadge, NPopover, NIcon, NModal, NTooltip } from 'naive-ui'; import styles2 from './modals/suggestion-option.module.less'; import schoolIcon from './images/schoolIcon.png'; import teacherIcon from './images/teacherIcon.png'; import messageIcon from './images/messageIcon.png'; import closeIcon from './images/closeIcon.png'; import clockIcon from './images/clockIcon.png'; import schoolDot from './images/schoolDot.png'; import personIcon from './images/personIcon.png'; import iconAboutus from './images/icon-aboutus.png'; import { useUserStore } from '@/store/modules/users'; import inFront from './images/inFront.png'; import inBack from './images/inBack.png'; import submitBtn from './images/submitBtn.png'; import sealing from './images/sealing.png'; import boxBg from './images/boxBg.png'; import { useRouter, useRoute } from 'vue-router'; import { storeToRefs } from 'pinia'; import opinionIcon from './images/opinionIcon.png'; import inviteIcon from './images/invite_student_icon.png'; import gnydIcon from './images/gnyd.png'; import classHistoryIcon from './images/classHistoryIcon.png'; import 'animate.css'; import ForgotPassword from '/src/views/setting/modal/forgotPassword'; import ImGroup from './imGroup'; import SuggestionOption from './modals/suggestion-option'; import dayjs from 'dayjs'; import ClassModal from '/src/views/home/modals/class-modal'; import { suggestMessageUnread } from '/src/api/user'; import { eventGlobal } from '/src/utils'; import { usePrepareStore } from '/src/store/modules/prepareLessons'; import { schoolDetail } from '/src/views/studentList/api'; import AddStudentModel from '/src/views/studentList/modals/addStudentModel'; import { modalClickMask } from '/src/state'; export default defineComponent({ name: 'layoutTop', setup() { const router = useRouter(); const noReadCount = ref(0); // 未读数 const showHeadFlag = ref(false); const showImGroup = ref(false); const showImGroupLoading = ref(true); const showSuggestionViseble = ref(false); const users = useUserStore(); const showWord = ref(false); const { info } = storeToRefs(users); const userInfoStatus = ref(false); const classRecordStatus = ref(false); const prepareStore = usePrepareStore(); const state = reactive({ addStudentVisible: false, activeRow: {} as any }); const oncheckEditStatus = (callBack: any) => { showHeadFlag.value = false; userInfoStatus.value = false; if (prepareStore.getIsEditResource) { eventGlobal.emit('pageBeforeLeave', () => callBack()); } else { callBack(); } }; const gotoPerson = () => { userInfoStatus.value = false; router.push({ path: '/setting', query: { activeTab: 'person' } }); }; const gotoSchool = () => { router.push({ path: '/setting', query: { activeTab: 'school' } }); }; const suggestionOptionRef = ref(); const resetPwd = () => { showHeadFlag.value = false; showWord.value = true; userInfoStatus.value = false; }; const aboutUs = () => { router.push({ path: '/aboutUs' }); }; const body = document.querySelector('body'); if (body) { body.className = 'myBody body'; } const showOption = () => { showSuggestionViseble.value = true; if (suggestionOptionRef.value) { suggestionOptionRef.value.onReset(); } console.log(suggestionOptionRef.value, 'suggestionOptionRef'); }; // 邀请学生二维码 const showInviteQrcode = async () => { try { const { schoolInfos } = users.getUserInfo; const schoolId = schoolInfos.length > 0 ? schoolInfos[0].id : null; if (schoolId) { const { data } = await schoolDetail({ id: schoolId }); state.activeRow = data; state.addStudentVisible = true; } } catch { // } }; const suggestionStatus = ref(false); const getSuggestMessageUnread = async () => { try { const { data } = await suggestMessageUnread(); const temp = data || []; let system: any = {}; temp.forEach((item: any) => { if (item.group === 'SYSTEM') { system = item; } }); if (system.number > 0) { suggestionStatus.value = system.number > 0 ? true : false; } else { suggestionStatus.value = false; } } catch { // } }; onMounted(() => { window.addEventListener('message', onImMessage); showImGroupLoading.value = true; showImGroup.value = true; getSuggestMessageUnread(); eventGlobal.on('onSuggestionRead', () => { if (suggestionStatus.value) { getSuggestMessageUnread(); } }); nextTick(() => { setTimeout(() => { showImGroup.value = false; }, 50); setTimeout(() => { showImGroupLoading.value = false; if (body) { body.className = 'myBody'; } }, 1000); }); }); const onImMessage = (evt: MessageEvent) => { if (evt.data.api === 'onImClose') { showImGroup.value = false; } else if (evt.data.api === 'getNoReadMessageCount') { console.log(evt, 'onMessage'); noReadCount.value = evt.data.count || 0; } }; onUnmounted(() => { window.removeEventListener('message', onImMessage); }); const imglist = [inFront, inBack, submitBtn, sealing, boxBg]; const loadImg = (imgList: any) => { for (let i = 0; i < imgList.length; i++) { const img = new Image(); // let currentSrc = '' img.src = imgList[i]; img.onload = function (e) { // console.log('加载完毕', e, img.complete); }; img.onerror = function (e) { // console.log('加载错误', e); }; } }; loadImg(imglist); // 功能引导 const route = useRoute(); const helpNoteList = reactive({ baseListTab: '' }); const helpNoteStatus = computed(() => { const routePath = route.path; const hidePath = [ '/classDetail', '/classStudentDetail', '/notation', '/xiaoku-ai', '/studentDetail', '/classStudentRecode', '/afterWorkDetail' ]; // 单独判断个人信息页面[学校设置]有引导 if (route.path === '/setting') { return helpNoteList.baseListTab === 'school' ? true : false; } else { return hidePath.includes(routePath) ? false : true; } }); return () => ( <>
{/* {info.value.schoolInfos[0].tenantName} |{' '} */} {(info.value?.schoolInfos && info.value?.schoolInfos[0].name) || ''}
{info.value.nickname}
), default: () => info.value.nickname }}个人信息
学校信息
修改密码
关于我们
退出登录