import { defineComponent, reactive, ref, watch } from "vue"; import { Popover, Icon } from "vant"; import icons from "../icons/index.json"; import iconChild from "./icons/child.png"; import DotIcon from "./icons/dot.png"; import DotActiveIcon from "./icons/dot-active.png"; import DotErrorIcon from "./icons/dot-error.png"; import styles from "./index.module.less"; import state from "/src/state"; import { evaluatingData } from "/src/view/evaluating"; import { getScoreData } from "./data"; export default defineComponent({ name: "sound-effect", emits: ["close"], setup(props, { emit }) { const scoreData = getScoreData(state.subjectId); const soundEffectData = reactive({ step: 0, tips: ["左边红灯表示吹奏的音过低", "吹奏时请保持中间绿灯亮起", "右边红灯表示吹奏的音过高"], time: 1, }); watch( () => evaluatingData.soundEffectFrequency, () => { // console.log('吹奏',evaluatingData.soundEffectFrequency , scoreData.frequency) const trend = Math.abs(evaluatingData.soundEffectFrequency - scoreData.frequency) <= 10 ? 1 : evaluatingData.soundEffectFrequency > scoreData.frequency ? 2 : 0; soundEffectData.step = trend; if (trend !== 1) { soundEffectData.time = Date.now(); } // 持续时间达到3秒钟,效音成功 if (Date.now() - soundEffectData.time > 3000) { // console.log("效音完成"); emit('close') } } ); /** 跳过本次 */ const handleSelect = (e: {text: string}) => { if (e.text === '关闭校音'){ emit('close', true) return } emit('close') }; return () => (