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' import { visibility } from 'html2canvas/dist/types/css/property-descriptors/visibility'; export default defineComponent({ name: 'coai-guide', emits: ['close'], setup(props, { emit }) { const data = reactive({ box: {}, show: false, /** * width: px2vw(840), height: px2vw(295) */ steps: [ { ele: '', eleRect: {} as DOMRect, img: getImage('home1.png'), handStyle: { top: '0.91rem' }, imgStyle: { left: px2vw(295), width: px2vw(840), height: px2vw(295) }, btnsStyle: { top: px2vw(215), left: px2vw(540), }, boxStyle:{ border:'none', width:'0px', height:'0px', backgroundColor: 'transparent' // visibility: 'hidden' }, eleRectPadding:{ left:7, top:7, width:14, height:14 } }, { ele: '', img: getImage('home2.png'), imgStyle: { top: '51Px', left: '-18em', width: px2vw(401), height: px2vw(227) }, btnsStyle: { top: px2vw(200), left: px2vw(-90), }, boxStyle:{ borderRadius:'25px' }, eleRectPadding:{ left:7, top:7, width:14, height:14 } }, { ele: '', img: getImage('home3.png'), handStyle: { top: '-1.39rem', left: '0.17rem', transform: 'rotate(180deg)' }, imgStyle: { top:px2vw(575), width: px2vw(454), height: px2vw(227), left:px2vw(282) }, btnsStyle: { top:px2vw(730), left:px2vw(450) }, eleRectPadding:{ left:44, top:44, width:88, height:88 } }, { ele: '', img: getImage('home4.png'), handStyle: { top: '-1.39rem', left: '1.4rem', transform: 'rotate(180deg)' }, imgStyle: { top: '4rem', left: px2vw(-310), width: px2vw(477), height: px2vw(227), }, btnsStyle: { top: '-0.85rem', left: '-3rem', 'justify-content': 'center', padding: 0 }, eleRectPadding:{ left:7, top:7, width:14, height:14 } } ], step: 0 }); const tipShow = ref(false); const guideInfo = localStorage.getItem('teacher-guideInfo'); if (guideInfo && JSON.parse(guideInfo).coaiGuide) { tipShow.value = false; } else { tipShow.value = true; } const getStepELe = () => { const ele: HTMLElement = document.getElementById(`home-${data.step}`)!; console.log(`coai-${data.step}`,data.steps[data.step].eleRectPadding); 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' }; } }; onMounted(() => { getStepELe(); }); const handleNext = () => { if (data.step >= 3) { endGuide(); return; } data.step = data.step + 1; getStepELe(); }; const endGuide = () => { let guideInfo = JSON.parse(localStorage.getItem('teacher-guideInfo')) || null; if (!guideInfo) { guideInfo = { homeGuide: true }; } else { guideInfo.homeGuide = true; } localStorage.setItem('teacher-guideInfo', JSON.stringify(guideInfo)); tipShow.value = false; // localStorage.setItem('endC') }; return () => ( <> {tipShow.value ? (