<template>
<div class="warp">
<div class="wtdimg">
<img :src="problemObject.wd_tp" alt="">
<img :src="problemObject.wd_kf_dt" alt="">
</div>
<div v-for="(value, sectionKey) in problemObject" :key="sectionKey">
<div v-for="(index, problemKey) in value" :key="problemKey">
<div v-if="index.problemStatus" class="problem">
<CusTomer :kf_tx="problemObject.wd_kf_tx" :wd_mc="problemObject.wd_mc" :question=index.problem :btn_display=index.btnStatus
:choices=index.options :zaaxclick="index.btnclick" @choiceSelected="handleChoiceSelected(problemKey, $event)" />
<user :problem=index.user_reply :display="index.displayStatus" />
<!-- 检测没有选项的问答,自动显示下一个 -->
<div v-if="index.options && index.options.length === 0 && index.problemStatus" style="display: none;">
{{ handleNoOptionsProblem(problemKey) }}
</div>
</div>
</div>
</div>
<!-- 不符合 -->
<div v-if="problemObject.end && problemObject.end.problemStatus">
<CusTomer :kf_tx="problemObject.wd_kf_tx" :question=problemObject.end.problem />
</div>
<div style="height: 300px;"></div>
</div>
</template>methods 新加方法
// 新增方法:处理没有选项的问答自动显示下一个
handleNoOptionsProblem(problemKey) {
// 检查是否已经处理过这个问答
if (this.problemObject.problems[problemKey]._noOptionsHandled) {
return;
}
// 标记为已处理
this.problemObject.problems[problemKey]._noOptionsHandled = true;
const keys = Object.keys(this.problemObject.problems);
const currentIndex = keys.indexOf(problemKey);
if (currentIndex + 1 < keys.length) {
setTimeout(() => {
this.problemObject.problems[keys[currentIndex + 1]].problemStatus = true;
}, 1500);
}
// 视窗滚动到文档的最底部
window.scrollTo({
top: document.documentElement.scrollHeight,
behavior: 'smooth' // 平滑滚动
});
},
评论 (0)