304 lines
7.5 KiB
Vue
304 lines
7.5 KiB
Vue
<template>
|
|
<view class="answer-content" v-if="props.isLoading">
|
|
<view class="talking-cont">
|
|
<CommonLoading color="#06f" />
|
|
</view>
|
|
</view>
|
|
<view class="answer-content" v-else>
|
|
<view class="talking-cont">
|
|
<MarkdownPreview :mdString="mdText" />
|
|
<!-- <text v-text="props.dataInfo?.talkingText|| ''"></text> -->
|
|
</view>
|
|
<view class="talking-link">
|
|
<view :class="['link-cont', activeNames.indexOf(1) >= 0 ? 'is-active' : '']" v-if="fileList.length > 0">
|
|
<view class="link-info" @click="changeActive(1)">
|
|
<view class="info-text"> 引用知识库{{ fileList.length }}篇相关资料 </view>
|
|
</view>
|
|
<view class="link-items">
|
|
<view class="link-item" v-for="(item, index) in fileList" @click.stop="previewFile(item)">{{ index + 1 }}. {{ item.docName }}</view>
|
|
</view>
|
|
</view>
|
|
<view v-else-if="!props.isAnswering" class="link-cont-desc">本次回答参考资料来源于网络</view>
|
|
<view :class="['link-cont', activeNames.indexOf(2) >= 0 ? 'is-active' : '']" v-if="crsList.length > 0">
|
|
<view class="link-info" @click="changeActive(2)">
|
|
<view class="info-text"> 发现{{ crsList.length }}个关联课程 </view>
|
|
</view>
|
|
<view class="link-items">
|
|
<view class="link-item" v-for="(item, index) in crsList" @click.stop="previewCrs(item)">{{ index + 1 }}. {{ item.crsName }}</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="btns-cont" v-if="!props.isLoading">
|
|
<view class="replay-btn" @click="reAnswer" v-if="!props.dataInfo.isHistory">
|
|
<image class="icon" src="@/static/images/dialog/answer-restart1.png" style="width: 100%; height: 100%"></image>
|
|
</view>
|
|
<!-- <view class="replay-btn" @click="stopAnswer" v-if="props.isAnswering && props.isLast">
|
|
<image class="icon" src="@/static/images/dialog/answer-stop1.png" style="width: 100%; height: 100%"></image>
|
|
</view> -->
|
|
<view class="replay-btn" @click="zanAnswer">
|
|
<image class="icon" v-if="props.dataInfo.likeStat !== 'Y'" src="@/static/images/dialog/answer-zan1.png" style="width: 100%; height: 100%"></image>
|
|
<image class="icon" v-else src="@/static/images/dialog/answer-yizan1.png" style="width: 100%; height: 100%"></image>
|
|
</view>
|
|
<view class="play-btn" @click="feedbackAnswer">
|
|
<image class="icon" v-if="props.dataInfo.downvoteStat !== 'Y'" src="@/static/images/dialog/answer-fankui1.png" style="width: 100%; height: 100%"></image>
|
|
<image class="icon" v-else src="@/static/images/dialog/answer-yifankui1.png" style="width: 100%; height: 100%"></image>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { onMounted, computed, ref, watch } from 'vue'
|
|
import MarkdownPreview from '@/components/markdown-preview/markdown-preview.vue'
|
|
import common from '@/common/common'
|
|
import DOMPurify from 'dompurify'
|
|
|
|
const emit = defineEmits(['handleEvents'])
|
|
const props = defineProps({
|
|
dataInfo: {
|
|
default: () => ({}),
|
|
type: Object
|
|
},
|
|
isLoading: {
|
|
default: false,
|
|
type: Boolean
|
|
},
|
|
isAnswering: {
|
|
default: false,
|
|
type: Boolean
|
|
},
|
|
isLast: {
|
|
default: false,
|
|
type: Boolean
|
|
}
|
|
})
|
|
|
|
watch(
|
|
() => props.dataInfo,
|
|
() => {},
|
|
{
|
|
deep: true,
|
|
immediate: true
|
|
}
|
|
)
|
|
watch(
|
|
() => props.isLoading,
|
|
() => {},
|
|
{
|
|
deep: true,
|
|
immediate: true
|
|
}
|
|
)
|
|
const mdText = computed(() => {
|
|
let _text = (props.dataInfo?.talkingText|| '').replace(/\\n/g, `\n`);
|
|
let _endtext = _text // DOMPurify.sanitize(_text)
|
|
return _endtext
|
|
})
|
|
const fileList = computed(() => props.dataInfo?.talkingFiles || [])
|
|
const crsList = computed(() => props.dataInfo?.talkingCrsList || [])
|
|
const activeNames = ref([1, 2])
|
|
|
|
const changeActive = val => {
|
|
if (activeNames.value.indexOf(val) >= 0) {
|
|
activeNames.value = activeNames.value.filter(t => t !== val)
|
|
} else {
|
|
activeNames.value.push(val)
|
|
}
|
|
}
|
|
const reAnswer = () => {
|
|
emit('handleEvents', 'reAnswer')
|
|
}
|
|
const stopAnswer = () => {
|
|
emit('handleEvents', 'stop')
|
|
}
|
|
const zanAnswer = () => {
|
|
emit('handleEvents', 'great')
|
|
}
|
|
const feedbackAnswer = () => {
|
|
emit('handleEvents', 'feedback')
|
|
}
|
|
const previewFile = item => {
|
|
emit('handleEvents', 'preview', item)
|
|
}
|
|
const previewCrs = item => {
|
|
common.navigateTo('/pages/courseDetail/index?crsId=' + item.crsId)
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.answer-content {
|
|
background-color: #f5f5f5;
|
|
padding: 20rpx;
|
|
border-radius: 15rpx;
|
|
padding-bottom: 10rpx;
|
|
position: relative;
|
|
overflow: hidden;
|
|
float: left;
|
|
width: 100%;
|
|
min-height: 80rpx;
|
|
|
|
.talking-cont {
|
|
padding-bottom: 20rpx;
|
|
}
|
|
|
|
.btns-cont {
|
|
overflow: hidden;
|
|
border-top: 3rpx solid #eee;
|
|
padding-bottom: 10rpx;
|
|
|
|
.replay-btn {
|
|
float: left;
|
|
width: 46rpx;
|
|
height: 46rpx;
|
|
overflow: hidden;
|
|
margin-right: 20rpx;
|
|
margin-top: 20rpx;
|
|
}
|
|
|
|
.play-btn {
|
|
float: left;
|
|
width: 46rpx;
|
|
height: 46rpx;
|
|
overflow: hidden;
|
|
margin-right: 20rpx;
|
|
margin-top: 20rpx;
|
|
}
|
|
|
|
.next-learn-btn {
|
|
float: left;
|
|
padding: 0 60rpx 0 20rpx;
|
|
height: 62rpx;
|
|
line-height: 62rpx;
|
|
font-size: 30rpx;
|
|
background-color: #06f;
|
|
color: #fff;
|
|
border-radius: 8rpx;
|
|
margin-top: 16rpx;
|
|
margin-right: 16rpx;
|
|
position: relative;
|
|
|
|
&.replay-study-btn {
|
|
float: right;
|
|
}
|
|
|
|
&.restart {
|
|
background-color: #eaf2ff;
|
|
color: #06f;
|
|
}
|
|
|
|
.icon-iamge {
|
|
width: 25rpx;
|
|
height: 25rpx;
|
|
position: absolute;
|
|
right: 20rpx;
|
|
top: 50%;
|
|
margin-top: -12rpx;
|
|
}
|
|
}
|
|
|
|
.replay-learn-btn {
|
|
float: left;
|
|
padding: 0 60rpx 0 20rpx;
|
|
height: 62rpx;
|
|
line-height: 62rpx;
|
|
font-size: 30rpx;
|
|
color: #06f;
|
|
background-color: #eaf2ff;
|
|
border-radius: 8rpx;
|
|
margin-top: 16rpx;
|
|
margin-right: 16rpx;
|
|
position: relative;
|
|
|
|
.icon-iamge {
|
|
width: 25rpx;
|
|
height: 25rpx;
|
|
position: absolute;
|
|
right: 20rpx;
|
|
top: 50%;
|
|
margin-top: -12rpx;
|
|
}
|
|
}
|
|
|
|
.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;
|
|
}
|
|
}
|
|
}
|
|
.link-cont-desc {
|
|
margin-bottom: 12rpx;
|
|
font-size: 24rpx;
|
|
color: #999;
|
|
}
|
|
.link-cont {
|
|
margin-bottom: 12rpx;
|
|
font-size: 28rpx;
|
|
.link-info {
|
|
height: 50rpx;
|
|
line-height: 50rpx;
|
|
overflow: hidden;
|
|
margin-bottom: 12rpx;
|
|
|
|
.info-text {
|
|
float: left;
|
|
padding-right: 20rpx;
|
|
}
|
|
|
|
&::after {
|
|
transition: all 0.3s ease-in-out;
|
|
content: '';
|
|
display: block;
|
|
float: left;
|
|
position: relative;
|
|
top: 12rpx;
|
|
width: 12rpx;
|
|
height: 12rpx;
|
|
border-right: 4rpx solid #333;
|
|
border-bottom: 4rpx solid #333;
|
|
transform: rotate(135deg);
|
|
}
|
|
}
|
|
|
|
&.is-active {
|
|
.link-info {
|
|
&::after {
|
|
top: 18rpx;
|
|
transform: rotate(45deg);
|
|
}
|
|
}
|
|
|
|
.link-items {
|
|
max-height: 600rpx;
|
|
}
|
|
}
|
|
|
|
.link-items {
|
|
max-height: 0rpx;
|
|
overflow: hidden;
|
|
transition: all 0.3s ease-in-out;
|
|
|
|
.link-item {
|
|
line-height: 48rpx;
|
|
color: #06f;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|