import { defineComponent, onMounted, reactive, ref } from "vue"; import styles from "./index.module.less"; import { Button, Icon, Popup } from "vant"; import icons from "./image/icons.json"; import state from "/src/state"; import { getQuery } from "/src/utils/queryString"; export default defineComponent({ name: "DetailGuide", props: { fingeringMode: { type: String, default: "", }, }, emits: ["close"], setup(props, { emit }) { const query = getQuery(); const data = reactive({ box: {}, show: true, steps: [ { className: "boxItem1", classTip: "", des: `快点击下排按钮听听${state.fingeringInfo.code}的声音吧,按钮可以滑动哦~`, img: icons.icon_cursor_1, }, { className: "boxItem2", classTip: "boxTip2", des: "这里可以切换音调,查看不同音调的指法~", img: icons.icon_cursor_2, }, { className: "boxItem3", classTip: "boxTip3", des: "可以通过手势放大缩小乐器哦~", img: icons.icon_cursor_3, }, ], step: 0, }); const steps = ["finger-note-0", "finger-note-1", "finger-note-2"]; const getStepELe = () => { const ele: HTMLElement = document.getElementById(steps[data.step])!; console.log(data.step, ele); if (ele) { const eleRect = ele.getBoundingClientRect(); const increment = data.step === 2 ? eleRect.width : 0; data.box = { left: eleRect.x - increment + "px", top: eleRect.y + "px", width: (data.step === 2 ? 0 : eleRect.width) + "px", height: (data.step === 2 ? 0 : eleRect.height) + "px", }; } else { handleNext(); } }; onMounted(() => { getStepELe(); }); const handleNext = () => { if (data.step >= 2) { endGuide(); return; } data.step = data.step + 1; getStepELe(); }; const endGuide = () => { emit("close", true); }; return () => (
handleNext()}>
{data.steps.map((item, index) => (
))}
e.stopPropagation()}> {data.steps.map((item, index) => (
{item.des}
))}
); }, });