diff --git a/src/api/examination.js b/src/api/examination.js index df6f23f1..cb4f6734 100644 --- a/src/api/examination.js +++ b/src/api/examination.js @@ -72,4 +72,15 @@ export const queryPaperExamRankingList = (data) => { data }); }; - \ No newline at end of file + + + // 反馈问题 + export const saveTraQnsFeedback = (data) => { + return request({ + url: base_url + '/traCrsPapers/saveTraQnsFeedback', + method: 'post', + toastErrors: true, + data + }); + }; + \ No newline at end of file diff --git a/src/common/common.js b/src/common/common.js index 7fd3b698..a2fdbb7d 100644 --- a/src/common/common.js +++ b/src/common/common.js @@ -21,7 +21,6 @@ function show(title, msg, showCancel = true, cancelText = '取消', confirmText confirmText, success: (res) => { // 统一处理成功回调,解析为布尔值 - console.log('res.confirm', res.confirm); resolve(!!res.confirm); } }; @@ -65,23 +64,23 @@ const hideLoading = () => uni.hideLoading() // 防抖工具函数 function debounce(fn, wait = 300) { - let isLocked = false; // 锁定状态标记 - return function(...args) { - // 如果处于锁定状态,直接返回不执行 - if (isLocked) { - return; - } - // 执行函数 - fn.apply(this, args); - - // 锁定,防止再次执行 - isLocked = true; - - // 等待指定时间后解锁 - setTimeout(() => { - isLocked = false; - }, wait); - }; + let isLocked = false; // 锁定状态标记 + return function(...args) { + // 如果处于锁定状态,直接返回不执行 + if (isLocked) { + return; + } + // 执行函数 + fn.apply(this, args); + + // 锁定,防止再次执行 + isLocked = true; + + // 等待指定时间后解锁 + setTimeout(() => { + isLocked = false; + }, wait); + }; } // 保留当前页面,跳转到应用内的某个页面,使用uni.navigateBack可以返回到原页面。 @@ -174,23 +173,23 @@ export const getUserInfo = (key = '') => { } // 数字转换,把传入的秒转换为HH:mm:ss格式 export const formatSeconds = (seconds) => { - // 处理非数字或负数情况 - if (typeof seconds !== 'number' || isNaN(seconds) || seconds < 0) { - return '00:00:00'; - } + // 处理非数字或负数情况 + if (typeof seconds !== 'number' || isNaN(seconds) || seconds < 0) { + return '00:00:00'; + } - // 计算小时、分钟和剩余秒数 - const hours = Math.floor(seconds / 3600); - const minutes = Math.floor((seconds % 3600) / 60); - const remainingSeconds = Math.floor(seconds % 60); + // 计算小时、分钟和剩余秒数 + const hours = Math.floor(seconds / 3600); + const minutes = Math.floor((seconds % 3600) / 60); + const remainingSeconds = Math.floor(seconds % 60); - // 补零函数:将数字转为两位数字符串 - const padZero = (num) => num.toString().padStart(2, '0'); + // 补零函数:将数字转为两位数字符串 + const padZero = (num) => num.toString().padStart(2, '0'); + + // 拼接成00:00:00格式 + return `${padZero(hours)}:${padZero(minutes)}:${padZero(remainingSeconds)}`; +}; - // 拼接成00:00:00格式 - return `${padZero(hours)}:${padZero(minutes)}:${padZero(remainingSeconds)}`; - }; - /** * 判断当前运行平台是否匹配指定标识 * @param {string} flag - 平台标识:'IOS' 表示苹果iOS平台,'AND' 表示安卓平台 @@ -242,6 +241,41 @@ function isLogin() { return !!getToken(); } +// 封装键盘高度变化处理 +export function setupKeyboardHeightListener(updateCallback) { + // #ifndef APP-PLUS + return () => {}; + // #endif + // #ifdef APP-PLUS + // 获取系统信息 + const systemInfo = uni.getSystemInfoSync(); + // 计算安全区域底部高度 + const safeAreaBottomHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom; + + // 定义处理函数 + const handleKeyboardHeightChange = (res) => { + let keyboardHeight = res.height; + + // 仅在iOS端补偿安全区域高度 + if (systemInfo.platform === 'ios') { + keyboardHeight = Math.max(0, keyboardHeight - safeAreaBottomHeight); // 避免负数 + } + + // 通过回调函数更新外部的响应式变量 + updateCallback(keyboardHeight); + }; + + // 监听键盘高度变化 + uni.onKeyboardHeightChange(handleKeyboardHeightChange); + + // 返回取消监听的函数,方便组件卸载时清理 + return () => { + uni.offKeyboardHeightChange(handleKeyboardHeightChange); + }; + // #endif + +} + export default { getPageCache, setPageCache, diff --git a/src/components/examination/question.vue b/src/components/examination/question.vue index e2657e7c..d31e00aa 100644 --- a/src/components/examination/question.vue +++ b/src/components/examination/question.vue @@ -29,12 +29,10 @@ style="width: 100%; height: 100%" > - + 重答 完成 - - @@ -45,20 +43,6 @@ - 重答 完成 @@ -100,6 +84,10 @@ status: { default: '', type: String + }, + isPreview: { // 是否是预览语音 + default: false, + type: Boolean } }); @@ -151,9 +139,10 @@ console.log('点击播放'); audioStore.playAudio(); }; + let unsubscribe = () =>{}; onMounted(() => { // 2. 监听 Store 中 isPlaying 的变化,实时同步 - const unsubscribe = audioStore.$subscribe((mutation, state) => { + unsubscribe = audioStore.$subscribe((mutation, state) => { isPlaying.value = state.isPlaying; }); // 注册播放完成回调 @@ -185,6 +174,7 @@ audioStore.stopAudio(); // 2. 移除当前组件注册的回调(避免内存泄漏) audioStore.removeCallbacks(); + unsubscribe(); }); diff --git a/src/components/examination/subject.vue b/src/components/examination/subject.vue index a6c3f186..54525e9a 100644 --- a/src/components/examination/subject.vue +++ b/src/components/examination/subject.vue @@ -9,7 +9,7 @@ @@ -32,8 +32,9 @@