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

This commit is contained in:
田岩
2025-12-17 14:34:49 +08:00
6 changed files with 1180 additions and 1046 deletions
+7
View File
@@ -719,4 +719,11 @@
}
}
}
::v-deep .uni-calendar--fixed{
bottom: auto;
top:0 !important;
}
::v-deep .uni-calendar__mask{
background-color: rgba(0, 0, 0, 0);
}
</style>
+19 -6
View File
@@ -243,7 +243,7 @@
position: relative;
height: 100vh;
width: 100vw;
overflow: hidden;
overflow-y: auto;
box-sizing: border-box;
padding-top: $top-height;
@@ -260,17 +260,24 @@
.ranking-box {
height: calc(100% - $top-height);
overflow: hidden;
padding-top: 250rpx;
// min-height: 600rpx;
// overflow: hidden;
position: absolute;
top: $top-height;
width: 100%;
z-index: 2;
// display: flex;
// flex-direction: column;
}
.nav-div {
position: relative;
position: absolute;
top: 0;
overflow: hidden;
height: 70rpx;
z-index: 20;
width: 100%;
.back_div {
margin-right: 10rpx;
@@ -307,8 +314,11 @@
.title-view {
height: 180rpx;
position: relative;
position: absolute;
top: 0;
padding-top: 20rpx;
z-index: 10;
width: 100%;
.cup-image {
position: absolute;
@@ -316,7 +326,7 @@
bottom: -33rpx;
width: 208rpx;
height: 208rpx;
z-index: 0;
z-index: 11;
}
.title-desc {
@@ -331,11 +341,14 @@
position: absolute;
bottom: 20rpx;
left: 46rpx;
z-index: 12;
}
}
.ranking-body {
height: calc(100% - 170rpx - 180rpx - 70rpx);
height: calc(100% - 170rpx);
min-height: 550rpx;
// flex: 1;
overflow: hidden;
background-color: #fff;
border-radius: 31rpx 31rpx 0 0;
+233 -56
View File
@@ -496,38 +496,31 @@
.touch-btn {
height: 92rpx;
box-shadow: 0 8rpx 20rpx 0 rgba(0, 0, 0, 0.06);
// box-shadow: 0 8rpx 20rpx 0 rgba(0, 0, 0, 0.06);
text-align: center;
line-height: 92rpx;
font-size: 28rpx;
color: #000;
background-color: #06f;
font-weight: 400;
position: relative;
color: #fff;
font-size: 29rpx;
border-radius: 23rpx;
.input-box {
.center-text {
height: 35rpx;
line-height: 35rpx;
width: 100%;
height: 92rpx;
line-height: 92rpx;
text-align: left;
box-sizing: border-box;
padding: 0 40rpx 0 40rpx;
}
}
.talk-btn-box {
position: absolute;
height: 100%;
width: 120rpx;
right: 0;
top: 0;
.talk-btn-icon {
width: 40rpx;
height: 40rpx;
position: absolute;
right: 60rpx;
top: 50%;
margin-top: -20rpx;
transform: translateY(-50%);
display: flex;
justify-content: center;
}
.type-icon {
width: 35rpx;
height: 35rpx;
margin-right: 10rpx;
}
}
}
@@ -538,12 +531,16 @@
// justify-content: flex-end;
width: 100%;
height: 100%;
pointer-events: none;
max-height: 100vh;
justify-content: space-between;
.circle-bg-box {
height: 234rpx;
background: url(@/static/images/course/talking.png) no-repeat;
background-size: cover;
position: relative;
pointer-events: none;
.icon-box {
position: absolute;
@@ -553,10 +550,12 @@
margin-top: -24rpx;
width: 34rpx;
height: 48rpx;
pointer-events: none;
image {
width: 100%;
height: 100%;
pointer-events: none;
}
}
}
@@ -564,30 +563,40 @@
.tips-box {
height: 40rpx;
line-height: 40rpx;
font-size: 28rpx;
color: #c0c0c0;
text-align: center;
margin: 12rpx 0 24rpx;
pointer-events: none;
}
.btns-box {
height: 270rpx;
// padding: 0 120rpx;
width: 154rpx;
margin: 0 auto 100rpx;
margin: 0 auto;
overflow: hidden;
font-size: 28rpx;
text-align: center;
line-height: 116rpx;
pointer-events: none;
display: flex;
.close-btn {
padding-top: 40rpx;
line-height: 28rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
float: left;
height: 100%;
width: 154rpx;
width: 100%;
overflow: hidden;
color: #999;
pointer-events: none;
&.is-out {
color: #fff;
pointer-events: none;
}
}
@@ -597,11 +606,14 @@
width: 154rpx;
overflow: hidden;
color: #999;
pointer-events: none;
}
.btn-box {
width: 100%;
height: 154rpx;
max-height: 152rpx;
pointer-events: none;
margin: 0 auto;
}
}
@@ -612,6 +624,7 @@
background-color: #06f;
border-radius: 32rpx;
position: relative;
pointer-events: none;
&.is-out {
background-color: #ff3e49;
@@ -628,6 +641,7 @@
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
pointer-events: none;
}
&::after {
@@ -641,38 +655,201 @@
bottom: -22rpx;
left: 50%;
margin-left: -22rpx;
}
}
.white-bg-box {
height: 365rpx;
background-color: #fff;
overflow: hidden;
border-radius: 32rpx 32rpx 0 0;
padding: 58rpx 36rpx;
.box-title {
font-size: 32rpx;
font-weight: bold;
line-height: 46rpx;
margin-bottom: 46rpx;
}
.box-btns {
height: 46rpx;
line-height: 46rpx;
display: flex;
justify-content: space-between;
color: #999;
.is-active {
color: #06f;
pointer-events: none;
}
}
}
}
::v-deep .uv-input__content__field-wrapper__field {
padding-right: 60rpx;
}
</style>
<style lang="scss" scoped>
// .talk-btns {
// height: 150rpx;
// background-color: #fff;
// padding: 25rpx 30rpx 0;
// position: relative;
// z-index: v-bind(btnZindex);
// .touch-btn {
// height: 92rpx;
// box-shadow: 0 8rpx 20rpx 0 rgba(0, 0, 0, 0.06);
// text-align: center;
// line-height: 92rpx;
// font-size: 28rpx;
// color: #000;
// font-weight: 400;
// position: relative;
// .input-box {
// width: 100%;
// height: 92rpx;
// line-height: 92rpx;
// text-align: left;
// box-sizing: border-box;
// padding: 0 40rpx 0 40rpx;
// }
// }
// .talk-btn-box {
// position: absolute;
// height: 100%;
// width: 120rpx;
// right: 0;
// top: 0;
// .talk-btn-icon {
// width: 40rpx;
// height: 40rpx;
// position: absolute;
// right: 60rpx;
// top: 50%;
// margin-top: -20rpx;
// }
// }
// }
// .overlay-box {
// display: flex;
// flex-direction: column-reverse;
// // justify-content: flex-end;
// width: 100%;
// height: 100%;
// .circle-bg-box {
// height: 234rpx;
// background: url(@/static/images/course/talking.png) no-repeat;
// background-size: cover;
// position: relative;
// .icon-box {
// position: absolute;
// left: 50%;
// top: 50%;
// margin-left: -17rpx;
// margin-top: -24rpx;
// width: 34rpx;
// height: 48rpx;
// image {
// width: 100%;
// height: 100%;
// }
// }
// }
// .tips-box {
// height: 40rpx;
// line-height: 40rpx;
// color: #c0c0c0;
// text-align: center;
// margin: 12rpx 0 24rpx;
// }
// .btns-box {
// height: 270rpx;
// // padding: 0 120rpx;
// width: 154rpx;
// margin: 0 auto 100rpx;
// overflow: hidden;
// font-size: 28rpx;
// text-align: center;
// line-height: 116rpx;
// .close-btn {
// float: left;
// height: 100%;
// width: 154rpx;
// overflow: hidden;
// color: #999;
// &.is-out {
// color: #fff;
// }
// }
// .translate-btn {
// float: right;
// height: 100%;
// width: 154rpx;
// overflow: hidden;
// color: #999;
// }
// .btn-box {
// width: 100%;
// height: 154rpx;
// }
// }
// .talk-dialog {
// width: 506rpx;
// height: 234rpx;
// margin: 0 auto;
// background-color: #06f;
// border-radius: 32rpx;
// position: relative;
// &.is-out {
// background-color: #ff3e49;
// &::after {
// background-color: #ff3e49;
// }
// }
// .gif-box {
// position: absolute;
// width: 200rpx;
// height: 80rpx;
// left: 50%;
// top: 50%;
// transform: translate(-50%, -50%);
// }
// &::after {
// content: '';
// width: 44rpx;
// height: 44rpx;
// clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
// background-color: #06f;
// overflow: hidden;
// position: absolute;
// bottom: -22rpx;
// left: 50%;
// margin-left: -22rpx;
// }
// }
// .white-bg-box {
// height: 365rpx;
// background-color: #fff;
// overflow: hidden;
// border-radius: 32rpx 32rpx 0 0;
// padding: 58rpx 36rpx;
// .box-title {
// font-size: 32rpx;
// font-weight: bold;
// line-height: 46rpx;
// margin-bottom: 46rpx;
// }
// .box-btns {
// height: 46rpx;
// line-height: 46rpx;
// display: flex;
// justify-content: space-between;
// color: #999;
// .is-active {
// color: #06f;
// }
// }
// }
// }
// ::v-deep .uv-input__content__field-wrapper__field {
// padding-right: 60rpx;
// }
</style>
@@ -227,9 +227,10 @@
}
}
.card-items{
padding: 0 24rpx;
height: calc(100% - 352rpx);
overflow-y: auto;
padding: 0 24rpx ;
// height: calc(100% - 352rpx);
overflow: hidden;
// overflow-y: auto;
}
.card-item {
width: 100%;
+20 -9
View File
@@ -22,9 +22,9 @@
<view class="tips-box">松开发送</view>
<view class="btns-box">
<view :class="['close-btn', isOut ? 'is-out' : '']">
取消
<image class="btn-box" v-if="!isOut" src="/src/static/images/course/close.png" mode=""></image>
<image class="btn-box" v-else src="/src/static/images/course/close-active.png" mode=""></image>
<text>取消</text>
<image class="btn-box" v-if="!isOut" src="/src/static/images/course/close.png" mode="heightFix"></image>
<image class="btn-box" v-else src="/src/static/images/course/close-active.png" mode="heightFix"></image>
</view>
</view>
<view :class="['talk-dialog', isOut ? 'is-out' : '']">
@@ -250,7 +250,10 @@
// #endif
//#ifndef APP-PLUS
const recordObjCom = ref({});
const initRecord = () => {};
const initRecord = () => {
// talkModelRef.value.open()
};
// #endif
onMounted(async () => {
initRecord?.();
@@ -484,6 +487,8 @@
width: 100%;
height: 100%;
pointer-events: none;
max-height: 100vh;
justify-content: space-between;
.circle-bg-box {
height: 234rpx;
@@ -513,6 +518,7 @@
.tips-box {
height: 40rpx;
line-height: 40rpx;
font-size: 28rpx;
color: #c0c0c0;
text-align: center;
margin: 12rpx 0 24rpx;
@@ -523,17 +529,22 @@
height: 270rpx;
// padding: 0 120rpx;
width: 154rpx;
margin: 0 auto 100rpx;
margin: 0 auto;
overflow: hidden;
font-size: 28rpx;
text-align: center;
line-height: 116rpx;
pointer-events: none;
display: flex;
.close-btn {
padding-top: 40rpx;
line-height: 28rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
float: left;
height: 100%;
width: 154rpx;
width: 100%;
overflow: hidden;
color: #999;
pointer-events: none;
@@ -555,8 +566,9 @@
.btn-box {
width: 100%;
height: 154rpx;
max-height: 152rpx;
pointer-events: none;
margin: 0 auto;
}
}
@@ -602,7 +614,6 @@
}
}
}
::v-deep .uv-input__content__field-wrapper__field {
padding-right: 60rpx;
}
+282 -357
View File
@@ -11,14 +11,7 @@
</view>
<view class="top-desc">内容由AI生成</view>
</view>
<scroll-view
:class="[' body-content index-dialog-body', detailInfo.traInterTyp === '01' ? 'talking-type1' : '']"
:scroll-y="true"
refresher-default-style="none"
:scroll-top="scrollTop"
:show-scrollbar="false"
:scroll-with-animation="false"
>
<scroll-view :class="[' body-content index-dialog-body', detailInfo.traInterTyp === '01' ? 'talking-type1' : '']" :scroll-y="true" refresher-default-style="none" :scroll-top="scrollTop" :show-scrollbar="false" :scroll-with-animation="false">
<view :class="['body-content-role', showRoleInfo ? '' : 'hide-info']">
<view :class="['role-title']">
<ImagePreview class="role-title-avatar" :src="detailInfo.ossAddr" :isCache="true"></ImagePreview>
@@ -28,21 +21,11 @@
<text class="card-title-name">{{ detailInfo.chaName }}</text>
<text class="card-title-age">{{ detailInfo.chaAge }}</text>
<text class="card-title-img">
<image
class="card-title-icon"
v-if="detailInfo.gender === 'm' || detailInfo.gender === '01'"
src="@/static/images/me/man.png"
></image>
<image
class="card-title-icon"
v-if="detailInfo.gender === 'f' || detailInfo.gender === '02'"
src="@/static/images/me/wuman.png"
></image>
<image class="card-title-icon" v-if="detailInfo.gender === 'm' || detailInfo.gender === '01'" src="@/static/images/me/man.png"></image>
<image class="card-title-icon" v-if="detailInfo.gender === 'f' || detailInfo.gender === '02'" src="@/static/images/me/wuman.png"></image>
</text>
</view>
<view class="role-desc">
预计时长 {{ detailInfo.traStartLimit }} ~ {{ detailInfo.traEndLimit }} 分钟
</view>
<view class="role-desc"> 预计时长 {{ detailInfo.traStartLimit }} ~ {{ detailInfo.traEndLimit }} 分钟 </view>
</view>
</view>
<view class="role-content">
@@ -69,9 +52,7 @@
<!-- sceneDesc -->
{{ detailInfo.sceneDesc }}
</view>
<view class="talking-desc">
陪练角色不具备主动终止场景陪练的功能当用户完成预设陪练目标时需由用户手动发起结束陪练操作
</view>
<view class="talking-desc"> 陪练角色不具备主动终止场景陪练的功能当用户完成预设陪练目标时需由用户手动发起结束陪练操作 </view>
<view class="talking-box" v-if="detailInfo.traInterTyp !== '01'">
<view class="tip-text">-请点击下方按钮开始{{ detailInfo.traInterTypDesc }}</view>
</view>
@@ -87,34 +68,18 @@
:isLast="index + 1 === talkingList.length"
:isAnswering="!answerIsOver"
:activeVoiceId="activeVoiceTalkingItemId"
@handleEvents="talkItemEvents"
></TalkingItem>
@handleEvents="talkItemEvents"></TalkingItem>
</view>
</scroll-view>
<view class="over-btn-box" v-if="detailInfo.traInterTyp === '01'">
<view class="over-btn" @click="overTalking">结束陪练</view>
</view>
<TouchBtn
class="body-bottom"
@uploadVoice="uploadRecordNow"
@startRecord="changePlayItemId('')"
:isLoading="!answerIsOver"
:isDisabled="false"
v-if="detailInfo.traInterTyp === '01'"
/>
<TouchBtn class="body-bottom" @uploadVoice="uploadRecordNow" @startRecord="changePlayItemId('')" formatType="wav" :isLoading="!answerIsOver" :isDisabled="false" v-if="detailInfo.traInterTyp === '01'" />
<view class="body-bottom" v-else>
<view class="body-bottom-btn" @click="beforeToTalking">
<view class="center-text">
<image
class="type-icon"
src="@/static/images/sparring/video-icon.png"
v-if="detailInfo.traInterTyp === '03'"
></image>
<image
class="type-icon"
src="@/static/images/sparring/phone-icon.png"
v-else-if="detailInfo.traInterTyp === '02'"
></image>
<image class="type-icon" src="@/static/images/sparring/video-icon.png" v-if="detailInfo.traInterTyp === '03'"></image>
<image class="type-icon" src="@/static/images/sparring/phone-icon.png" v-else-if="detailInfo.traInterTyp === '02'"></image>
<image v-else class="type-icon" src="@/static/images/sparring/talk-icon.png"></image>
{{ detailInfo.traInterTypDesc }}
</view>
@@ -127,93 +92,84 @@
</template>
<script setup>
import { ref, unref, onMounted, computed, nextTick } from 'vue';
import { onShow, onHide, onLoad, onUnload, onLaunch, onBackPress } from '@dcloudio/uni-app';
import common from '@/common/common';
import { getPhoneEnvBool } from '@/common/common';
import TouchBtn from './components/touchBtn.vue';
import ImagePreview from '@/components/image-preview/image-preview.vue';
import { commonUploadVoiceFile } from '@/api/common.js';
import { queryTraPartnerCharacterInfoById, partnerChatReportTrigger, checkTraPartnerInfoById } from '@/api/sparring.js';
import { useSocketStore } from '@/store/socket.js';
import { useStorageStore } from '@/store/storage.js';
import { storeToRefs } from 'pinia';
import TalkingItem from './components/talking-item.vue';
import badge from '@/components/points-and-badge/badge';
import points from '@/components/points-and-badge/points';
import usePointsAndBadge from '@/components/points-and-badge/usePointsAndBadge';
import { ref, unref, onMounted, computed, nextTick } from 'vue'
import { onShow, onHide, onLoad, onUnload, onLaunch, onBackPress } from '@dcloudio/uni-app'
import common from '@/common/common'
import { getPhoneEnvBool } from '@/common/common'
import TouchBtn from './components/touchBtn.vue'
import ImagePreview from '@/components/image-preview/image-preview.vue'
import { commonUploadVoiceFile } from '@/api/common.js'
import { queryTraPartnerCharacterInfoById, partnerChatReportTrigger, checkTraPartnerInfoById } from '@/api/sparring.js'
import { useSocketStore } from '@/store/socket.js'
import { useStorageStore } from '@/store/storage.js'
import { storeToRefs } from 'pinia'
import TalkingItem from './components/talking-item.vue'
import badge from '@/components/points-and-badge/badge'
import points from '@/components/points-and-badge/points'
import usePointsAndBadge from '@/components/points-and-badge/usePointsAndBadge'
import { initRecord } from '@/composables/useExamSubject.js';
import permissionApi from '@/common/permission';
const { pointAndBadgesRun, badgeRef, pointsRef } = usePointsAndBadge();
const socketStore = useSocketStore();
const { SocketObj } = storeToRefs(socketStore);
import { initRecord } from '@/composables/useExamSubject.js'
import permissionApi from '@/common/permission'
const { pointAndBadgesRun, badgeRef, pointsRef } = usePointsAndBadge()
const socketStore = useSocketStore()
const { SocketObj } = storeToRefs(socketStore)
const traId = ref('');
const chaId = ref('');
const talkingType = ref('');
// const badgeRef = ref(null);
// const pointsRef = ref(null);
const isPreview = ref(false);
const detailInfo = ref({});
const currentIndex = ref(0);
const showRoleInfo = ref(false);
const showLoading = ref(true);
const talkingList = ref([]);
// {
// type: 'answer',
// talkingText: 'asad',
// isLoading: false,
// id: new Date().getTime(),
// },
const askData = ref({});
const execId = ref('');
const answerIsOver = ref(true);
const traId = ref('')
const chaId = ref('')
const talkingType = ref('')
// const badgeRef = ref(null);
// const pointsRef = ref(null);
const isPreview = ref(false)
const detailInfo = ref({})
const currentIndex = ref(0)
const showRoleInfo = ref(false)
const showLoading = ref(true)
const talkingList = ref([])
// {
// type: 'answer',
// talkingText: 'asad',
// isLoading: false,
// id: new Date().getTime(),
// },
const askData = ref({})
const execId = ref('')
const answerIsOver = ref(true)
const getDetailInfo = () => {
const getDetailInfo = () => {
queryTraPartnerCharacterInfoById({
traId: traId.value,
chaId: chaId.value
}).then((res) => {
console.log(res);
}).then(res => {
console.log(res)
detailInfo.value = {
...res.body
};
}
if (detailInfo.value.traInterTyp === '01') {
initsocketTask();
initsocketTask()
}
setTimeout(() => {
showLoading.value = false;
}, Math.random() * 1000 + 500);
});
};
const scrollTop = ref(99999);
const scrollToBottomNow = (time = 100) => {
showLoading.value = false
}, Math.random() * 1000 + 500)
})
}
const scrollTop = ref(99999)
const scrollToBottomNow = (time = 100) => {
nextTick(() => {
setTimeout(() => {
scrollTop.value += 100;
scrollTop.value += 100;
}, time);
});
};
const uploadRecordNow = (voicePath, voiceTime) => {
console.log(voicePath, voiceTime);
scrollTop.value += 100
scrollTop.value += 100
}, time)
})
}
const uploadRecordNow = (voicePath, voiceTime) => {
console.log(voicePath, voiceTime)
if (!execId.value) {
common.show('提示', '网络连接失败,请重新加载', false).then((res) => {
common.show('提示', '网络连接失败,请重新加载', false).then(res => {
if (res) {
common.redirectTo(
'/pages/sparring/tip?traId=' +
traId.value +
'&chaId=' +
chaId.value +
'&type=' +
talkingType.value +
'&isPreview=' +
(isPreview.value ? '1' : '')
);
common.redirectTo('/pages/sparring/tip?traId=' + traId.value + '&chaId=' + chaId.value + '&type=' + talkingType.value + '&isPreview=' + (isPreview.value ? '1' : ''))
}
});
return;
})
return
}
//#ifndef APP-PLUS
// h5
@@ -223,12 +179,12 @@
type: 'question',
talkingText: '',
isLoading: true
});
scrollToBottomNow();
})
scrollToBottomNow()
//
answerIsOver.value = false;
answerIsOver.value = false
commonUploadVoiceFile(voicePath, '/trapractice/traPartnerChat/voiceTrans', {})
.then((_res) => {
.then(_res => {
if (!!(_res.body.transContent || '').trim()) {
askData.value = {
execId: execId.value,
@@ -238,59 +194,59 @@
ossFileAddr: _res.body.ossFileAddr,
talkingVoice: voicePath,
voiceTime: voiceTime
};
}
sendMessage({
commond: 'ASK',
body: askData.value
});
})
} else {
answerIsOver.value = true;
talkingList.value.pop();
answerIsOver.value = true
talkingList.value.pop()
uni.showToast({
title: '未识别到文字',
icon: 'none',
duration: 1000
});
})
}
})
.catch((err) => {
answerIsOver.value = true;
talkingList.value.pop();
.catch(err => {
answerIsOver.value = true
talkingList.value.pop()
uni.showToast({
title: '系统异常,请联系管理员',
icon: 'none',
duration: 1000
});
});
})
})
// #endif
};
const beforeToTalking = () => {
}
const beforeToTalking = () => {
if (isPreview.value) {
toTalking();
return;
toTalking()
return
}
checkTraPartnerInfoById({
traId: traId.value
}).then((res) => {
}).then(res => {
if (res.body.inRange) {
toTalking();
toTalking()
} else {
common.show('提示', res.body.message, false);
common.show('提示', res.body.message, false)
}
});
};
const toTalking = async () => {
})
}
const toTalking = async () => {
try {
//#ifdef APP-PLUS
console.log('申请权限');
console.log('申请权限')
try {
await permissionApi.judgeIosPermission('record');
await permissionApi.judgeIosPermission('record')
if (detailInfo.value.traInterTyp === '03') {
await permissionApi.judgeIosPermission('camera');
await permissionApi.judgeIosPermission('camera')
}
} catch (e) {
console.error('摄像头或者麦克风权限申请失败:', e);
return;
console.error('摄像头或者麦克风权限申请失败:', e)
return
}
//#endif
common.setPageCache('tipMsgsceneDesc', {
@@ -298,58 +254,46 @@
chaName: detailInfo.value.chaName,
traInterTyp: detailInfo.value.traInterTyp,
traInterTypDesc: detailInfo.value.traInterTypDesc
});
let _gotUrl;
})
let _gotUrl
if (detailInfo.value.traInterTyp === '02') {
_gotUrl = '/pages/sparring/talk';
_gotUrl = '/pages/sparring/talk'
} else if (detailInfo.value.traInterTyp === '03') {
_gotUrl = '/pages/sparring/talk'; //
_gotUrl = '/pages/sparring/talk' //
}
common.redirectTo(
_gotUrl +
'?traId=' +
traId.value +
'&chaId=' +
chaId.value +
'&type=' +
talkingType.value +
'&traInterTyp=' +
detailInfo.value.traInterTyp +
'&isPreview=' +
(isPreview.value ? '1' : '0')
);
common.redirectTo(_gotUrl + '?traId=' + traId.value + '&chaId=' + chaId.value + '&type=' + talkingType.value + '&traInterTyp=' + detailInfo.value.traInterTyp + '&isPreview=' + (isPreview.value ? '1' : '0'))
} catch (err) {
console.error('申请权限失败');
console.error('申请权限失败')
}
};
const activeVoiceTalkingItemId = ref('');
//
const changePlayItemId = (id = '') => {
activeVoiceTalkingItemId.value = id;
};
}
const activeVoiceTalkingItemId = ref('')
//
const changePlayItemId = (id = '') => {
activeVoiceTalkingItemId.value = id
}
const talkItemEvents = ({ type, data, id, info = {} }) => {
const talkItemEvents = ({ type, data, id, info = {} }) => {
switch (type) {
case 'changePlay':
activeVoiceTalkingItemId.value = id;
break;
activeVoiceTalkingItemId.value = id
break
case 'scrollToBottom':
scrollToBottomNow();
break;
scrollToBottomNow()
break
default:
break;
break
}
};
}
const watchFlag = ref(1);
const showModelComfirm = ref(false);
const reconcatNum = ref(0);
const answerText = ref('');
const touchBtnCallBack = ref(null);
let isLeave = false;
const initsocketTask = () => {
let _src = isPreview.value ? '/trapractice/previewsocket/open' : '/trapractice/partnersocket/open';
socketStore.creatSocket(_src + '?summary=');
const watchFlag = ref(1)
const showModelComfirm = ref(false)
const reconcatNum = ref(0)
const answerText = ref('')
const touchBtnCallBack = ref(null)
let isLeave = false
const initsocketTask = () => {
let _src = isPreview.value ? '/trapractice/previewsocket/open' : '/trapractice/partnersocket/open'
socketStore.creatSocket(_src + '?summary=')
// unref(SocketObj).on('open', (res)=>{
// if(!answerIsOver.value){
// sendMessage({
@@ -363,43 +307,34 @@
// }
// })
unref(SocketObj).on('error', () => {
if (watchFlag.value === 1 || showModelComfirm.value) return;
if (watchFlag.value === 1 || showModelComfirm.value) return
if (reconcatNum.value === 5) {
common.msg('系统网络异常,请稍后再试!');
common.redirectTo(`/pages/index/dialog`);
return;
common.msg('系统网络异常,请稍后再试!')
common.redirectTo(`/pages/index/dialog`)
return
}
showModelComfirm.value = true;
reconcatNum.value += 1;
showModelComfirm.value = true
reconcatNum.value += 1
common
.show('提示信息', '网络环境不稳定,请重试!', false, '', '确认')
.then((res) => {
.then(res => {
overNow(() => {
reconcatNum.value += 1;
reconcatNum.value += 1
// common.redirectTo(`/pages/index/dialog`);
socketStore?.closeSocket();
common.redirectTo(
'/pages/sparring/result?isOver=1&traId=' +
traId.value +
'&execId=' +
execId.value +
'&type=' +
talkingType.value +
'&isPreview=' +
(isPreview.value ? '1' : '')
);
});
socketStore?.closeSocket()
common.redirectTo('/pages/sparring/result?isOver=1&traId=' + traId.value + '&execId=' + execId.value + '&type=' + talkingType.value + '&isPreview=' + (isPreview.value ? '1' : ''))
})
})
.finally(() => {
showModelComfirm.value = false;
});
});
unref(SocketObj).on('message', (res) => {
const { rtnCode, body, commond } = JSON.parse(res.data);
let _id = new Date().getTime() + 'id';
showModelComfirm.value = false
})
})
unref(SocketObj).on('message', res => {
const { rtnCode, body, commond } = JSON.parse(res.data)
let _id = new Date().getTime() + 'id'
if (rtnCode === '0000') {
if (commond === 'ASK-OPEN') {
console.log('ASK-OPEN', body);
console.log('ASK-OPEN', body)
//
sendMessage({
commond: 'ASK-START',
@@ -409,28 +344,28 @@
traTyp: talkingType.value,
execId: execId.value || ''
}
});
})
sendMessage({
commond: 'ASK-PING',
body: {
execId: execId.value || ''
}
});
return;
})
return
}
if (commond === 'ASK-START') {
console.log('开启对话!', body);
execId.value = body.execId;
return;
console.log('开启对话!', body)
execId.value = body.execId
return
}
if (commond === 'ASK') {
console.log('发送问题成功!');
console.log(body);
console.log(talkingList.value[talkingList.value.length - 1].isLoading);
console.log('发送问题成功!')
console.log(body)
console.log(talkingList.value[talkingList.value.length - 1].isLoading)
if (talkingList.value.length > 0 && talkingList.value[talkingList.value.length - 1].isLoading) {
talkingList.value = talkingList.value.filter((t) => {
return !(t.type === 'question' && t.isLoading);
});
talkingList.value = talkingList.value.filter(t => {
return !(t.type === 'question' && t.isLoading)
})
}
// seqNo.value = body.seqNo;
// touchBtnCallBack.value && touchBtnCallBack.value();
@@ -443,32 +378,32 @@
id: _id + 'qns',
...body,
talkingVoice: askData.value.talkingVoice
});
})
talkingList.value.push({
type: 'answer',
isLoading: true,
id: _id + 'loading'
});
scrollToBottomNow();
return;
})
scrollToBottomNow()
return
}
if (commond === 'ASK-STOP') {
console.log('停止回答标记!');
stopAnswerCallBack.value && stopAnswerCallBack.value(askData.value);
console.log('停止回答标记!')
stopAnswerCallBack.value && stopAnswerCallBack.value(askData.value)
setTimeout(() => {
stopAnswerCallBack.value = null;
answerIsOver.value = true;
}, 10);
return;
stopAnswerCallBack.value = null
answerIsOver.value = true
}, 10)
return
}
if (commond === 'ASK-ANSWER') {
if (body.event === 'start') {
answerIsOver.value = false;
answerText.value = '';
answerIsOver.value = false
answerText.value = ''
// talkingList.value.pop();
talkingList.value = talkingList.value.filter((t) => {
return !(t.type === 'answer' && t.isLoading);
});
talkingList.value = talkingList.value.filter(t => {
return !(t.type === 'answer' && t.isLoading)
})
talkingList.value.push({
type: 'answer',
talkingText: answerText.value,
@@ -479,131 +414,121 @@
askData: {
...askData.value
}
});
})
} else if (body.event === 'token') {
answerIsOver.value = false;
answerText.value += body.data;
talkingList.value[talkingList.value.length - 1].talkingText = answerText.value;
answerIsOver.value = false
answerText.value += body.data
talkingList.value[talkingList.value.length - 1].talkingText = answerText.value
} else if (body.event === 'end') {
answerIsOver.value = true;
answerIsOver.value = true
} else if (body.event === 'recordAi') {
talkingList.value[talkingList.value.length - 1].execLogId = body.execLogId;
talkingList.value[talkingList.value.length - 1].execLogId = body.execLogId
}
scrollToBottomNow();
return;
scrollToBottomNow()
return
}
if (commond === 'ASK-RE-ANSWER') {
// console.log('')
if (body.event === 'start') {
answerIsOver.value = false;
answerText.value = '';
answerIsOver.value = false
answerText.value = ''
} else if (body.event === 'token') {
answerIsOver.value = false;
answerText.value = body.data;
answerIsOver.value = false
answerText.value = body.data
} else if (body.event === 'end') {
answerIsOver.value = true;
answerIsOver.value = true
}
return;
return
}
if (commond === 'ASK-ERR') {
console.log('提问失败,系统异常!');
return;
console.log('提问失败,系统异常!')
return
}
if (commond === 'ASK-OVER') {
console.log(body);
console.log('陪练已结束,去结果页面!');
socketStore?.closeSocket();
common.redirectTo(
'/pages/sparring/result?isOver=1&traId=' +
traId.value +
'&execId=' +
execId.value +
'&type=' +
talkingType.value +
'&isPreview=' +
(isPreview.value ? '1' : '')
);
return;
console.log(body)
console.log('陪练已结束,去结果页面!')
socketStore?.closeSocket()
common.redirectTo('/pages/sparring/result?isOver=1&traId=' + traId.value + '&execId=' + execId.value + '&type=' + talkingType.value + '&isPreview=' + (isPreview.value ? '1' : ''))
return
}
if (commond === 'ASK-PONG') {
console.log('PONG');
if (isLeave) return;
console.log('PONG')
if (isLeave) return
setTimeout(() => {
sendMessage({
commond: 'ASK-PING',
body: {
execId: execId.value || ''
}
});
}, 30000);
})
}, 30000)
}
} else {
if (['0005', 'QQ0005'].includes(res.rtnCode)) {
goto_login_fun();
goto_login_fun()
}
}
});
watchFlag.value += 1;
};
const goBack = () => {
if (detailInfo.value.traInterTyp === '01') {
overTalking();
} else {
common.navigateBack();
}
};
const overTalking = () => {
common.show('提示', '确定结束陪练吗?').then((res) => {
if (res) {
overNow();
}
});
};
const overNow = (cb = () => {}) => {
partnerChatReportTrigger({
execId: execId.value,
traId: traId.value,
talkingType: isPreview.value ? 'preview' : 'practice'
})
.then((res) => {
watchFlag.value = 1;
watchFlag.value += 1
}
const goBack = () => {
if (detailInfo.value.traInterTyp === '01') {
overTalking()
} else {
common.navigateBack()
}
}
const overTalking = () => {
common.show('提示', '确定结束陪练吗?').then(res => {
if (res) {
overNow()
}
})
}
const overNow = (cb = () => {}) => {
watchFlag.value = 1
sendMessage({
commond: 'ASK-STOP',
body: {
execId: execId.value || ''
}
});
socketStore?.closeSocket();
changePlayItemId('');
common.redirectTo(
'/pages/sparring/result?isOver=1&traId=' +
traId.value +
'&execId=' +
execId.value +
'&type=' +
talkingType.value +
'&isPreview=' +
(isPreview.value ? '1' : '')
);
// pointAndBadgesRun(talkingType.value === '01'? '07': '08', '', ()=>{
// common.redirectTo('/pages/sparring/result?isOver=1&traId=' + traId.value + '&execId=' + execId.value + '&type=' + talkingType.value + '&isPreview=' + (isPreview.value ?'1':''))
// })
})
.catch(() => {
cb();
});
};
const sendMessage = (data) => {
unref(SocketObj).send(data);
socketStore?.closeSocket()
changePlayItemId('')
common.redirectTo('/pages/sparring/result?isOver=1&traId=' + traId.value + '&execId=' + execId.value + '&type=' + talkingType.value + '&isPreview=' + (isPreview.value ? '1' : ''))
// partnerChatReportTrigger({
// execId: execId.value,
// traId: traId.value,
// talkingType: isPreview.value ? 'preview' : 'practice'
// })
// .then(res => {
// watchFlag.value = 1
// sendMessage({
// commond: 'ASK-STOP',
// body: {
// execId: execId.value || ''
// }
// })
// socketStore?.closeSocket()
// changePlayItemId('')
// common.redirectTo('/pages/sparring/result?isOver=1&traId=' + traId.value + '&execId=' + execId.value + '&type=' + talkingType.value + '&isPreview=' + (isPreview.value ? '1' : ''))
// })
// .catch(() => {
// cb()
// })
}
const sendMessage = data => {
unref(SocketObj).send(data)
if (data.commond == 'ASK-PING') {
console.log('PING');
console.log('PING')
}
};
// let timer = null
//#ifdef APP-PLUS
onShow(() => {
isLeave = false;
}
// let timer = null
//#ifdef APP-PLUS
onShow(() => {
isLeave = false
// timer = setInterval(() => {
// sendMessage({
// commond: 'ASK-PING',
@@ -612,54 +537,54 @@
// }
// }, 1000)
// })
});
onHide(() => {
isLeave = true;
})
onHide(() => {
isLeave = true
// clearInterval(timer)
// timer = null
});
// #endif
onLoad((params) => {
traId.value = params.traId;
chaId.value = params.chaId;
talkingType.value = params.type;
isPreview.value = params.isPreview === '1';
getDetailInfo();
console.log('onLoad');
})
// #endif
onLoad(params => {
traId.value = params.traId
chaId.value = params.chaId
talkingType.value = params.type
isPreview.value = params.isPreview === '1'
getDetailInfo()
console.log('onLoad')
//#ifdef APP-PLUS
plus.screen.lockOrientation('portrait-primary');
plus.screen.lockOrientation('portrait-primary')
// #endif
});
onUnload(() => {
console.log('onUnload');
watchFlag.value = 1;
})
onUnload(() => {
console.log('onUnload')
watchFlag.value = 1
sendMessage({
commond: 'ASK-STOP',
body: {
execId: execId.value || ''
}
});
})
if (detailInfo.value.traInterTyp === '01') {
socketStore?.closeSocket();
socketStore?.closeSocket()
}
execId.value = '';
});
onLaunch(() => {
console.log('onLaunch');
});
onMounted(() => {
execId.value = ''
})
onLaunch(() => {
console.log('onLaunch')
})
onMounted(() => {
// getDetailInfo()
});
onBackPress((res) => {
})
onBackPress(res => {
if (res.from === 'backbutton') {
goBack();
return true;
goBack()
return true
}
});
})
</script>
<style lang="scss" scoped>
.sparring-detail {
.sparring-detail {
position: relative;
overflow-x: hidden;
overflow-y: auto;
@@ -1023,5 +948,5 @@
}
}
}
}
}
</style>