|
@@ -27,7 +27,7 @@ import icon_3_0 from "./image/icon_3_0.png";
|
|
|
import icon_3_1 from "./image/icon_3_1.png";
|
|
|
import icon_3_2 from "./image/icon_3_2.png";
|
|
|
import iconBack from "./image/icon-back.png";
|
|
|
-import { evaluatingData } from "/src/view/evaluating";
|
|
|
+import { evaluatingData, startCheckDelay } from "/src/view/evaluating";
|
|
|
import { IPostMessage } from "/src/utils/native-message";
|
|
|
import state from "/src/state";
|
|
|
|
|
@@ -37,6 +37,7 @@ export default defineComponent({
|
|
|
setup(props, { emit }) {
|
|
|
// startTune定时器
|
|
|
let startTuneTimer: any = null
|
|
|
+ let checkErjiTimer: any = null
|
|
|
const anim = ref();
|
|
|
const data = reactive({
|
|
|
show: false,
|
|
@@ -52,6 +53,8 @@ export default defineComponent({
|
|
|
startTuneResult: false, // 发送startTune后,能否收到正常的result回调
|
|
|
abnormalPopShow: false, // 异常弹窗
|
|
|
});
|
|
|
+ // 调用'isWiredHeadsetOn'最小时间间隔,1秒
|
|
|
+ let minInterval = 0;
|
|
|
/** 获取耳机状态 */
|
|
|
const getEarphoneState = async () => {
|
|
|
const res = await getEarphone();
|
|
@@ -61,6 +64,12 @@ export default defineComponent({
|
|
|
/** 持续检测耳机状态 */
|
|
|
const keepCheckEarphone = async () => {
|
|
|
if (data.step >= 7 || !data.show) return;
|
|
|
+ let momentTime = +new Date()
|
|
|
+ // console.log('间隔123',momentTime - minInterval)
|
|
|
+ if (momentTime - minInterval < 1000) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ minInterval = momentTime
|
|
|
evaluatingData.earphone = await getEarphoneState();
|
|
|
// console.log('erji',evaluatingData.earphone,data.step)
|
|
|
if (evaluatingData.earphone) {
|
|
@@ -75,7 +84,7 @@ export default defineComponent({
|
|
|
data.checkStatus = "init"
|
|
|
}
|
|
|
}
|
|
|
- setTimeout(() => {
|
|
|
+ checkErjiTimer = setTimeout(() => {
|
|
|
keepCheckEarphone();
|
|
|
}, 1000);
|
|
|
};
|
|
@@ -109,18 +118,22 @@ export default defineComponent({
|
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
|
+ clearTimeout(checkErjiTimer)
|
|
|
data.show = true;
|
|
|
sendResult(listenerResult);
|
|
|
addCheckPlayEnd(checkAudioPlayEnd);
|
|
|
keepCheckEarphone();
|
|
|
});
|
|
|
onUnmounted(() => {
|
|
|
+ clearTimeout(checkErjiTimer)
|
|
|
data.show = false;
|
|
|
removeResult(listenerResult);
|
|
|
removeCheckPlayEnd(checkAudioPlayEnd);
|
|
|
});
|
|
|
|
|
|
const handleStartTune = async () => {
|
|
|
+ // 检测APP端socket状态
|
|
|
+ await startCheckDelay();
|
|
|
// data.step = evaluatingData.earphone ? 4 : 3;
|
|
|
if (evaluatingData.earphone) {
|
|
|
if (data.step <= 5) {
|
|
@@ -183,16 +196,19 @@ export default defineComponent({
|
|
|
};
|
|
|
|
|
|
const resetCheck = () => {
|
|
|
+ api_toggleTune("stop");
|
|
|
clearTimeout(data.startAbnormalTimer);
|
|
|
data.abnormalPopShow = false
|
|
|
data.step = 2
|
|
|
data.checkStatus = 'init'
|
|
|
data.count = 0
|
|
|
data.startTuneResult = false
|
|
|
+ evaluatingData.delayCheckSocketError = false
|
|
|
}
|
|
|
watch(
|
|
|
() => evaluatingData.delayCheckSocketError,
|
|
|
() => {
|
|
|
+ // 监听到网络异常,重置延迟检测状态
|
|
|
if (evaluatingData.delayCheckSocketError) {
|
|
|
resetCheck()
|
|
|
}
|
|
@@ -210,6 +226,7 @@ export default defineComponent({
|
|
|
{/*返回按钮*/}
|
|
|
<img class={styles.delayBackBtn} src={iconBack} onClick={() => {
|
|
|
clearTimeout(startTuneTimer)
|
|
|
+ api_toggleTune("stop");
|
|
|
emit("back")
|
|
|
}} />
|
|
|
{/* 异常提示弹窗 */}
|