import { NButton } from 'naive-ui'; import { defineComponent, nextTick, onMounted, reactive, ref, watch } from 'vue'; import styles from './index.module.less'; import { getImage } from './images'; import {px2vw} from '@/utils/index' export default defineComponent({ name: 'myColloge-guide', emits: ['close'], setup(props, { emit }) { const data = reactive({ box: { height:'0px', } as any, show: false, /** * width: px2vw(840), height: px2vw(295) */ steps: [ { ele: '', img: getImage('myColloge1.png'), imgStyle: { top: '100%', left: '630px', width: '458px', height:'291px' }, btnsStyle: { bottom: '96px', left: '780px', }, eleRectPadding:{ left:7, top:7, width:14, height:14 }, type:'bottom' }, ], step: 0 }); const tipShow = ref(false); const guideInfo = localStorage.getItem('teacher-guideInfo'); if (guideInfo && JSON.parse(guideInfo).myColloge) { tipShow.value = false; } else { tipShow.value = true; } const getStepELe = () => { const ele: HTMLElement = document.getElementById(`myColloge-${data.step}`)!; if (ele) { const eleRect = ele.getBoundingClientRect(); const left = data.steps[data.step].eleRectPadding?.left || 0; const top = data.steps[data.step].eleRectPadding?.top || 0; const width = data.steps[data.step].eleRectPadding?.width || 0; const height = data.steps[data.step].eleRectPadding?.height || 0 data.box = { left: eleRect.x - left+ 'px', top: eleRect.y - top +'px', width: eleRect.width + width+'px', height: eleRect.height +height+ 'px' }; console.log(`coai-${data.step}`,data.box); } }; onMounted(() => { getStepELe(); }); const handleNext = () => { if (data.step >= 4) { endGuide(); return; } data.step = data.step + 1; getStepELe(); }; const endGuide = () => { let guideInfo = JSON.parse(localStorage.getItem('teacher-guideInfo') || '') || null; if (!guideInfo) { guideInfo = { myColloge: true }; } else { guideInfo.myColloge = true; } localStorage.setItem('teacher-guideInfo', JSON.stringify(guideInfo)); tipShow.value = false; // localStorage.setItem('endC') }; return () => ( <> {tipShow.value ? (