fix: bug
This commit is contained in:
+1
-1
@@ -8,5 +8,5 @@ VITE_APP_BASE_H5_API_Url = 'http://25.18.122.91:9786'
|
|||||||
# VITE_APP_BASE_H5_API_Url_TRAEXAM = 'http://25.64.32.154:9604'
|
# VITE_APP_BASE_H5_API_Url_TRAEXAM = 'http://25.64.32.154:9604'
|
||||||
# VITE_APP_BASE_H5_API_Url_TRAPRACTICE = 'http://25.64.32.156:9603'
|
# VITE_APP_BASE_H5_API_Url_TRAPRACTICE = 'http://25.64.32.156:9603'
|
||||||
# VITE_APP_BASE_H5_API_Url_TRAAPP = 'http://25.64.32.154:9601'
|
# VITE_APP_BASE_H5_API_Url_TRAAPP = 'http://25.64.32.154:9601'
|
||||||
VITE_APP_BASE_H5_API_Url_TRAAPP = 'http://25.64.32.158:9601'
|
# VITE_APP_BASE_H5_API_Url_TRAAPP = 'http://25.64.32.158:9601'
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<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' : '']">
|
<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>
|
||||||
<view class="right-time">{{voiceTime}}</view>
|
<view class="right-time">{{voiceTime}}</view>
|
||||||
<view class="talking-cont">
|
<view class="talking-cont">
|
||||||
@@ -9,24 +9,16 @@
|
|||||||
{{ showContent }}
|
{{ showContent }}
|
||||||
</text>
|
</text>
|
||||||
<view class="talking-text translate-text" v-if="translateLoading">
|
<view class="talking-text translate-text" v-if="translateLoading">
|
||||||
<CommonLoading color="#fff"/>
|
<CommonLoading color="#fff" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="btns-cont">
|
<view class="btns-cont">
|
||||||
<view class="play-btn">
|
<view class="play-btn">
|
||||||
<image class="icon"
|
<image class="icon" v-show="!(!voiceLoading&&(props.activeVoiceId === dataInfo.id))" @click.stop="playVoice"
|
||||||
v-show="!(!voiceLoading&&(props.activeVoiceId === dataInfo.id))"
|
src="@/static/images/course/play-blue.png" style="width: 100%;height: 100%;"></image>
|
||||||
@click.stop="playVoice"
|
<image class="icon" v-show="!voiceLoading&&(props.activeVoiceId === dataInfo.id)" @click.stop="pauseVoice"
|
||||||
src="@/static/images/course/play-blue.png"
|
src="@/static/images/course/stop-blue.png" style="width: 100%;height: 100%;"></image>
|
||||||
style="width: 100%;height: 100%;"
|
<!-- <view class="icon text-btn" v-if="type === 1" @click.stop="translateVoice(dataInfo)">文</view> -->
|
||||||
></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>
|
||||||
</view>
|
</view>
|
||||||
@@ -37,30 +29,45 @@
|
|||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view> -->
|
</view> -->
|
||||||
<view class="talking-info talking-info-loading" v-else>
|
<view class="talking-info talking-info-loading" v-else>
|
||||||
<view :class="['talking-gif']">
|
<view :class="['talking-gif']">
|
||||||
<CommonLoading color="#fff"/>
|
<CommonLoading color="#fff" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, unref, ref, toRefs, watch, onMounted } from "vue"
|
import {
|
||||||
import { onUnload } from '@dcloudio/uni-app';
|
computed,
|
||||||
const props = defineProps({
|
unref,
|
||||||
|
ref,
|
||||||
|
toRefs,
|
||||||
|
watch,
|
||||||
|
onMounted
|
||||||
|
} from "vue"
|
||||||
|
import {
|
||||||
|
onUnload
|
||||||
|
} from '@dcloudio/uni-app';
|
||||||
|
import {
|
||||||
|
getPhoneEnvBool
|
||||||
|
} from '@/common/common.js';
|
||||||
|
const props = defineProps({
|
||||||
dataInfo: {
|
dataInfo: {
|
||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
type: Object
|
type: Object
|
||||||
},
|
},
|
||||||
activeVoiceId:{
|
activeVoiceId: {
|
||||||
default:'',
|
default: '',
|
||||||
type: String
|
type: String
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const { activeVoiceId, dataInfo } = toRefs(props)
|
const {
|
||||||
|
activeVoiceId,
|
||||||
|
dataInfo
|
||||||
|
} = toRefs(props)
|
||||||
const emit = defineEmits(['changePlay'])
|
const emit = defineEmits(['changePlay'])
|
||||||
// 声音播放初始化
|
// 声音播放初始化
|
||||||
const talkVoiceObj = ref(null)
|
const talkUserVoiceObj = ref(null)
|
||||||
|
|
||||||
const isPlaying = ref(false)
|
const isPlaying = ref(false)
|
||||||
const voiceLoading = ref(false)
|
const voiceLoading = ref(false)
|
||||||
@@ -68,97 +75,106 @@ import { onUnload } from '@dcloudio/uni-app';
|
|||||||
|
|
||||||
const voiceTime = ref('')
|
const voiceTime = ref('')
|
||||||
const itemVoice = ref('')
|
const itemVoice = ref('')
|
||||||
const showContent = computed(()=>{
|
const showContent = computed(() => {
|
||||||
return dataInfo.value.talkingText || ''
|
return dataInfo.value.talkingText || ''
|
||||||
})
|
})
|
||||||
onMounted(()=>{
|
onMounted(() => {
|
||||||
initVoice()
|
initVoice()
|
||||||
})
|
})
|
||||||
onUnload(()=>{
|
onUnload(() => {
|
||||||
pauseVoice()
|
pauseVoice()
|
||||||
})
|
})
|
||||||
const pauseVoice = () => {
|
const pauseVoice = () => {
|
||||||
if(!talkVoiceObj.value) return
|
if (!talkUserVoiceObj.value) return
|
||||||
talkVoiceObj.value.pause()
|
talkUserVoiceObj.value.pause()
|
||||||
isPlaying.value = false
|
isPlaying.value = false
|
||||||
emit('changePlay', '')
|
emit('changePlay', '')
|
||||||
}
|
}
|
||||||
const playVoice = () =>{
|
const playVoice = () => {
|
||||||
emit('changePlay', unref(dataInfo)?.id)
|
emit('changePlay', unref(dataInfo)?.id)
|
||||||
if(talkVoiceObj.value && talkVoiceObj.value.src) {
|
if (talkUserVoiceObj.value && talkUserVoiceObj.value.src) {
|
||||||
setTimeout(()=>{
|
setTimeout(() => {
|
||||||
talkVoiceObj.value.src = unref(dataInfo).talkingVoice
|
// talkUserVoiceObj.value.src = itemVoice.value
|
||||||
talkVoiceObj.value.play()
|
talkUserVoiceObj.value.play()
|
||||||
},300)
|
}, 300)
|
||||||
return
|
return
|
||||||
}else{
|
} else {
|
||||||
talkVoiceObj.value.src = ''
|
talkUserVoiceObj.value.src = ''
|
||||||
if(unref(dataInfo).talkingVoice){
|
if (unref(dataInfo).talkingVoice) {
|
||||||
setTimeout(()=>{
|
setTimeout(() => {
|
||||||
talkVoiceObj.value.src = unref(dataInfo).talkingVoice
|
talkUserVoiceObj.value.src = itemVoice.value
|
||||||
talkVoiceObj.value.play()
|
talkUserVoiceObj.value.play()
|
||||||
isPlaying.value = true
|
isPlaying.value = true
|
||||||
},100)
|
}, 100)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const IsAndEnv = getPhoneEnvBool('AND');
|
||||||
const initVoice = () => {
|
const initVoice = () => {
|
||||||
talkVoiceObj.value = uni.createInnerAudioContext()
|
talkUserVoiceObj.value = uni.createInnerAudioContext()
|
||||||
talkVoiceObj.value.onPause(()=>{
|
talkUserVoiceObj.value.onPause(() => {
|
||||||
talkVoiceObj.value.volume = 1
|
talkUserVoiceObj.value.volume = 1
|
||||||
})
|
})
|
||||||
talkVoiceObj.value.onPlay(()=>{
|
talkUserVoiceObj.value.onPlay(() => {
|
||||||
if(isTesting.value){
|
if (isTesting.value) {
|
||||||
talkVoiceObj.value.pause()
|
talkUserVoiceObj.value.pause()
|
||||||
isTesting.value = false
|
isTesting.value = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
talkVoiceObj.value.onEnded(()=>{
|
talkUserVoiceObj.value.onEnded(() => {
|
||||||
emit('changePlay', '')
|
emit('changePlay', '')
|
||||||
talkVoiceObj.value.src = ''
|
talkUserVoiceObj.value.src = ''
|
||||||
talkVoiceObj.value.volume = 1
|
talkUserVoiceObj.value.volume = 1
|
||||||
})
|
})
|
||||||
talkVoiceObj.value.onError(()=>{
|
talkUserVoiceObj.value.onError(() => {
|
||||||
talkVoiceObj.value.src = ''
|
talkUserVoiceObj.value.src = ''
|
||||||
})
|
})
|
||||||
itemVoice.value = unref(dataInfo).talkingVoice
|
itemVoice.value = unref(dataInfo).talkingVoice
|
||||||
talkVoiceObj.value.src = itemVoice.value
|
talkUserVoiceObj.value.src = itemVoice.value
|
||||||
isTesting.value = true
|
//#ifdef APP-PLUS
|
||||||
talkVoiceObj.value.volume = 0
|
// 安卓端 须播放一次,不然再次播放会没有声音
|
||||||
talkVoiceObj.value.play()
|
if (IsAndEnv) {
|
||||||
talkVoiceObj.value.pause()
|
isTesting.value = true
|
||||||
setTimeout(()=>{
|
talkUserVoiceObj.value.volume = 0
|
||||||
|
talkUserVoiceObj.value.play()
|
||||||
|
talkUserVoiceObj.value.pause()
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
|
setTimeout(() => {
|
||||||
setVoiceTime(0)
|
setVoiceTime(0)
|
||||||
},100)
|
}, 100)
|
||||||
}
|
}
|
||||||
const isTesting= ref(false)
|
const isTesting = ref(false)
|
||||||
const setVoiceTime = (sum) => {
|
const setVoiceTime = (sum) => {
|
||||||
sum += 1
|
sum += 1
|
||||||
if(Math.ceil(talkVoiceObj.value.duration)>0){
|
if (Math.ceil(talkUserVoiceObj.value.duration) > 0) {
|
||||||
voiceTime.value = (Math.ceil(talkVoiceObj.value.duration) || 1 ) + 's'
|
voiceTime.value = (Math.ceil(talkUserVoiceObj.value.duration) || 1) + 's'
|
||||||
}else{
|
} else {
|
||||||
if(sum === 20) {
|
if (sum === 20) {
|
||||||
voiceTime.value = 0 + 's'
|
voiceTime.value = 0 + 's'
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
setTimeout(()=>{
|
setTimeout(() => {
|
||||||
setVoiceTime(sum)
|
setVoiceTime(sum)
|
||||||
},200)
|
}, 200)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
watch(() => props.dataInfo, () => {},{deep: true,immediate: true})
|
watch(() => props.dataInfo, () => {}, {
|
||||||
watch(() => props.dataInfo.talkingVoice,(val)=>{
|
deep: true,
|
||||||
if(val){
|
immediate: true
|
||||||
|
})
|
||||||
|
watch(() => props.dataInfo.talkingVoice, (val) => {
|
||||||
|
if (val) {
|
||||||
initVoice()
|
initVoice()
|
||||||
}
|
}
|
||||||
},{
|
}, {
|
||||||
deep: true,
|
deep: true,
|
||||||
immediate: true
|
immediate: true
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.talking-info{
|
.talking-info {
|
||||||
padding: 20rpx;
|
padding: 20rpx;
|
||||||
border-radius: 15rpx;
|
border-radius: 15rpx;
|
||||||
background-color: #06f;
|
background-color: #06f;
|
||||||
@@ -167,18 +183,21 @@ import { onUnload } from '@dcloudio/uni-app';
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
float: right;
|
float: right;
|
||||||
.talking-gif{
|
|
||||||
|
.talking-gif {
|
||||||
width: 200rpx;
|
width: 200rpx;
|
||||||
height: 38rpx;
|
height: 38rpx;
|
||||||
background: url(@/static/images/course/voice-gray.png) no-repeat;
|
background: url(@/static/images/course/voice-gray.png) no-repeat;
|
||||||
background-size: contain;
|
background-size: contain;
|
||||||
padding-left: 168rpx;
|
padding-left: 168rpx;
|
||||||
&.is-play{
|
|
||||||
|
&.is-play {
|
||||||
background: url(@/static/images/course/voice-white.gif) no-repeat;
|
background: url(@/static/images/course/voice-white.gif) no-repeat;
|
||||||
background-size: contain;
|
background-size: contain;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.right-time{
|
|
||||||
|
.right-time {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 20rpx;
|
right: 20rpx;
|
||||||
top: 20rpx;
|
top: 20rpx;
|
||||||
@@ -186,37 +205,45 @@ import { onUnload } from '@dcloudio/uni-app';
|
|||||||
height: 38rpx;
|
height: 38rpx;
|
||||||
line-height: 38rpx;
|
line-height: 38rpx;
|
||||||
}
|
}
|
||||||
&.talking-info-loading{
|
|
||||||
|
&.talking-info-loading {
|
||||||
padding-bottom: 20rpx;
|
padding-bottom: 20rpx;
|
||||||
}
|
}
|
||||||
&.talking-info-text{
|
|
||||||
|
&.talking-info-text {
|
||||||
padding-bottom: 20rpx;
|
padding-bottom: 20rpx;
|
||||||
width: auto;
|
width: auto;
|
||||||
float: right;
|
float: right;
|
||||||
.talking-cont{
|
|
||||||
|
.talking-cont {
|
||||||
margin-top: 0rpx;
|
margin-top: 0rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
.talking-cont{
|
|
||||||
|
.talking-cont {
|
||||||
margin-top: 16rpx;
|
margin-top: 16rpx;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
.talking-text{
|
|
||||||
|
.talking-text {
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
line-height: 48rpx;
|
line-height: 48rpx;
|
||||||
margin-bottom: 20rpx;
|
margin-bottom: 20rpx;
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
white-space: pre-line;
|
white-space: pre-line;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
&.translate-text{
|
|
||||||
|
&.translate-text {
|
||||||
min-height: 48rpx;
|
min-height: 48rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.btns-cont{
|
|
||||||
|
.btns-cont {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border-top: 3rpx solid #eee;
|
border-top: 3rpx solid #eee;
|
||||||
.replay-btn{
|
|
||||||
|
.replay-btn {
|
||||||
float: left;
|
float: left;
|
||||||
width: 46rpx;
|
width: 46rpx;
|
||||||
height: 46rpx;
|
height: 46rpx;
|
||||||
@@ -224,7 +251,8 @@ import { onUnload } from '@dcloudio/uni-app';
|
|||||||
margin-right: 16rpx;
|
margin-right: 16rpx;
|
||||||
margin-top: 25rpx;
|
margin-top: 25rpx;
|
||||||
}
|
}
|
||||||
.play-btn{
|
|
||||||
|
.play-btn {
|
||||||
float: left;
|
float: left;
|
||||||
width: 46rpx;
|
width: 46rpx;
|
||||||
height: 46rpx;
|
height: 46rpx;
|
||||||
@@ -232,7 +260,8 @@ import { onUnload } from '@dcloudio/uni-app';
|
|||||||
margin-right: 16rpx;
|
margin-right: 16rpx;
|
||||||
margin-top: 25rpx;
|
margin-top: 25rpx;
|
||||||
}
|
}
|
||||||
.text-btn{
|
|
||||||
|
.text-btn {
|
||||||
float: left;
|
float: left;
|
||||||
width: 46rpx;
|
width: 46rpx;
|
||||||
height: 46rpx;
|
height: 46rpx;
|
||||||
@@ -247,7 +276,8 @@ import { onUnload } from '@dcloudio/uni-app';
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
border-radius: 20rpx;
|
border-radius: 20rpx;
|
||||||
}
|
}
|
||||||
.text-right-btn{
|
|
||||||
|
.text-right-btn {
|
||||||
float: right;
|
float: right;
|
||||||
padding: 0 10rpx;
|
padding: 0 10rpx;
|
||||||
height: 46rpx;
|
height: 46rpx;
|
||||||
@@ -257,7 +287,8 @@ import { onUnload } from '@dcloudio/uni-app';
|
|||||||
margin-left: 16rpx;
|
margin-left: 16rpx;
|
||||||
margin-top: 25rpx;
|
margin-top: 25rpx;
|
||||||
}
|
}
|
||||||
.next-btn{
|
|
||||||
|
.next-btn {
|
||||||
float: right;
|
float: right;
|
||||||
padding: 0 60rpx 0 20rpx;
|
padding: 0 60rpx 0 20rpx;
|
||||||
height: 62rpx;
|
height: 62rpx;
|
||||||
@@ -268,7 +299,8 @@ import { onUnload } from '@dcloudio/uni-app';
|
|||||||
border-radius: 8rpx;
|
border-radius: 8rpx;
|
||||||
margin-top: 16rpx;
|
margin-top: 16rpx;
|
||||||
position: relative;
|
position: relative;
|
||||||
.icon-iamge{
|
|
||||||
|
.icon-iamge {
|
||||||
width: 25rpx;
|
width: 25rpx;
|
||||||
height: 25rpx;
|
height: 25rpx;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
@@ -192,7 +192,6 @@
|
|||||||
scrollToBottomNow();
|
scrollToBottomNow();
|
||||||
commonUploadVoiceFile(voicePath, '/trapractice/traPartnerChat/voiceTrans', {})
|
commonUploadVoiceFile(voicePath, '/trapractice/traPartnerChat/voiceTrans', {})
|
||||||
.then((_res) => {
|
.then((_res) => {
|
||||||
console.log(_res)
|
|
||||||
if (!!(_res.body.transContent || '').trim()) {
|
if (!!(_res.body.transContent || '').trim()) {
|
||||||
askData.value = {
|
askData.value = {
|
||||||
execId: execId.value,
|
execId: execId.value,
|
||||||
|
|||||||
Reference in New Issue
Block a user