|
@@ -0,0 +1,213 @@
|
|
|
+import { NButton } from 'naive-ui';
|
|
|
+import {
|
|
|
+ defineComponent,
|
|
|
+ nextTick,
|
|
|
+ onMounted,
|
|
|
+ reactive,
|
|
|
+ ref,
|
|
|
+ watch
|
|
|
+} from 'vue';
|
|
|
+import styles from './index.module.less';
|
|
|
+import { getImage } from './images';
|
|
|
+
|
|
|
+export default defineComponent({
|
|
|
+ name: 'coai-guide',
|
|
|
+ emits: ['close'],
|
|
|
+ setup(props, { emit }) {
|
|
|
+ const data = reactive({
|
|
|
+ box: {},
|
|
|
+ show: false,
|
|
|
+ steps: [
|
|
|
+ {
|
|
|
+ ele: '',
|
|
|
+ eleRect: {} as DOMRect,
|
|
|
+ img: getImage('coai-1.png'),
|
|
|
+ handStyle: {
|
|
|
+ top: '0.91rem'
|
|
|
+ },
|
|
|
+ imgStyle: {
|
|
|
+ top: '1.5rem'
|
|
|
+ },
|
|
|
+ btnsStyle: {
|
|
|
+ top: '4.5rem',
|
|
|
+ left: '1rem'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ ele: '',
|
|
|
+ img: getImage('coai-2.png'),
|
|
|
+ handStyle: {
|
|
|
+ top: '-1.39rem',
|
|
|
+ left: '0.15rem',
|
|
|
+ transform: 'rotate(180deg)'
|
|
|
+ },
|
|
|
+ imgStyle: {
|
|
|
+ top: '-4rem'
|
|
|
+ },
|
|
|
+ btnsStyle: {
|
|
|
+ top: '-1.3rem',
|
|
|
+ left: '1.3rem'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ ele: '',
|
|
|
+ img: getImage('coai-3.png'),
|
|
|
+ handStyle: {
|
|
|
+ top: '-1.39rem',
|
|
|
+ left: '0.17rem',
|
|
|
+ transform: 'rotate(180deg)'
|
|
|
+ },
|
|
|
+ imgStyle: {
|
|
|
+ top: '-4rem'
|
|
|
+ },
|
|
|
+ btnsStyle: {
|
|
|
+ top: '-1.3rem',
|
|
|
+ left: '1.3rem'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ ele: '',
|
|
|
+ img: getImage('coai-4.png'),
|
|
|
+ handStyle: {
|
|
|
+ top: '-1.39rem',
|
|
|
+ left: '1.4rem',
|
|
|
+ transform: 'rotate(180deg)'
|
|
|
+ },
|
|
|
+ imgStyle: {
|
|
|
+ top: '-4rem',
|
|
|
+ left: '-3.2rem'
|
|
|
+ },
|
|
|
+ btnsStyle: {
|
|
|
+ top: '-0.85rem',
|
|
|
+ left: '-3rem',
|
|
|
+ 'justify-content': 'center',
|
|
|
+ padding: 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ 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 = () => {
|
|
|
+ console.log(`coai-${data.step}`);
|
|
|
+ const ele: HTMLElement = document.getElementById(`coai-${data.step}`)!;
|
|
|
+ if (ele) {
|
|
|
+ const eleRect = ele.getBoundingClientRect();
|
|
|
+ data.box = {
|
|
|
+ left: eleRect.x + 'px',
|
|
|
+ top: eleRect.y + 'px',
|
|
|
+ width: eleRect.width + 'px',
|
|
|
+ height: eleRect.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 ? (
|
|
|
+ <div v-model:show={tipShow.value} class={["n-modal-mask","n-modal-mask-guide"]}>
|
|
|
+ <div class={styles.content} onClick={() => handleNext()}>
|
|
|
+ <div
|
|
|
+ class={styles.backBtn}
|
|
|
+ onClick={(e: Event) => {
|
|
|
+ e.stopPropagation();
|
|
|
+ endGuide();
|
|
|
+ }}>
|
|
|
+ 跳过
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ class={styles.box}
|
|
|
+ style={data.box}
|
|
|
+ id={`modeType-${data.step}`}>
|
|
|
+ {data.steps.map((item: any, index) => (
|
|
|
+ <div
|
|
|
+ onClick={(e: Event) => e.stopPropagation()}
|
|
|
+ class={styles.item}
|
|
|
+ style={{
|
|
|
+ display: index === data.step ? '' : 'none',
|
|
|
+ left: `${item.eleRect?.left}px`,
|
|
|
+ top: `${item.eleRect?.top}px`
|
|
|
+ }}>
|
|
|
+ <img
|
|
|
+ class={styles.img}
|
|
|
+ style={item.imgStyle}
|
|
|
+ src={item.img}
|
|
|
+ />
|
|
|
+ <img
|
|
|
+ class={styles.iconHead}
|
|
|
+ style={item.handStyle}
|
|
|
+ src={getImage('indexDot.png')}
|
|
|
+ />
|
|
|
+ <div class={styles.btns} style={item.btnsStyle}>
|
|
|
+ {data.step + 1 == data.steps.length ? (
|
|
|
+ <>
|
|
|
+ <NButton
|
|
|
+ class={styles.btn}
|
|
|
+ round
|
|
|
+ color="transparent"
|
|
|
+ style={{ 'border-color': '#fff' }}
|
|
|
+ type="primary"
|
|
|
+ onClick={() => {
|
|
|
+ data.step = 0;
|
|
|
+ getStepELe();
|
|
|
+ }}>
|
|
|
+ 再看一遍
|
|
|
+ </NButton>
|
|
|
+ <NButton
|
|
|
+ class={[styles.btn, styles.endBtn]}
|
|
|
+ round
|
|
|
+ type="primary"
|
|
|
+ onClick={() => endGuide()}>
|
|
|
+ 完成
|
|
|
+ </NButton>
|
|
|
+ </>
|
|
|
+ ) : (
|
|
|
+ <NButton
|
|
|
+ class={styles.btn}
|
|
|
+ round
|
|
|
+ type="primary"
|
|
|
+ onClick={() => handleNext()}>
|
|
|
+ 下一步 ({data.step + 1}/{data.steps.length})
|
|
|
+ </NButton>
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ ))}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ ) : null}
|
|
|
+ </>
|
|
|
+ );
|
|
|
+ }
|
|
|
+});
|