JLBA202505130001_关于吉林银行新建AI智能培训系统的需求_fix: bug
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view class="talking-info" v-if="dataInfo.intrctWay === '02'">
|
||||
<view class="talking-info" v-if="dataInfo.intrctWay === '02'">
|
||||
<view :class="['talking-gif', !voiceLoading&&(props.activeVoiceId === dataInfo.id) ? 'is-play' : '']">
|
||||
<CommonLoading color="#fff" v-show="voiceLoading"/>
|
||||
<CommonLoading color="#fff" v-show="voiceLoading" />
|
||||
</view>
|
||||
<view class="right-time">{{voiceTime}}</view>
|
||||
<view class="talking-cont">
|
||||
@@ -9,157 +9,207 @@
|
||||
{{ showContent }}
|
||||
</text>
|
||||
<view class="talking-text translate-text" v-if="translateLoading">
|
||||
<CommonLoading color="#fff"/>
|
||||
<CommonLoading color="#fff" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="btns-cont">
|
||||
<view class="play-btn">
|
||||
<image class="icon"
|
||||
v-show="!(!voiceLoading&&(props.activeVoiceId === dataInfo.id))"
|
||||
@click="playVoice"
|
||||
src="@/static/images/course/play-blue.png"
|
||||
style="width: 100%;height: 100%;"
|
||||
></image>
|
||||
<image class="icon"
|
||||
v-show="!voiceLoading&&(props.activeVoiceId === dataInfo.id)"
|
||||
@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" v-show="!(!voiceLoading&&(props.activeVoiceId === dataInfo.id))" @click="playVoice"
|
||||
src="@/static/images/course/play-blue.png" style="width: 100%;height: 100%;"></image>
|
||||
<image class="icon" v-show="!voiceLoading&&(props.activeVoiceId === dataInfo.id)" @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> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="talking-info talking-info-text" v-else-if="dataInfo.intrctWay === '01'">
|
||||
<view class="talking-info talking-info-text" v-else-if="dataInfo.intrctWay === '01'">
|
||||
<view class="talking-cont">
|
||||
<text :class="['talking-text translate-text loading']">
|
||||
{{ showContent }}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="talking-info talking-info-loading" v-else>
|
||||
<view class="talking-info talking-info-loading" v-else>
|
||||
<view :class="['talking-gif']">
|
||||
<CommonLoading color="#fff"/>
|
||||
<CommonLoading color="#fff" />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, unref, ref, toRefs, watch, onMounted } from "vue"
|
||||
import { onUnload } from '@dcloudio/uni-app';
|
||||
import { downloadFile } from '@/api/common.js';
|
||||
const props = defineProps({
|
||||
import {
|
||||
computed,
|
||||
unref,
|
||||
ref,
|
||||
toRefs,
|
||||
watch,
|
||||
onMounted
|
||||
} from "vue"
|
||||
import {
|
||||
useStorageStore
|
||||
} from "@/store/storage.js"
|
||||
import {
|
||||
onUnload
|
||||
} from '@dcloudio/uni-app';
|
||||
import {
|
||||
downloadFile
|
||||
} from '@/api/common.js';
|
||||
const props = defineProps({
|
||||
dataInfo: {
|
||||
default: () => ({}),
|
||||
type: Object
|
||||
},
|
||||
activeVoiceId:{
|
||||
default:'',
|
||||
activeVoiceId: {
|
||||
default: '',
|
||||
type: String
|
||||
},
|
||||
})
|
||||
const { activeVoiceId, dataInfo } = toRefs(props)
|
||||
const {
|
||||
activeVoiceId,
|
||||
dataInfo
|
||||
} = toRefs(props)
|
||||
|
||||
const storageStore = useStorageStore();
|
||||
const emit = defineEmits(['changePlay'])
|
||||
watch(() => props.dataInfo, () => {},{deep: true,immediate: true})
|
||||
watch(() => props.dataInfo, () => {}, {
|
||||
deep: true,
|
||||
immediate: true
|
||||
})
|
||||
// 声音播放初始化
|
||||
const talkVoiceObj = ref(null)
|
||||
|
||||
|
||||
const isPlaying = ref(false)
|
||||
const voiceLoading = ref(false)
|
||||
const translateLoading = ref(false)
|
||||
|
||||
|
||||
const voiceTime = ref('')
|
||||
const itemVoice = ref('')
|
||||
const showContent = computed(()=>{
|
||||
const showContent = computed(() => {
|
||||
return dataInfo.value.talkingText || ''
|
||||
})
|
||||
onMounted(()=>{
|
||||
onMounted(() => {
|
||||
initVoice()
|
||||
})
|
||||
onUnload(()=>{
|
||||
onUnload(() => {
|
||||
pauseVoice()
|
||||
})
|
||||
watch(() => props.dataInfo.bucketKey,(val)=>{
|
||||
if(val){
|
||||
watch(() => props.dataInfo.bucketKey, (val) => {
|
||||
if (val) {
|
||||
initVoice()
|
||||
}
|
||||
},{
|
||||
}, {
|
||||
deep: true,
|
||||
immediate: true
|
||||
})
|
||||
const pauseVoice = () => {
|
||||
if(!talkVoiceObj.value) return
|
||||
if (!talkVoiceObj.value) return
|
||||
talkVoiceObj.value.pause()
|
||||
isPlaying.value = false
|
||||
emit('changePlay', '')
|
||||
}
|
||||
const playVoice = () =>{
|
||||
|
||||
const playVoice = () => {
|
||||
|
||||
emit('changePlay', unref(dataInfo)?.id)
|
||||
|
||||
if(talkVoiceObj.value && talkVoiceObj.value.src) {
|
||||
talkVoiceObj.value.play()
|
||||
|
||||
console.log(unref(dataInfo)?.id)
|
||||
if (talkVoiceObj.value && talkVoiceObj.value.src) {
|
||||
console.log(1, talkVoiceObj.value.src)
|
||||
setTimeout(() => {
|
||||
talkVoiceObj.value.play()
|
||||
}, 100)
|
||||
return
|
||||
}else{
|
||||
talkVoiceObj.value.src = ''
|
||||
if(unref(dataInfo).talkingVoice){
|
||||
setTimeout(()=>{
|
||||
talkVoiceObj.value.src = unref(dataInfo).talkingVoice
|
||||
talkVoiceObj.value.play()
|
||||
isPlaying.value = true
|
||||
},100)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
const initVoice = () => {
|
||||
talkVoiceObj.value = uni.createInnerAudioContext()
|
||||
talkVoiceObj.value.onEnded(()=>{
|
||||
emit('changePlay', '')
|
||||
talkVoiceObj.value.src = ''
|
||||
})
|
||||
talkVoiceObj.value.onError(()=>{
|
||||
talkVoiceObj.value.src = ''
|
||||
})
|
||||
if(unref(dataInfo).intrctWay === '02'){
|
||||
downloadFile(unref(dataInfo).bucketKey)
|
||||
.then((res) => {
|
||||
|
||||
if (res?.data) {
|
||||
common.msg(res.data.message);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// talkVoiceObj.value.src = ''
|
||||
// if (unref(dataInfo).talkingVoice) {
|
||||
// setTimeout(() => {
|
||||
// talkVoiceObj.value.src = unref(dataInfo).talkingVoice
|
||||
// talkVoiceObj.value.play()
|
||||
// isPlaying.value = true
|
||||
// }, 100)
|
||||
// }
|
||||
|
||||
storageStore.getStorageById('audio', unref(dataInfo).bucketKey, (url) => {
|
||||
if (url) {
|
||||
voiceLoading.value = false;
|
||||
itemVoice.value = res.tempFilePath;
|
||||
talkVoiceObj.value.src = res.tempFilePath;
|
||||
if (voiceIsPlaying.value) return
|
||||
itemVoice.value = url;
|
||||
talkVoiceObj.value.src = url;
|
||||
if(unref(dataInfo)?.id !== props.activeVoiceId) return
|
||||
talkVoiceObj.value.play();
|
||||
storageStore.setStorage('audio', _id, itemVoice.value);
|
||||
setTimeout(()=>{
|
||||
setVoiceTime(0)
|
||||
},100)
|
||||
})
|
||||
.catch((err) => {
|
||||
voiceLoading.value = false;
|
||||
emit('changePlay', '');
|
||||
});
|
||||
|
||||
// itemVoice.value = unref(dataInfo).talkingVoice
|
||||
// talkVoiceObj.value.src = itemVoice.value
|
||||
// setTimeout(()=>{
|
||||
// setVoiceTime(0)
|
||||
// },100)
|
||||
} else {
|
||||
downloadFile(unref(dataInfo).bucketKey)
|
||||
.then((res) => {
|
||||
if (res?.data) {
|
||||
common.msg(res.data.message);
|
||||
return;
|
||||
}
|
||||
voiceLoading.value = false;
|
||||
itemVoice.value = res.tempFilePath;
|
||||
talkVoiceObj.value.src = res.tempFilePath;
|
||||
if(unref(dataInfo)?.id !== props.activeVoiceId) return
|
||||
talkVoiceObj.value.play();
|
||||
storageStore.setStorage('audio', unref(dataInfo).bucketKey, itemVoice.value);
|
||||
})
|
||||
.catch((err) => {
|
||||
voiceLoading.value = false;
|
||||
emit('changePlay', '');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
const initVoice = () => {
|
||||
console.log('init')
|
||||
talkVoiceObj.value = uni.createInnerAudioContext()
|
||||
talkVoiceObj.value.onEnded(() => {
|
||||
emit('changePlay', '')
|
||||
// talkVoiceObj.value.src = ''
|
||||
})
|
||||
talkVoiceObj.value.onError((err) => {
|
||||
console.log(err)
|
||||
talkVoiceObj.value.src = ''
|
||||
})
|
||||
// if (unref(dataInfo).intrctWay === '02') {
|
||||
// downloadFile(unref(dataInfo).bucketKey)
|
||||
// .then((res) => {
|
||||
|
||||
// if (res?.data) {
|
||||
// common.msg(res.data.message);
|
||||
// return;
|
||||
// }
|
||||
// voiceLoading.value = false;
|
||||
// itemVoice.value = res.tempFilePath;
|
||||
// talkVoiceObj.value.src = res.tempFilePath;
|
||||
// console.log(res.tempFilePath)
|
||||
// storageStore.setStorage('audio', unref(dataInfo).bucketKey, itemVoice.value);
|
||||
// if (voiceIsPlaying.value) return
|
||||
// if (unref(dataInfo)?.id !== props.activeVoiceId) return
|
||||
// talkVoiceObj.value.play();
|
||||
// setTimeout(() => {
|
||||
// setVoiceTime(0)
|
||||
// }, 100)
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// voiceLoading.value = false;
|
||||
// emit('changePlay', '');
|
||||
// });
|
||||
|
||||
// // itemVoice.value = unref(dataInfo).talkingVoice
|
||||
// // talkVoiceObj.value.src = itemVoice.value
|
||||
// // setTimeout(()=>{
|
||||
// // setVoiceTime(0)
|
||||
// // },100)
|
||||
// }
|
||||
}
|
||||
const setVoiceTime = (sum) => {
|
||||
plus.io.getAudioInfo({
|
||||
filePath: unref(dataInfo).talkingVoice,
|
||||
success:(res)=>{
|
||||
voiceTime.value = (Math.floor(res.duration) || 1) + 's'
|
||||
success: (res) => {
|
||||
voiceTime.value = (Math.floor(res.duration) || 1) + 's'
|
||||
},
|
||||
fail:(res)=>{
|
||||
voiceTime.value = (unref(dataInfo).voiceTime || 1) + 's'
|
||||
fail: (res) => {
|
||||
voiceTime.value = (unref(dataInfo).voiceTime || 1) + 's'
|
||||
}
|
||||
})
|
||||
// sum += 1
|
||||
@@ -178,7 +228,7 @@ import { downloadFile } from '@/api/common.js';
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.talking-info{
|
||||
.talking-info {
|
||||
padding: 20rpx;
|
||||
border-radius: 15rpx;
|
||||
background-color: #06f;
|
||||
@@ -187,18 +237,21 @@ import { downloadFile } from '@/api/common.js';
|
||||
color: #fff;
|
||||
width: 100%;
|
||||
float: right;
|
||||
.talking-gif{
|
||||
|
||||
.talking-gif {
|
||||
width: 200rpx;
|
||||
height: 38rpx;
|
||||
background: url(@/static/images/course/voice-gray.png) no-repeat;
|
||||
background-size: contain;
|
||||
padding-left: 168rpx;
|
||||
&.is-play{
|
||||
|
||||
&.is-play {
|
||||
background: url(@/static/images/course/voice-white.gif) no-repeat;
|
||||
background-size: contain;
|
||||
}
|
||||
}
|
||||
.right-time{
|
||||
|
||||
.right-time {
|
||||
position: absolute;
|
||||
right: 20rpx;
|
||||
top: 20rpx;
|
||||
@@ -206,37 +259,45 @@ import { downloadFile } from '@/api/common.js';
|
||||
height: 38rpx;
|
||||
line-height: 38rpx;
|
||||
}
|
||||
&.talking-info-loading{
|
||||
|
||||
&.talking-info-loading {
|
||||
padding-bottom: 20rpx;
|
||||
}
|
||||
&.talking-info-text{
|
||||
|
||||
&.talking-info-text {
|
||||
padding-bottom: 20rpx;
|
||||
width: auto;
|
||||
float: right;
|
||||
.talking-cont{
|
||||
|
||||
.talking-cont {
|
||||
margin-top: 0rpx;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
.talking-cont{
|
||||
|
||||
.talking-cont {
|
||||
margin-top: 16rpx;
|
||||
overflow: hidden;
|
||||
.talking-text{
|
||||
|
||||
.talking-text {
|
||||
font-size: 28rpx;
|
||||
line-height: 48rpx;
|
||||
margin-bottom: 20rpx;
|
||||
word-break: break-all;
|
||||
white-space: pre-line;
|
||||
overflow: hidden;
|
||||
&.translate-text{
|
||||
|
||||
&.translate-text {
|
||||
min-height: 48rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
.btns-cont{
|
||||
|
||||
.btns-cont {
|
||||
overflow: hidden;
|
||||
border-top: 3rpx solid #eee;
|
||||
.replay-btn{
|
||||
|
||||
.replay-btn {
|
||||
float: left;
|
||||
width: 46rpx;
|
||||
height: 46rpx;
|
||||
@@ -244,7 +305,8 @@ import { downloadFile } from '@/api/common.js';
|
||||
margin-right: 16rpx;
|
||||
margin-top: 25rpx;
|
||||
}
|
||||
.play-btn{
|
||||
|
||||
.play-btn {
|
||||
float: left;
|
||||
width: 46rpx;
|
||||
height: 46rpx;
|
||||
@@ -252,7 +314,8 @@ import { downloadFile } from '@/api/common.js';
|
||||
margin-right: 16rpx;
|
||||
margin-top: 25rpx;
|
||||
}
|
||||
.text-btn{
|
||||
|
||||
.text-btn {
|
||||
float: left;
|
||||
width: 46rpx;
|
||||
height: 46rpx;
|
||||
@@ -267,7 +330,8 @@ import { downloadFile } from '@/api/common.js';
|
||||
font-weight: bold;
|
||||
border-radius: 20rpx;
|
||||
}
|
||||
.text-right-btn{
|
||||
|
||||
.text-right-btn {
|
||||
float: right;
|
||||
padding: 0 10rpx;
|
||||
height: 46rpx;
|
||||
@@ -277,7 +341,8 @@ import { downloadFile } from '@/api/common.js';
|
||||
margin-left: 16rpx;
|
||||
margin-top: 25rpx;
|
||||
}
|
||||
.next-btn{
|
||||
|
||||
.next-btn {
|
||||
float: right;
|
||||
padding: 0 60rpx 0 20rpx;
|
||||
height: 62rpx;
|
||||
@@ -288,7 +353,8 @@ import { downloadFile } from '@/api/common.js';
|
||||
border-radius: 8rpx;
|
||||
margin-top: 16rpx;
|
||||
position: relative;
|
||||
.icon-iamge{
|
||||
|
||||
.icon-iamge {
|
||||
width: 25rpx;
|
||||
height: 25rpx;
|
||||
position: absolute;
|
||||
|
||||
Reference in New Issue
Block a user