소스 검색

评分中返回问题

liushengqiang 2 년 전
부모
커밋
fb48bfde69
2개의 변경된 파일55개의 추가작업 그리고 43개의 파일을 삭제
  1. 5 0
      src/view/evaluating/index.module.less
  2. 50 43
      src/view/evaluating/index.tsx

+ 5 - 0
src/view/evaluating/index.module.less

@@ -0,0 +1,5 @@
+.scoreMode{
+    z-index: 9999;
+    background: transparent;
+    left: 10vw;
+}

+ 50 - 43
src/view/evaluating/index.tsx

@@ -1,5 +1,6 @@
+import styles from "./index.module.less";
 import { Snackbar } from "@varlet/ui";
-import { closeToast, showLoadingToast } from "vant";
+import { Overlay, Popup, Toast, closeToast, showLoadingToast, showToast } from "vant";
 import { defineComponent, onBeforeUnmount, onMounted, onUnmounted, reactive, ref, watch } from "vue";
 import { getLeveByScore, getLeveByScoreMeasure, IEvaluatings } from "./evaluatResult";
 import {
@@ -26,7 +27,7 @@ import { IPostMessage } from "/src/utils/native-message";
 import { usePageVisibility } from "@vant/use";
 import { browser } from "/src/utils";
 import { getAudioCurrentTime, setAudioCurrentTime, toggleMutePlayAudio } from "../audio-list";
-import testAudio from './testAudio.mp3'
+import testAudio from "./testAudio.mp3";
 
 const browserInfo = browser();
 export const evaluatingData = reactive({
@@ -53,6 +54,8 @@ export const evaluatingData = reactive({
 	resulstMode: false,
 	/** 是否是完整评测 */
 	isComplete: false,
+	/** 评分中弹窗 */
+	scoreLoadingMode: false,
 });
 
 /** 点击开始评测按钮 */
@@ -134,7 +137,7 @@ export const connectWebsocket = async (content: any) => {
  */
 export const handlePerformDetection = async () => {
 	// 检测完成不检测了
-	if (evaluatingData.checkEnd) return
+	if (evaluatingData.checkEnd) return;
 	if (evaluatingData.checkStep === 0) {
 		// 检测耳机
 		const erji = await checkUseEarphone();
@@ -196,6 +199,7 @@ const handleScoreResult = (res?: IPostMessage) => {
 			};
 			// console.log("🚀 ~ evaluatingData.resultData:", evaluatingData.resultData)
 			closeToast();
+			evaluatingData.scoreLoadingMode = false;
 		}
 	}
 };
@@ -250,51 +254,50 @@ const recordStartTimePoint = async (res?: IPostMessage) => {
 		inteveral *= 1000;
 	}
 	evaluatingData.backtime = inteveral || Date.now();
-	console.log("🚀 ~ 开始时间点:", evaluatingData.backtime, "已经录的时间:", Date.now() - inteveral, '记录时间点:', Date.now());
+	console.log("🚀 ~ 开始时间点:", evaluatingData.backtime, "已经录的时间:", Date.now() - inteveral, "记录时间点:", Date.now());
 	// 开始播放
 	playMusic();
 
 	// playTestMusic()
 };
 
-
 const getTestCurrent = () => {
-	const _c = _audio.currentTime * 1000
-	console.log("🚀 ~ 播放的时间测试:", _c)
-	if (_c >= 500){
-		console.error('开始播放的延迟:', Date.now() - evaluatingData.backtime - 500)
-		_audio.pause()
+	const _c = _audio.currentTime * 1000;
+	console.log("🚀 ~ 播放的时间测试:", _c);
+	if (_c >= 500) {
+		console.error("开始播放的延迟:", Date.now() - evaluatingData.backtime - 500);
+		_audio.pause();
 		// 延迟500毫秒播放
 		setTimeout(() => {
-			playMusic()
-		}, 2000)
-		
-		return
+			playMusic();
+		}, 2000);
+
+		return;
 	}
 	setTimeout(() => {
-		getTestCurrent()
-	}, 10)
-}
+		getTestCurrent();
+	}, 10);
+};
 
 const playTestMusic = () => {
 	// _audio = new Audio(state.music)
-	_audio = new Audio(testAudio)
+	_audio = new Audio(testAudio);
 	// _audio.muted = true
 	// _audio.src = testAudio
 	_audio.onplay = () => {
-		console.log('开始播放测试')
-		getTestCurrent()
-	}
+		console.log("开始播放测试");
+		getTestCurrent();
+	};
 	_audio.onloadedmetadata = () => {
-		console.log('测试音频加载完成')
-		console.log('开始播放的时间点', Date.now())
+		console.log("测试音频加载完成");
+		console.log("开始播放的时间点", Date.now());
 		_audio.play();
 		setTimeout(() => {
-			console.log('结束播放的时间点', Date.now(), _audio.currentTime * 1000)
-		}, 500)
-	}
-	_audio.load()
-}
+			console.log("结束播放的时间点", Date.now(), _audio.currentTime * 1000);
+		}, 500);
+	};
+	_audio.load();
+};
 
 /**
  * 结束评测
@@ -311,10 +314,7 @@ export const handleEndEvaluat = (isComplete = false) => {
 	endEvaluating({
 		musicScoreId: state.examSongId,
 	});
-	showLoadingToast({
-		message: "评分中",
-		duration: 0,
-	});
+	evaluatingData.scoreLoadingMode = true;
 	evaluatingData.isComplete = isComplete;
 	// 如果开启了摄像头, 结束录制视频
 	if (state.setting.camera && state.setting.saveToAlbum) {
@@ -339,6 +339,7 @@ export const handleCancelEvaluat = () => {
 	evaluatingData.startBegin = false;
 	// 关闭提示
 	closeToast();
+	evaluatingData.scoreLoadingMode = false;
 	// 取消记录
 	api_proxyServiceMessage({
 		header: {
@@ -386,7 +387,7 @@ export default defineComponent({
 			/** 指法 */
 			finger: false,
 			/** 原音伴奏 */
