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

This commit is contained in:
杨航
2025-08-08 17:46:34 +08:00
7 changed files with 543 additions and 40 deletions
+5 -3
View File
@@ -21,15 +21,17 @@ export default {
<style lang="scss">
/* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
// @import "@/uni_modules/uview-ui/index.scss";
view {
box-sizing: border-box;
}
@font-face {
font-family: 'PingFangSC';
src: url('@/static/font/PingFang-SC.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
view {
box-sizing: border-box;
font-family: "PingFangSC";
}
// 解决uview离线环境下没有图标
@font-face {
@@ -19,9 +19,9 @@
{{subject_data.qnsContent}}
</view>
<view class="option_div">
<questionVue @changePlay="changePlay" :dataInfo="talkingInfo" :activeVoiceId="questionValue"></questionVue>
</view>
</view>
</template>
<script setup>
@@ -31,19 +31,15 @@
onMounted,
nextTick,
computed,
toRaw
toRaw,
watch
} from 'vue'
import questionVue from './question.vue';
import radioSubjectItem from './radio-subject-item.vue'
import {
SUBJECT_TYPE
} from '@/enum.js'
const customStyle = {
borderRadius: '16rpx',
width: '292rpx',
backgroundColor: '#0066FF',
border: '1rpx solid rgb(12, 123, 245)',
}
const emit = defineEmits(['click_option'])
const questionValue = ref('')
const props = defineProps({
item: {
type: Object,
@@ -52,9 +48,52 @@
mode: {
type: String,
required: true,
}
},
activeVoiceId: {
type: String,
required: true,
},
voicePathValue: {
type: String,
required: true,
},
});
const talkingInfo = ref({
id: '3',
intrctWay: "",
intrctContent: "中的i id一二三。",
talkingText: '中的i id一二三。',
talkingVoice: ''
})
watch(() => props.voicePathValue, (val) => {
if (val) {
talkingInfo.value = {
id: '3',
intrctWay: "02",
intrctContent: "中的i id一二三。",
talkingText: '中的i id一二三。',
talkingVoice: val
}
}
})
// "chatId": "CHAT025018122068202508081709060000000000000000000000000000000098",
// "fileId": "S3F0250181220722025080817090600000476885",
// "ossFileAddr": "http://25.18.122.66::9786/traoss/show//S3F0250181220722025080817090600000476885",
// "transContent": "一二三四。"
// const activeVoiceId = ref()
const customStyle = {
borderRadius: '16rpx',
width: '292rpx',
backgroundColor: '#0066FF',
border: '1rpx solid rgb(12, 123, 245)',
}
const emit = defineEmits(['click_option'])
const subject_data = reactive({
qnsId: '',
qnsContent: '',
@@ -67,10 +106,18 @@
})
// 题类型
const subject_type_text = computed(() => SUBJECT_TYPE.find(res => subject_data.qnsTyp === res.value)?.label || '')
const changePlay = (id) => {
console.log('changePlay');
questionValue.value = id
// emit('handleEvents', 'changePlay', props.talkingInfo, id)
}
</script>
<style scoped lang="scss">
.option_div {
padding-top: 46rpx;
}
.item {
// height: 170rpx;
+267
View File
@@ -0,0 +1,267 @@
<template>
<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"/>
</view>
<view class="right-time">{{voiceTime}}</view>
<view class="talking-cont">
<text :class="['talking-text translate-text loading']" v-show="!translateLoading">
{{ showContent }}
</text>
<view class="talking-text translate-text" v-if="translateLoading">
<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> -->
</view>
</view>
</view>
<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-gif']">
<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({
dataInfo: {
default: () => ({}),
type: Object
},
activeVoiceId:{
default:'',
type: String
},
})
const { activeVoiceId, dataInfo } = toRefs(props)
const emit = defineEmits(['changePlay'])
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(()=>{
return dataInfo.value.talkingText || ''
})
onMounted(()=>{
initVoice()
})
onUnload(()=>{
pauseVoice()
})
watch(() => props.dataInfo.talkingVoice,(val)=>{
if(val){
initVoice()
}
},{
deep: true,
immediate: true
})
const pauseVoice = () => {
if(!talkVoiceObj.value) return
talkVoiceObj.value.pause()
isPlaying.value = false
emit('changePlay', '')
}
const playVoice = () =>{
emit('changePlay', unref(dataInfo)?.id)
if(talkVoiceObj.value && talkVoiceObj.value.src) {
talkVoiceObj.value.play()
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'){
itemVoice.value = unref(dataInfo).talkingVoice
talkVoiceObj.value.src = itemVoice.value
console.log(talkVoiceObj.value.src,1111)
setTimeout(()=>{
setVoiceTime(0)
},100)
}
}
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) {
voiceTime.value = 0 + 's'
return
}
setTimeout(()=>{
setVoiceTime(sum)
},200)
}
}
</script>
<style scoped lang="scss">
.talking-info{
padding: 20rpx;
border-radius: 15rpx;
background-color: #06f;
padding-bottom: 30rpx;
position: relative;
color: #fff;
width: 100%;
float: right;
.talking-gif{
width: 200rpx;
height: 38rpx;
background: url(@/static/images/course/voice-gray.png) no-repeat;
background-size: contain;
padding-left: 168rpx;
&.is-play{
background: url(@/static/images/course/voice-white.gif) no-repeat;
background-size: contain;
}
}
.right-time{
position: absolute;
right: 20rpx;
top: 20rpx;
font-size: 28rpx;
height: 38rpx;
line-height: 38rpx;
}
&.talking-info-loading{
padding-bottom: 20rpx;
}
&.talking-info-text{
padding-bottom: 20rpx;
width: auto;
float: right;
.talking-cont{
margin-top: 0rpx;
}
}
.talking-cont{
margin-top: 16rpx;
overflow: hidden;
.talking-text{
font-size: 28rpx;
line-height: 48rpx;
margin-bottom: 20rpx;
word-break: break-all;
white-space: pre-line;
overflow: hidden;
&.translate-text{
min-height: 48rpx;
}
}
}
.btns-cont{
overflow: hidden;
border-top: 3rpx solid #eee;
.replay-btn{
float: left;
width: 46rpx;
height: 46rpx;
overflow: hidden;
margin-right: 16rpx;
margin-top: 25rpx;
}
.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;
line-height: 46rpx;
text-align: center;
color: #fff;
margin-right: 16rpx;
margin-top: 25rpx;
background-color: #67A4ff;
font-size: 24rpx;
font-weight: bold;
border-radius: 20rpx;
}
.text-right-btn{
float: right;
padding: 0 10rpx;
height: 46rpx;
overflow: hidden;
line-height: 46rpx;
text-align: center;
margin-left: 16rpx;
margin-top: 25rpx;
}
.next-btn{
float: right;
padding: 0 60rpx 0 20rpx;
height: 62rpx;
line-height: 62rpx;
font-size: 30rpx;
background-color: #06f;
color: #fff;
border-radius: 8rpx;
margin-top: 16rpx;
position: relative;
.icon-iamge{
width: 25rpx;
height: 25rpx;
position: absolute;
right: 20rpx;
top: 50%;
margin-top: -12rpx;
}
}
}
}
</style>
+206 -21
View File
@@ -25,14 +25,18 @@
</view>
<view class="scroll_div">
<swiper class="swiper" :indicator-dots="false" @change="swiperChange" :current="questionNumber" easing-function="linear">
<swiper class="swiper" :indicator-dots="false" @change="swiperChange" :current="questionNumber"
easing-function="linear">
<swiper-item v-for="(item,index) in topicList">
<view class="content">
<view class="expose_shadow"></view>
<scroll-view :scroll-y="true" class="scroll-Y" :show-scrollbar="false" :refresher-threshold="0">
<RadioSubject :item="item" v-if="item.qnsTyp !== 'ES'" :mode="mode">
</RadioSubject>
<CharactersSubject :item="item" v-if="item.qnsTyp === 'ES'" :mode="mode">
<CharactersSubject :item="item" v-if="item.qnsTyp === 'ES'" :mode="mode"
:activeVoiceId="activeVoiceId"
:voicePathValue="voicePathValue"
>
</CharactersSubject>
</scroll-view>
</view>
@@ -40,26 +44,59 @@
</swiper>
</view>
<view class="fixed-btn-box font_pf">
<view class="sheet">
<image :src="examinationSheetIcon()" class="img"></image>
<view class="sheet_text">答题卡</view>
<view class="fixed-box font_pf">
<view class="fixed-btn-box">
<view class="sheet_button" @click="openSheet()">
<image :src="examinationSheetIcon()" class="img"></image>
<view class="sheet_text">答题卡</view>
</view>
<view class="button_div">
<uv-button class="button" type="primary" :throttleTime="100" text="上一题" color="#E2EDFF"
custom-style="color:#0066FF;borderRadius:16rpx;height:92rpx;"
@click="button_tab(-1)"></uv-button>
<view style="width:46rpx"></view>
<uv-button class="button" type="primary" :throttleTime="100" text="下一题" color="#0066FF"
custom-style="color:#FFFFFF;borderRadius:16rpx;height:92rpx;"
@click="button_tab(1)"></uv-button>
</view>
</view>
<view class="button_div">
<uv-button class="button" type="primary" :throttleTime="100" text="上一题" color="#E2EDFF"
custom-style="color:#0066FF;borderRadius:16rpx;height:92rpx;" @click="button_tab(-1)"></uv-button>
<view style="width:46rpx"></view>
<uv-button class="button" type="primary" :throttleTime="100" text="下一题" color="#0066FF"
custom-style="color:#FFFFFF;borderRadius:16rpx;height:92rpx;" @click="button_tab(1)"></uv-button>
<view class="touch-btn-div" :class="{'show':showTouchBtn}">
<TouchBtn class="talk-btns" @uploadVoice="uploadRecordNow" @submitAnswer="submitAnswerNow"
:loadingText="sendLoadingText" :isLoading="!answerIsOver" :isDisabled="false" />
</view>
</view>
</view>
<uni-popup ref="popup" class="popup">
<view class="sheet_popup_div">
<view class="title_div">
<view class="text">
答题卡
</view>
<view class="popup_back_div">
</view>
</view>
<view class="sheet_table">
<view class="sheet_table_item" v-for="(item,index) in [1,2,3,4,5,67,8,9,10,11,12,13,14,15]">
<view class="circle">
{{index + 1}}
</view>
</view>
</view>
<view class="sheet_button">
<uv-button class="button" type="primary" :throttleTime="100" text="交卷" color="#0066FF"
custom-style="color:#FFFFFF;borderRadius:16rpx;height:92rpx;"
></uv-button>
</view>
</view>
</uni-popup>
</view>
</template>
<script setup>
import RadioSubject from '@/components/examination/radio-subject.vue'
import CharactersSubject from '@/components/examination/characters-subject.vue'
import TouchBtn from '@/pages/course/components/touchBtn.vue'
import {
ref,
reactive,
@@ -78,25 +115,37 @@
import {
getPageCache
} from '@/common/common';
import {
commonUploadVoiceFile
} from "@/api/common.js"
const sendLoadingText = ref('问题回答中,请在问题回答结束后重试!')
const answerIsOver = ref(true)
const examId = ref('')
const popup = ref(null)
const mode = ref('examination') // 考试 examination 练习practice
const paperData = reactive({
papersId: '',
limitTm: 0,
papersName: '',
}) // 试卷信息
const topicList = reactive([]) // 问题列表
const questionNumber = ref(0) // 题号
const showTouchBtn = computed(() => {
return topicList[questionNumber.value]['qnsTyp'] === 'ES'
})
const progress = computed(() => { // 计算进度百分比(保留两位小数)
const total = topicList.length;
if (total === 0) return 0;
const completed = questionNumber.value + 1;
return Math.min(Math.round((completed / total) * 10000) / 100, 100);
})
const topicList = reactive([]) // 问题列表
const questionNumber = ref(0) // 题号
const activeVoiceId = ref('')
const swiperChange = (item) => {
questionNumber.value = item.detail.current
}
// 按上一题下一题
const button_tab = (num) => {
let newNumber = questionNumber.value + num;
@@ -108,6 +157,71 @@
questionNumber.value = newNumber;
}
// 打开答题卡
const openSheet = () => {
popup.value.open('bottom');
}
const voicePathValue = ref('')
// 发送语音
const uploadRecordNow = (voicePath) => {
console.log('voicePath',voicePath);
//#ifdef APP-PLUS
// talkingList.value.push({
// type: 'question',
// talkingText: '',
// isLoading: true
// })
// scrollToBottomNow()
commonUploadVoiceFile(voicePath, '/traask/traAskchat/voiceTrans', {}).then(res => {
let _res = JSON.parse(res.data)
voicePathValue.value = voicePath
console.log('_res', _res, voicePath);
if (_res.rtnCode === '0000') {
// "chatId": "CHAT025018122068202508081537410000000000000000000000000000000088",
// "fileId": "S3F0250181220722025080815374100000456565",
// "ossFileAddr": "http://25.18.122.66::9786/traoss/show//S3F0250181220722025080815374100000456565",
// "transContent": "下面那几个跟。"
// activeVoiceId.value =
// if (!!(_res.body.transContent || '').trim()) {
// askData.value = {
// reqBatch: reqBatch.value,
// intrctWay: '02', //01-文本;02-语音;03-图片
// intrctContent: _res.body.transContent,
// bucketKey: _res.body.fileId,
// ossFileAddr: _res.body.ossFileAddr,
// talkingVoice: voicePath
// }
// sendMessage({
// "commond": 'ASK',
// "body": askData.value
// })
// } else {
// // talkingList.value.pop()
// uni.showToast({
// title: '未识别到文字!',
// icon: "none",
// duration: 1000
// });
// }
} else {}
}).catch(err => {
// talkingList.value.pop()
uni.showToast({
title: '系统异常,请联系管理员',
icon: "none",
duration: 1000
});
})
// #endif
}
// 发送文本
const submitAnswerNow = (val, cb = null) => {
}
// 初始化时检查
onLoad(() => {
const examination = getPageCache('examination')
@@ -125,28 +239,99 @@
})))
});
const hand_in_paper = () => {
console.log('点击交卷', topicList);
console.log('点击交卷', showTouchBtn.value);
showTouchBtn.value = !showTouchBtn.value
}
</script>
<style scoped lang="scss">
$bg-margin-left: 30rpx;
.fixed-btn-box {
.popup {
//答题卡
z-index: 1800;
padding: 0 38rpx;
.sheet_popup_div {
width: 100%;
height: 100%;
background-color: #FFFFFF;
padding: 10rpx 34rpx;
display: flex;
flex-direction: column;
align-items: center;
border-radius: 16rpx 16rpx 0px 0px;
.title_div {
width: 100%;
text-align: center;
padding: 30rpx 0;
font-family: PingFangSC;
font-weight: 600;
font-size: 34rpx;
color: #000000;
text-align: center;
font-style: normal;
border-bottom: 2rpx solid #EFEFEF;
}
.sheet_table {
margin-top: 48rpx;
margin-bottom: 48rpx;
display: flex;
/* 启用 Flex 布局 */
flex-wrap: wrap;
/* 超出宽度时自动换行 */
width: calc(100vw - 108rpx);
align-content: space-between;
.sheet_table_item {
width: calc((100vw - 108rpx) / 5 - 16rpx);
height: calc((100vw - 108rpx) / 5 - 16rpx);
margin: 8rpx;
border: 2rpx solid #E5E5E5;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
}
}
.sheet_button{
width: 100%;
}
}
}
.fixed-box {
position: fixed;
width: 100%;
left: 0;
bottom: 0;
height: 154rpx;
background: #FFFFFF;
border-radius: 16rpx 16rpx 0px 0px;
border: 2rpx solid #E5E5E5;
background: #FFFFFF;
}
.touch-btn-div {
height: 0;
overflow: hidden;
transition: height 0.2s ease-out;
}
.touch-btn-div.show {
height: 150rpx;
}
.fixed-btn-box {
height: 154rpx;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 20rpx 20rpx 20rpx;
.sheet {
.sheet_button {
display: flex;
flex-direction: column;
align-items: center;
+1
View File
@@ -252,6 +252,7 @@
seqNo.value = body.seqNo
touchBtnCallBack.value && touchBtnCallBack.value()
touchBtnCallBack.value = null
console.log('嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻', body);
talkingList.value.push({
type: 'question',
talkingText: body.intrctContent,
+1 -1
View File
@@ -5,7 +5,7 @@
<!-- 主体 -->
<view class="content">
<view class="drop-down-div"> 下拉显示</view>
<view class="item" v-for="(item,index) in data_list" :class="index % 2?'completed':'incomplete'"
<view class="item" v-for="(item,index) in data_list" :class="item.examStatText=='Y'?'completed':'incomplete'"
@click="gotoDetails(item)">
<view class="subscript" v-if="item.examStatText==='N'">未完成</view>
<view class="subscript" v-if="item.examStatText==='Y'">已完成</view>
+4 -3
View File
@@ -6,11 +6,12 @@
</view>
<view>考试详情</view>
</view>
<view class="detail_div completed incomplete">
<view class="subscript">完成</view>
<view class="detail_div" :class="detailData.examStatText=='Y'?'completed':'incomplete'">
<view class="subscript" v-if="detailData.examStatText==='N'">完成</view>
<view class="subscript" v-if="detailData.examStatText==='Y'">已完成</view>
<view class="title_div">
<view class="title ellipsis-text">{{detailData.papersName}}</view>
<!-- <view class="subscript" >未完成</view> -->
</view>
<view class="time">
<text class="color_3">起止时间</text><text