Merge branch 'develop' of http://25.13.9.101:9000/K17_AITS/tra-app into develop

This commit is contained in:
田岩
2025-07-15 17:55:17 +08:00
9 changed files with 68 additions and 20 deletions
+3 -1
View File
@@ -1,4 +1,6 @@
const _ENV = import.meta.env
function msg(title, duration = 1000) {
uni.showToast({
title: title,
@@ -114,7 +116,7 @@ export const getUserInfo = (key = '') => {
const userInfo = uni.getStorageSync('userInfo')
return '' === key ? userInfo : userInfo[key];
}
export const getPhoneEnvBool = (flag) => _ENV.VITE_APP_ENV === flag
// 将对象和字符串相互转换
+36 -19
View File
@@ -38,9 +38,11 @@
</template>
<script setup>
import { toRefs, ref, computed, unref, onMounted, onUnmounted, nextTick, watch } from 'vue';
import { toRefs, ref, computed, unref, onMounted, onUnmounted, nextTick, watch, getCurrentInstance } from 'vue';
import common from '../../../common/common';
import permission from '@/common/permission.js'
import { getPhoneEnvBool } from '@/common/common.js'
const proxy = getCurrentInstance()
const emit = defineEmits(['uploadVoice', 'submitAnswer','startRecord'])
const props = defineProps({
isDisabled:{
@@ -67,10 +69,11 @@ const audioObj = uni.createInnerAudioContext()
//#ifdef APP-PLUS
// app端
const recordObjCom = ref({})
const IsAndEnv = getPhoneEnvBool('AND')
const initRecord = () => {
recordObjCom.value = uni.getRecorderManager()
startRecord()
stopRecord()
// startRecord()
// stopRecord()
unref(recordObjCom)?.onStop((res, duration)=>{
audioPath.value = res.tempFilePath
})
@@ -90,22 +93,36 @@ const initRecord = () => {}
// #endif
onMounted(async ()=>{
initRecord?.()
// //#ifdef APP-PLUS
// //#ifdef __IOS__
// // ios端
// let _recordPerm = permission.judgeIosPermission('record')
// if(!_recordPerm){
// permission.gotoAppPermissionSetting()
// }
// // #endif
// // #endif
// //#ifdef APP-PLUS
// // 安卓端
// let _recordPerm = await permission.requestAndroidPermission('android.permission.RECORD_AUDIO')
// if(_recordPerm !== 1){
// permission.gotoAppPermissionSetting()
// }
// // #endif
//#ifdef APP-PLUS
// 安卓端
if(IsAndEnv){
let _recordPerm = await permission.requestAndroidPermission('android.permission.RECORD_AUDIO')
if(_recordPerm !== 1){
common.show('提示信息', '当前页面需要使用的录音权限,是否前往开启?',true, '取消','确定').then((res) => {
if(res) {
// 去开启权限
permission.gotoAppPermissionSetting()
}else{
// 取消
common.redirectTo('/pages/index/index')
}
})
}
}else{
let _recordPerm = permission.judgeIosPermission('record')
if(!_recordPerm){
common.show('提示信息', '当前页面需要使用的录音权限,是否前往开启?',true, '取消','确定').then((res) => {
if(res) {
// 去开启权限
permission.gotoAppPermissionSetting()
}else{
// 取消
common.redirectTo('/pages/index/index')
}
})
}
}
// #endif
})
// 录音结束
+5
View File
@@ -233,6 +233,8 @@ const getData = async (flag) => {
}
}catch{
}finally{
watchFlag.value +=1
}
};
@@ -583,14 +585,17 @@ const showTalkingModel = ref(false)
// getData('1');
// })
onHide(()=>{
if(watchFlag.value === 1) return
socketStore.closeSocket()
common.show('提示信息', '检测到您已离开,即将退出学习页面。',false, '','确认').then((res) => {
common.redirectTo(`/pages/courseDetail/index?crsId=${crsId.value}&crsNum=${crsNum.value}&from=study`)
}).finally(() => {})
})
onShow(()=>{
if(watchFlag.value === 1) return
socketStore.createSocket()
})
const watchFlag = ref(1)
onUnload(()=>{
changePlayItemId()
teacherVoiceObj?.stop?.()