-			play_mode: ''  as IPlayState,
+			play_mode: "" as IPlayState,
 			/** 评测是否要伴奏 */
 			enableAccompaniment: true,
 		});
@@ -396,25 +397,24 @@ export default defineComponent({
 			record_old_data.finger = state.setting.displayFingering;
 			state.setting.displayFingering = false;
 			// 切换为伴奏
-			record_old_data.play_mode = state.playSource
-			record_old_data.enableAccompaniment = state.setting.enableAccompaniment
+			record_old_data.play_mode = state.playSource;
+			record_old_data.enableAccompaniment = state.setting.enableAccompaniment;
 			// 如果关闭伴奏,评测静音
-			if (!record_old_data.enableAccompaniment){
-				console.log('关闭伴奏')
-				toggleMutePlayAudio(record_old_data.play_mode === 'music' ? 'music' : 'background', true)
+			if (!record_old_data.enableAccompaniment) {
+				console.log("关闭伴奏");
+				toggleMutePlayAudio(record_old_data.play_mode === "music" ? "music" : "background", true);
 			}
 		};
 		/** 还原状态 */
 		const handle_reduction = () => {
 			// 还原指法
 			state.setting.displayFingering = record_old_data.finger;
-			state.playSource = record_old_data.play_mode
+			state.playSource = record_old_data.play_mode;
 
 			// 如果关闭伴奏, 结束评测取消静音
-			if (!record_old_data.enableAccompaniment){
-				toggleMutePlayAudio(record_old_data.play_mode === 'music' ? 'music' : 'background', false)
+			if (!record_old_data.enableAccompaniment) {
+				toggleMutePlayAudio(record_old_data.play_mode === "music" ? "music" : "background", false);
 			}
-
 		};
 
 		watch(pageVisibility, (value) => {
@@ -423,6 +423,7 @@ export default defineComponent({
 			}
 		});
 		onMounted(() => {
+			evaluatingData.scoreLoadingMode = false;
 			hanlde_record();
 			evaluatingData.resultData = {};
 			// evaluatingData.resultData = {...getLeveByScore(90), score: 30, intonation: 10, cadence: 30, integrity: 40}
@@ -445,6 +446,12 @@ export default defineComponent({
 			handle_reduction();
 			console.log("卸载评测模块成功");
 		});
-		return () => <div></div>;
+		return () => (
+			<div>
+				<Overlay className={styles.scoreMode} v-model:show={evaluatingData.scoreLoadingMode}>
+					<Toast duration={0} show={true} message={"评分中"} type="loading"></Toast>
+				</Overlay>
+			</div>
+		);
 	},
 });