更新问答 检测 没有选项直接下一个问题
标签搜索
侧边栏壁纸
  • 累计撰写 16 篇文章
  • 累计收到 24 条评论

更新问答 检测 没有选项直接下一个问题

lay
lay
2025-10-23 / 0 评论 / 33 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2025年10月23日,已超过70天没有更新,若内容或图片失效,请留言反馈。
<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

评论 (0)

取消