Merge branch 'develop' of http://25.13.9.101:9000/K17_AITS/tra-app into develop
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,24 +9,16 @@
|
||||
{{ 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.stop="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.stop="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>
|
||||
@@ -37,128 +29,152 @@
|
||||
</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';
|
||||
const props = defineProps({
|
||||
import {
|
||||
computed,
|
||||
unref,
|
||||
ref,
|
||||
toRefs,
|
||||
watch,
|
||||
onMounted
|
||||
} from "vue"
|
||||
import {
|
||||
onUnload
|
||||
} from '@dcloudio/uni-app';
|
||||
import {
|
||||
getPhoneEnvBool
|
||||
} from '@/common/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 emit = defineEmits(['changePlay'])
|
||||
// 声音播放初始化
|
||||
const talkVoiceObj = ref(null)
|
||||
|
||||
const talkUserVoiceObj = 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()
|
||||
})
|
||||
const pauseVoice = () => {
|
||||
if(!talkVoiceObj.value) return
|
||||
talkVoiceObj.value.pause()
|
||||
if (!talkUserVoiceObj.value) return
|
||||
talkUserVoiceObj.value.pause()
|
||||
isPlaying.value = false
|
||||
emit('changePlay', '')
|
||||
}
|
||||
const playVoice = () =>{
|
||||
const playVoice = () => {
|
||||
emit('changePlay', unref(dataInfo)?.id)
|
||||
if(talkVoiceObj.value && talkVoiceObj.value.src) {
|
||||
setTimeout(()=>{
|
||||
talkVoiceObj.value.src = unref(dataInfo).talkingVoice
|
||||
talkVoiceObj.value.play()
|
||||
},300)
|
||||
if (talkUserVoiceObj.value && talkUserVoiceObj.value.src) {
|
||||
setTimeout(() => {
|
||||
// talkUserVoiceObj.value.src = itemVoice.value
|
||||
talkUserVoiceObj.value.play()
|
||||
}, 300)
|
||||
return
|
||||
}else{
|
||||
talkVoiceObj.value.src = ''
|
||||
if(unref(dataInfo).talkingVoice){
|
||||
setTimeout(()=>{
|
||||
talkVoiceObj.value.src = unref(dataInfo).talkingVoice
|
||||
talkVoiceObj.value.play()
|
||||
} else {
|
||||
talkUserVoiceObj.value.src = ''
|
||||
if (unref(dataInfo).talkingVoice) {
|
||||
setTimeout(() => {
|
||||
talkUserVoiceObj.value.src = itemVoice.value
|
||||
talkUserVoiceObj.value.play()
|
||||
isPlaying.value = true
|
||||
},100)
|
||||
}, 100)
|
||||
}
|
||||
}
|
||||
}
|
||||
const IsAndEnv = getPhoneEnvBool('AND');
|
||||
const initVoice = () => {
|
||||
talkVoiceObj.value = uni.createInnerAudioContext()
|
||||
talkVoiceObj.value.onPause(()=>{
|
||||
talkVoiceObj.value.volume = 1
|
||||
talkUserVoiceObj.value = uni.createInnerAudioContext()
|
||||
talkUserVoiceObj.value.onPause(() => {
|
||||
talkUserVoiceObj.value.volume = 1
|
||||
})
|
||||
talkVoiceObj.value.onPlay(()=>{
|
||||
if(isTesting.value){
|
||||
talkVoiceObj.value.pause()
|
||||
talkUserVoiceObj.value.onPlay(() => {
|
||||
if (isTesting.value) {
|
||||
talkUserVoiceObj.value.pause()
|
||||
isTesting.value = false
|
||||
}
|
||||
})
|
||||
talkVoiceObj.value.onEnded(()=>{
|
||||
talkUserVoiceObj.value.onEnded(() => {
|
||||
emit('changePlay', '')
|
||||
talkVoiceObj.value.src = ''
|
||||
talkVoiceObj.value.volume = 1
|
||||
talkUserVoiceObj.value.src = ''
|
||||
talkUserVoiceObj.value.volume = 1
|
||||
})
|
||||
talkVoiceObj.value.onError(()=>{
|
||||
talkVoiceObj.value.src = ''
|
||||
talkUserVoiceObj.value.onError(() => {
|
||||
talkUserVoiceObj.value.src = ''
|
||||
})
|
||||
itemVoice.value = unref(dataInfo).talkingVoice
|
||||
talkVoiceObj.value.src = itemVoice.value
|
||||
isTesting.value = true
|
||||
talkVoiceObj.value.volume = 0
|
||||
talkVoiceObj.value.play()
|
||||
talkVoiceObj.value.pause()
|
||||
setTimeout(()=>{
|
||||
talkUserVoiceObj.value.src = itemVoice.value
|
||||
//#ifdef APP-PLUS
|
||||
// 安卓端 须播放一次,不然再次播放会没有声音
|
||||
if (IsAndEnv) {
|
||||
isTesting.value = true
|
||||
talkUserVoiceObj.value.volume = 0
|
||||
talkUserVoiceObj.value.play()
|
||||
talkUserVoiceObj.value.pause()
|
||||
}
|
||||
// #endif
|
||||
setTimeout(() => {
|
||||
setVoiceTime(0)
|
||||
},100)
|
||||
}, 100)
|
||||
}
|
||||
const isTesting= ref(false)
|
||||
const isTesting = ref(false)
|
||||
const setVoiceTime = (sum) => {
|
||||
sum += 1
|
||||
if(Math.ceil(talkVoiceObj.value.duration)>0){
|
||||
voiceTime.value = (Math.ceil(talkVoiceObj.value.duration) || 1 ) + 's'
|
||||
}else{
|
||||
if(sum === 20) {
|
||||
if (Math.ceil(talkUserVoiceObj.value.duration) > 0) {
|
||||
voiceTime.value = (Math.ceil(talkUserVoiceObj.value.duration) || 1) + 's'
|
||||
} else {
|
||||
if (sum === 20) {
|
||||
voiceTime.value = 0 + 's'
|
||||
return
|
||||
}
|
||||
setTimeout(()=>{
|
||||
setTimeout(() => {
|
||||
setVoiceTime(sum)
|
||||
},200)
|
||||
}, 200)
|
||||
}
|
||||
}
|
||||
watch(() => props.dataInfo, () => {},{deep: true,immediate: true})
|
||||
watch(() => props.dataInfo.talkingVoice,(val)=>{
|
||||
if(val){
|
||||
watch(() => props.dataInfo, () => {}, {
|
||||
deep: true,
|
||||
immediate: true
|
||||
})
|
||||
watch(() => props.dataInfo.talkingVoice, (val) => {
|
||||
if (val) {
|
||||
initVoice()
|
||||
}
|
||||
},{
|
||||
}, {
|
||||
deep: true,
|
||||
immediate: true
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.talking-info{
|
||||
.talking-info {
|
||||
padding: 20rpx;
|
||||
border-radius: 15rpx;
|
||||
background-color: #06f;
|
||||
@@ -167,18 +183,21 @@ import { onUnload } from '@dcloudio/uni-app';
|
||||
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;
|
||||
@@ -186,37 +205,45 @@ import { onUnload } from '@dcloudio/uni-app';
|
||||
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;
|
||||
@@ -224,7 +251,8 @@ import { onUnload } from '@dcloudio/uni-app';
|
||||
margin-right: 16rpx;
|
||||
margin-top: 25rpx;
|
||||
}
|
||||
.play-btn{
|
||||
|
||||
.play-btn {
|
||||
float: left;
|
||||
width: 46rpx;
|
||||
height: 46rpx;
|
||||
@@ -232,7 +260,8 @@ import { onUnload } from '@dcloudio/uni-app';
|
||||
margin-right: 16rpx;
|
||||
margin-top: 25rpx;
|
||||
}
|
||||
.text-btn{
|
||||
|
||||
.text-btn {
|
||||
float: left;
|
||||
width: 46rpx;
|
||||
height: 46rpx;
|
||||
@@ -247,7 +276,8 @@ import { onUnload } from '@dcloudio/uni-app';
|
||||
font-weight: bold;
|
||||
border-radius: 20rpx;
|
||||
}
|
||||
.text-right-btn{
|
||||
|
||||
.text-right-btn {
|
||||
float: right;
|
||||
padding: 0 10rpx;
|
||||
height: 46rpx;
|
||||
@@ -257,7 +287,8 @@ import { onUnload } from '@dcloudio/uni-app';
|
||||
margin-left: 16rpx;
|
||||
margin-top: 25rpx;
|
||||
}
|
||||
.next-btn{
|
||||
|
||||
.next-btn {
|
||||
float: right;
|
||||
padding: 0 60rpx 0 20rpx;
|
||||
height: 62rpx;
|
||||
@@ -268,7 +299,8 @@ import { onUnload } from '@dcloudio/uni-app';
|
||||
border-radius: 8rpx;
|
||||
margin-top: 16rpx;
|
||||
position: relative;
|
||||
.icon-iamge{
|
||||
|
||||
.icon-iamge {
|
||||
width: 25rpx;
|
||||
height: 25rpx;
|
||||
position: absolute;
|
||||
|
||||
@@ -192,7 +192,6 @@
|
||||
scrollToBottomNow();
|
||||
commonUploadVoiceFile(voicePath, '/trapractice/traPartnerChat/voiceTrans', {})
|
||||
.then((_res) => {
|
||||
console.log(_res)
|
||||
if (!!(_res.body.transContent || '').trim()) {
|
||||
askData.value = {
|
||||
execId: execId.value,
|
||||
|
||||
Reference in New Issue
Block a user