修复练习答题,开发课程记录页,创建学习记录页
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<view :class="['talking-gif', 'is-play']">
|
||||
<CommonLoading color="#fff" v-show="voiceLoading" />
|
||||
</view>
|
||||
<view class="right-time">{{voiceTime}}</view>
|
||||
<view class="right-time">{{ voiceTime }}</view>
|
||||
<view class="talking-cont">
|
||||
<text :class="['talking-text translate-text loading']" v-show="!translateLoading">
|
||||
{{ showContent }}
|
||||
@@ -14,13 +14,25 @@
|
||||
</view>
|
||||
<view class="btns-cont">
|
||||
<view class="play-btn">
|
||||
<!-- <image class="icon" v-show="!(props.activeVoiceId === dataInfo.id)" @click="playVoice"
|
||||
src="@/static/images/course/play-blue.png" style="width: 100%;height: 100%;"></image> -->
|
||||
<image class="icon"
|
||||
@click.stop="pauseVoice" src="@/static/images/course/stop-blue.png"
|
||||
style="width: 100%;height: 100%;"></image>
|
||||
<!-- <view class="icon text-btn" v-if="type === 1" @click.stop="translateVoice(dataInfo)">文</view> -->
|
||||
<image
|
||||
class="icon"
|
||||
@click="playVoice"
|
||||
src="@/static/images/course/play-blue.png"
|
||||
style="width: 100%; height: 100%"
|
||||
></image>
|
||||
<!-- <image
|
||||
class="icon"
|
||||
@click.stop="pauseVoice"
|
||||
src="@/static/images/course/stop-blue.png"
|
||||
style="width: 100%; height: 100%"
|
||||
></image> -->
|
||||
</view>
|
||||
<view class="text-btn" @click.stop="translateVoice()">文</view>
|
||||
<view class="fl1"></view>
|
||||
<view class="btns-cont-button-text" @click.stop="buutton_click('again')">重答</view>
|
||||
<view class="btns-cont-button-text" @click.stop="buutton_click('complete')">完成</view>
|
||||
|
||||
<!-- <view class="icon text-btn" v-if="type === 1" @click.stop="translateVoice(dataInfo)">文</view> -->
|
||||
</view>
|
||||
</view>
|
||||
<!-- 01纯文字 -->
|
||||
@@ -31,14 +43,23 @@
|
||||
</text>
|
||||
</view>
|
||||
<view class="btns-cont">
|
||||
<view class="play-btn">
|
||||
<!-- <image class="icon" v-show="!(props.activeVoiceId === dataInfo.id)" @click="playVoice"
|
||||
src="@/static/images/course/play-blue.png" style="width: 100%;height: 100%;"></image> -->
|
||||
<image class="icon"
|
||||
@click.stop="pauseVoice" src="@/static/images/course/stop-blue.png"
|
||||
style="width: 100%;height: 100%;"></image>
|
||||
<view class="icon text-btn" @click.stop="buutton_click(dataInfo)">重答</view>
|
||||
</view>
|
||||
<!-- <view class="play-btn">
|
||||
<image
|
||||
class="icon"
|
||||
@click="playVoice"
|
||||
src="@/static/images/course/play-blue.png"
|
||||
style="width: 100%; height: 100%"
|
||||
></image>
|
||||
<image
|
||||
class="icon"
|
||||
@click.stop="pauseVoice"
|
||||
src="@/static/images/course/stop-blue.png"
|
||||
style="width: 100%; height: 100%"
|
||||
></image>
|
||||
</view> -->
|
||||
<view class="fl1"></view>
|
||||
<view class="btns-cont-button-text" @click.stop="buutton_click('again')">重答</view>
|
||||
<view class="btns-cont-button-text" @click.stop="buutton_click('complete')">完成</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="talking-info talking-info-loading" v-else-if="intrctWay === '00'">
|
||||
@@ -49,143 +70,142 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
computed,
|
||||
unref,
|
||||
ref,
|
||||
toRefs,
|
||||
watch,
|
||||
onMounted
|
||||
} from "vue"
|
||||
import {
|
||||
onUnload
|
||||
} from '@dcloudio/uni-app';
|
||||
import { computed, unref, ref, toRefs, watch, onMounted } from 'vue';
|
||||
import { onUnload } from '@dcloudio/uni-app';
|
||||
const props = defineProps({
|
||||
dataInfo: {
|
||||
default: () => ({
|
||||
talkingText:'',
|
||||
talkingVoice:'',
|
||||
|
||||
talkingText: '',
|
||||
talkingVoice: ''
|
||||
}),
|
||||
type: Object
|
||||
},
|
||||
|
||||
text: { // 当前激活的语音
|
||||
|
||||
text: {
|
||||
// 当前激活的语音
|
||||
default: '',
|
||||
type: String
|
||||
},
|
||||
voice: { // 当前激活的语音
|
||||
voice: {
|
||||
// 当前激活的语音
|
||||
default: '',
|
||||
type: String
|
||||
},
|
||||
activeVoiceId: { // 当前激活的语音
|
||||
activeVoiceId: {
|
||||
// 当前激活的语音
|
||||
default: '',
|
||||
type: String
|
||||
},
|
||||
intrctWay: {
|
||||
default: '',
|
||||
type: String
|
||||
},
|
||||
})
|
||||
const {
|
||||
dataInfo
|
||||
} = toRefs(props)
|
||||
|
||||
}
|
||||
});
|
||||
const { dataInfo } = toRefs(props);
|
||||
|
||||
const intrctWay = computed(() => {
|
||||
console.log('props.intrctWay', props.intrctWay);
|
||||
return props.intrctWay
|
||||
})
|
||||
const emit = defineEmits(['changePlay'])
|
||||
watch(() => props.dataInfo, () => {}, {
|
||||
deep: true,
|
||||
immediate: true
|
||||
})
|
||||
return props.intrctWay;
|
||||
});
|
||||
const emit = defineEmits(['changePlay', 'buutton_click']);
|
||||
watch(
|
||||
() => props.dataInfo,
|
||||
() => {},
|
||||
{
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
);
|
||||
// 声音播放初始化
|
||||
const talkVoiceObj = ref(null)
|
||||
const talkVoiceObj = ref(null);
|
||||
|
||||
const isPlaying = ref(false)
|
||||
const voiceLoading = ref(false)
|
||||
const translateLoading = ref(false)
|
||||
const isPlaying = ref(false);
|
||||
const voiceLoading = ref(false);
|
||||
const translateLoading = ref(false);
|
||||
|
||||
const voiceTime = ref('');
|
||||
const itemVoice = ref('');
|
||||
|
||||
const voiceTime = ref('')
|
||||
const itemVoice = ref('')
|
||||
|
||||
// 中间显示的文字
|
||||
const showContent = computed(() => {
|
||||
return props.text || ''
|
||||
})
|
||||
return props.text || props.dataInfo.anserResult || '';
|
||||
});
|
||||
onMounted(() => {
|
||||
initVoice()
|
||||
})
|
||||
initVoice();
|
||||
});
|
||||
onUnload(() => {
|
||||
pauseVoice()
|
||||
})
|
||||
watch(() => props.dataInfo.talkingVoice, (val) => {
|
||||
if (val) {
|
||||
initVoice()
|
||||
pauseVoice();
|
||||
});
|
||||
watch(
|
||||
() => props.dataInfo.talkingVoice,
|
||||
(val) => {
|
||||
if (val) {
|
||||
initVoice();
|
||||
}
|
||||
},
|
||||
{
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
}, {
|
||||
deep: true,
|
||||
immediate: true
|
||||
})
|
||||
|
||||
);
|
||||
|
||||
// 按钮点击
|
||||
const buutton_click = (type) => {
|
||||
|
||||
}
|
||||
emit('buutton_click', type, props.dataInfo);
|
||||
};
|
||||
const pauseVoice = () => {
|
||||
if (!talkVoiceObj.value) return
|
||||
talkVoiceObj.value.pause()
|
||||
isPlaying.value = false
|
||||
emit('changePlay', '')
|
||||
}
|
||||
if (!talkVoiceObj.value) return;
|
||||
talkVoiceObj.value.pause();
|
||||
isPlaying.value = false;
|
||||
emit('changePlay', '');
|
||||
};
|
||||
const playVoice = () => {
|
||||
emit('changePlay', unref(dataInfo)?.id)
|
||||
emit('changePlay', unref(dataInfo)?.id);
|
||||
if (talkVoiceObj.value && talkVoiceObj.value.src) {
|
||||
talkVoiceObj.value.play()
|
||||
return
|
||||
talkVoiceObj.value.play();
|
||||
return;
|
||||
} else {
|
||||
talkVoiceObj.value.src = ''
|
||||
talkVoiceObj.value.src = '';
|
||||
if (unref(dataInfo).talkingVoice) {
|
||||
setTimeout(() => {
|
||||
talkVoiceObj.value.src = unref(dataInfo).talkingVoice
|
||||
talkVoiceObj.value.play()
|
||||
isPlaying.value = true
|
||||
}, 100)
|
||||
talkVoiceObj.value.src = unref(dataInfo).talkingVoice;
|
||||
talkVoiceObj.value.play();
|
||||
isPlaying.value = true;
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
const initVoice = () => {
|
||||
talkVoiceObj.value = uni.createInnerAudioContext()
|
||||
talkVoiceObj.value = uni.createInnerAudioContext();
|
||||
talkVoiceObj.value.onEnded(() => {
|
||||
emit('changePlay', '')
|
||||
talkVoiceObj.value.src = ''
|
||||
})
|
||||
emit('changePlay', '');
|
||||
talkVoiceObj.value.src = '';
|
||||
});
|
||||
talkVoiceObj.value.onError(() => {
|
||||
talkVoiceObj.value.src = ''
|
||||
})
|
||||
talkVoiceObj.value.src = '';
|
||||
});
|
||||
if (unref(dataInfo).intrctWay === '02') {
|
||||
itemVoice.value = unref(dataInfo).talkingVoice
|
||||
talkVoiceObj.value.src = itemVoice.value
|
||||
itemVoice.value = unref(dataInfo).talkingVoice;
|
||||
talkVoiceObj.value.src = itemVoice.value;
|
||||
setTimeout(() => {
|
||||
setVoiceTime(0)
|
||||
}, 100)
|
||||
setVoiceTime(0);
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
};
|
||||
const setVoiceTime = (sum) => {
|
||||
sum += 1
|
||||
sum += 1;
|
||||
if (Math.ceil(talkVoiceObj.value.duration) > 0) {
|
||||
voiceTime.value = (Math.ceil(talkVoiceObj.value.duration) || 1) + 's'
|
||||
voiceTime.value = (Math.ceil(talkVoiceObj.value.duration) || 1) + 's';
|
||||
} else {
|
||||
if (sum === 20) {
|
||||
voiceTime.value = 0 + 's'
|
||||
return
|
||||
voiceTime.value = 0 + 's';
|
||||
return;
|
||||
}
|
||||
setTimeout(() => {
|
||||
setVoiceTime(sum)
|
||||
}, 200)
|
||||
setVoiceTime(sum);
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@@ -228,12 +248,11 @@
|
||||
&.talking-info-text {
|
||||
padding-bottom: 20rpx;
|
||||
width: auto;
|
||||
min-width: calc(100vw * 0.45);
|
||||
float: right;
|
||||
|
||||
.talking-cont {
|
||||
margin-top: 0rpx;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.talking-cont {
|
||||
@@ -256,8 +275,11 @@
|
||||
|
||||
.btns-cont {
|
||||
overflow: hidden;
|
||||
border-top: 3rpx solid #eee;
|
||||
|
||||
border-top: 3rpx solid #1f79ff;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding-top: 20rpx;
|
||||
margin-top: 22rpx;
|
||||
.replay-btn {
|
||||
float: left;
|
||||
width: 46rpx;
|
||||
@@ -268,16 +290,12 @@
|
||||
}
|
||||
|
||||
.play-btn {
|
||||
float: left;
|
||||
width: 46rpx;
|
||||
height: 46rpx;
|
||||
overflow: hidden;
|
||||
margin-right: 16rpx;
|
||||
margin-top: 25rpx;
|
||||
}
|
||||
|
||||
.text-btn {
|
||||
float: left;
|
||||
width: 46rpx;
|
||||
height: 46rpx;
|
||||
overflow: hidden;
|
||||
@@ -285,8 +303,7 @@
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
margin-right: 16rpx;
|
||||
margin-top: 25rpx;
|
||||
background-color: #67A4ff;
|
||||
background-color: #67a4ff;
|
||||
font-size: 24rpx;
|
||||
font-weight: bold;
|
||||
border-radius: 20rpx;
|
||||
@@ -324,6 +341,16 @@
|
||||
margin-top: -12rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.btns-cont-button-text {
|
||||
font-weight: 400;
|
||||
font-size: 30rpx;
|
||||
color: #ffffff;
|
||||
line-height: 30rpx;
|
||||
text-align: left;
|
||||
font-style: normal;
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -28,9 +28,9 @@
|
||||
<template v-if="qnsTyp === 'ES'">
|
||||
<questionVue
|
||||
:intrctWay="subject_data.es_status"
|
||||
:dataInfo="{}"
|
||||
:text="subject_data.anserResult"
|
||||
:dataInfo="item_answer"
|
||||
:activeVoiceId="subject_data.qnsId"
|
||||
@buutton_click="questionBuuttonClick"
|
||||
></questionVue>
|
||||
</template>
|
||||
<template v-else>
|
||||
@@ -119,8 +119,10 @@
|
||||
// result.anserResult
|
||||
|
||||
let answerText = props.item?.my_answer || props.item.anserResult || [];
|
||||
|
||||
console.log('answerText', props.item.anserResult);
|
||||
const item_answer = ref(typeof answerText === 'string' ? answerText.split(',') : []);
|
||||
// item_answer 是答题结果,可以是对象 数组 字符串类型
|
||||
const item_answer = ref(typeof answerText === 'string' ? answerText.split(',') : answerText);
|
||||
const feedback_click = () => {
|
||||
emit('subject_click', 'feedback', props.item);
|
||||
};
|
||||
@@ -163,17 +165,22 @@
|
||||
},
|
||||
set: (val) => {}
|
||||
});
|
||||
|
||||
// const subject_data = reactive({
|
||||
// qnsId: props.item.qnsId,
|
||||
// qnsContent: props.item.qnsContent,
|
||||
// qnsTyp: props.item.qnsTyp,
|
||||
// analyContent: props.item.analyContent,
|
||||
// itemVos: (props.item.itemVos ?? []).map((res) => ({
|
||||
// ...res,
|
||||
// correctFlag: props.clearResult ? '' : res.correctFlag
|
||||
// }))
|
||||
// });
|
||||
// 按钮
|
||||
const questionBuuttonClick = (type, submitObj) => {
|
||||
console.log('type', type, submitObj);
|
||||
// 判断点击的是什么
|
||||
if(type === 'complete') { // 完成
|
||||
|
||||
}else if(type === 'again') { // 重答
|
||||
|
||||
}
|
||||
emit('subject_click', type, {
|
||||
qnsTyp: props.item.qnsTyp,
|
||||
qnsId: props.item.qnsId,
|
||||
answer: item_answer.value,
|
||||
answerItems: []
|
||||
});
|
||||
};
|
||||
|
||||
// 题类型
|
||||
const subject_type_text = computed(() => SUBJECT_TYPE.find((res) => qnsTyp.value === res.value)?.label || '');
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
<template>
|
||||
<view class="talk-btns">
|
||||
<uv-button
|
||||
class="touch-btn"
|
||||
@touchstart="startRecord"
|
||||
@touchend="stopRecord"
|
||||
@touchmove="handleMove"
|
||||
v-if="!keyboardIsShow"
|
||||
:customStyle="{ height: '92rpx' }"
|
||||
>
|
||||
按住说话
|
||||
</uv-button>
|
||||
<view class="touch-btn" v-if="keyboardIsShow">
|
||||
<view class="touch-btn" @click="disabled_click">
|
||||
<uv-button
|
||||
class="touch-btn"
|
||||
@touchstart="startRecord"
|
||||
@touchend="stopRecord"
|
||||
@touchmove="handleMove"
|
||||
v-if="!keyboardIsShow"
|
||||
:customStyle="{ height: '92rpx' }"
|
||||
>
|
||||
按住说话
|
||||
</uv-button>
|
||||
|
||||
|
||||
<uv-input
|
||||
v-if="keyboardIsShow"
|
||||
class="input-box"
|
||||
ref="inputRef"
|
||||
v-model="inputText"
|
||||
@@ -19,8 +22,10 @@
|
||||
:adjustPosition="false"
|
||||
placeholderStyle="color:#999999;font-size:26rpx"
|
||||
placeholder="请输入文字"
|
||||
:disabled="props.isDisabled"
|
||||
></uv-input>
|
||||
</view>
|
||||
|
||||
<view class="talk-btn-box">
|
||||
<image
|
||||
class="talk-btn-icon"
|
||||
@@ -78,7 +83,7 @@
|
||||
const emit = defineEmits(['submit']);
|
||||
const props = defineProps({
|
||||
isDisabled: {
|
||||
default: true,
|
||||
default: false,
|
||||
type: Boolean
|
||||
},
|
||||
isLoading: {
|
||||
@@ -89,6 +94,11 @@
|
||||
default: '发送回答中,请稍后再试!',
|
||||
type: String
|
||||
},
|
||||
disabledText: {
|
||||
default: '请稍后再试!',
|
||||
type: String
|
||||
},
|
||||
|
||||
canAnswer: {
|
||||
default: true,
|
||||
type: Boolean
|
||||
@@ -107,23 +117,21 @@
|
||||
default: 1000
|
||||
}
|
||||
});
|
||||
const { isDisabled } = toRefs(props);
|
||||
|
||||
// 键盘还是语音
|
||||
const keyboardIsShow = ref(false);
|
||||
const popupRef = ref(null);
|
||||
const inputText = ref('');
|
||||
let startTime = 0;
|
||||
|
||||
|
||||
// not_started 未开始, preparing 准备中, in_recording 录音中,ending 结束中
|
||||
const recordingStatus = ref('not_started');
|
||||
// 获取全局唯一的录音管理器 recorderManager
|
||||
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
const recorderManager = uni.getRecorderManager();
|
||||
// #endif
|
||||
|
||||
|
||||
|
||||
// const innerAudioContext = uni.createInnerAudioContext();
|
||||
const startTimer = ref(null); // 延迟启动的定时器ID
|
||||
const startFlag = ref(1);
|
||||
@@ -155,9 +163,9 @@
|
||||
recorderManager.stop();
|
||||
});
|
||||
}, times);
|
||||
nextTick(() => recordingStatus.value = 'not_started');
|
||||
nextTick(() => (recordingStatus.value = 'not_started'));
|
||||
};
|
||||
|
||||
|
||||
onMounted(async () => {
|
||||
// #ifdef APP-PLUS
|
||||
recorderManager.onStop(function (res) {
|
||||
@@ -168,8 +176,8 @@
|
||||
const recordDuration = endTime - startTime;
|
||||
console.log('说话时长', recordDuration);
|
||||
if (props.minRecordDuration > recordDuration) {
|
||||
nextTick(()=>common.msg('说话时间太短,没有听清!'))
|
||||
return ;
|
||||
nextTick(() => common.msg('说话时间太短,没有听清!'));
|
||||
return;
|
||||
}
|
||||
console.log('录音结束,时长:', recordDuration, '秒');
|
||||
emit('submit', 'voice', res.tempFilePath);
|
||||
@@ -185,7 +193,7 @@
|
||||
});
|
||||
// #endif
|
||||
});
|
||||
|
||||
|
||||
const touchY = ref(0);
|
||||
const windowInfo = uni.getWindowInfo();
|
||||
// 安全区域信息
|
||||
@@ -199,6 +207,12 @@
|
||||
const handleMove = (obj) => {
|
||||
touchY.value = obj.changedTouches[0].pageY;
|
||||
};
|
||||
const clearinputText = (text = '') => {
|
||||
const old_text = inputText.value;
|
||||
inputText.value = text;
|
||||
return old_text;
|
||||
};
|
||||
defineExpose({ clearinputText });
|
||||
// 发送文本
|
||||
const showKeyboard = () => {
|
||||
if (keyboardIsShow.value) {
|
||||
@@ -218,6 +232,11 @@
|
||||
keyboardIsShow.value = !keyboardIsShow.value;
|
||||
inputText.value = '';
|
||||
};
|
||||
// 禁用时点击给的提示
|
||||
const disabled_click = () => {
|
||||
console.log('禁用时点击给的提示');
|
||||
if (props.isDisabled) common.msg(props.disabledText);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
ref,
|
||||
onMounted,
|
||||
computed,
|
||||
defineProps,
|
||||
watch
|
||||
} from 'vue'
|
||||
import {
|
||||
|
||||
Reference in New Issue
Block a user