Adinnet-Web Adinnet-Web
首页
  • 技术沉淀

    • 技术沉淀
  • 前端文章

    • JavaScript
  • 前端笔记

    • 《JavaScript教程》
    • 《JavaScript高级程序设计》
    • 《ES6 教程》
    • 《Vue》
    • 《React》
    • 《TypeScript 从零实现 axios》
    • 《Git》
    • TypeScript
    • JS设计模式总结
  • HTML
  • CSS
  • 技术文档
  • GitHub技巧
  • Nodejs
  • 博客搭建
  • 学习
  • 实用技巧
收藏
  • 分类
  • 标签
  • 归档
首页
  • 技术沉淀

    • 技术沉淀
  • 前端文章

    • JavaScript
  • 前端笔记

    • 《JavaScript教程》
    • 《JavaScript高级程序设计》
    • 《ES6 教程》
    • 《Vue》
    • 《React》
    • 《TypeScript 从零实现 axios》
    • 《Git》
    • TypeScript
    • JS设计模式总结
  • HTML
  • CSS
  • 技术文档
  • GitHub技巧
  • Nodejs
  • 博客搭建
  • 学习
  • 实用技巧
收藏
  • 分类
  • 标签
  • 归档
  • JavaScript文章

  • 学习笔记

  • 技术沉淀

    • CSS矩形绘制
    • 仿微信通讯录
    • 微信小程序订阅消息
    • 保存海报
    • 微信小程序页面弹框
    • 微信小程序在指定距离范围内签到
    • h5嵌套u3d,使用iframe进行交互
    • 前端主导文件处理方法
    • 图片压缩方法封装
    • 金额大写函数
    • 前端主导的小程序一键导航功能
    • uniapp富文本组件(只支持H5)
    • uniapp二次确认弹框组件(依赖于uview)
    • 无缝滚动插件(vue3)
    • H5与unity通信(只针对unity嵌套H5)
    • 辅助触控
    • 关系图
    • h5&svg点赞动效
    • iframe高精地图文件预览
    • 自适应横向瀑布流布局
    • 考试功能
    • 仿小说翻页
    • 富文本
    • h5唤醒App
    • vue3 Count-to数字翻动
    • 小程序图片转base64
    • 第三方应用跳转微信小程序
    • 圆角TabBar
    • 大屏Header
    • Echarts中国地图
    • 使用computed拦截v-model
    • 消息订阅与发布
    • Html相对路径页面跳转
    • Vite打包本地访问
    • H5主题切换
    • 移动端列表分页
    • 每次进入页面都触发的功能(v3)
    • 智能导诊
      • js中几个优雅的运算符使用技巧
      • 其他CSS伪元素
      • 微信浏览器保存canvas海报
      • uniappH5手动拖拽缩放自定义绘制海报
      • uniapp小程序盒子拖拽排序
      • 微信小程序地图的使用
      • css静态漏斗绘制
      • 微信小程序图片流处理
      • ios时间问题
      • 文字围绕效果
      • 表格树动态计算
      • React中useEffect用法
      • React Hooks 陷阱
      • Naive UI修改默认样式
      • vue 根据div id 滚动到指定view到可视视图中
      • js将[1,2,3]排列组合成[1.12.123]
      • 移动端如何加载vite导出dist包
      • TS探索接口、泛型和自定义类型
      • WebSocket中加入Token
      • 幂方程指数衰减
      • pageSpy
      • 表格多条件搜索
      • axios get 请求 url 转码 空格转成+,导致请求失败
      • NaiveUI使用Message组件遇到的问题记录
      • 小程序多盒子拖拽排序
      • 对象快速筛key方法
      • 倒计时
      • nuxt3中的useAsyncData使用详解
      • nuxt3文件式路由
      • 播放amr格式音频
      • echarts瀑布图
      • vue中使用vueuse进行文件导出
      • 分享一个数据整理方法
      • naiveui表格shift多选
      • 数组递归转tree
      • 自定义指令图片懒加载
      • 将数组里面的对象转换成我们需要的键值对
      • 亚马逊云s3上传
      • 上拉加载更多封装
      • JS设计模式总结笔记
      • 适配移动端页面顶部安全区域
      • 【CryptoJS】使用介绍
      • 微信小程序富文本图片点击放大
      • 微信小程序省市区级联选择
      • uniapp拖动排序插件
      • element ui 的树形结构懒加载,局部更新
      • 表单搜索过滤空值
      • 判断设备类型
      • tsconfig配置打包问题
      • vant-uploader上传组件添加长按保存图片
      • BroadcastChannel跨页面通信
      • pnpm安装问题
      • echart阶梯图形绘制
      • js根据对象拼接参数
      • 集成免密登录
      • 输入框输入数字限制
      • js控制全局css变量
      • 流程图
      • 修改npm包
      • tsx在vue3中的应用
      • 109video播放视频流
      • echart默认展示某个点的tooltip
      • 大屏适配几种方案
      • 表单低代码自定义列表页
      • 表单低代码列表页配置端代码
      • 低代码平台使用的一些好用的js方法
      • vue3cookie的使用
      • 原生js下载文件
      • stompjs 创建socket,断线重连机制
      • iframe作为内嵌网页cookie设置
      • 前端对文件内容解析生成特定算法哈希值方法
      • vue3中前端自定义命名文件名称下载文件的方法
      • 前端项目中权限判断的方法配合路由守卫使用
      • 原生table:表格table中thead固定,tbody超出高度出现滚动条
      • vue中使用原生的方法
      • vue3中amchart的初步使用
      • base64图片加水印
      • 手写签名
      • base64转doc文件
    • 前端
    • 技术沉淀
    朱艺
    2024-03-12
    目录

    智能导诊

    # 效果图

    Alt text Alt text

    # 功能

    移动端项目中,当用户想访问的内容层级比较深的时候,会有智能导诊模块,类似与客服聊天但并非真正的聊天(如im聊天),而是通过一些快捷选择将用户想要访问的内容迅速展示出来

    项目中,需要根据项目情况看导诊的步骤具体有几步,并对样式及逻辑进行调整

    # 实现

    <template>
      <div class="intelligent-guide-page">
        <!-- 步骤条 -->
        <div class="step-wrapper fcb">
          <div v-for="(item, index) in stepList" :key="index" :class="['step-item fs24 fc', step >= item.value ? 'active' : '']" @click="skipTo(item)">
            {{ item.name }}
            <span v-if="item.value < 4">
              <img v-if="step >= item.value" src="@/assets/images/common/nav-arrow-active.png" alt="">
              <img v-else src="@/assets/images/common/nav-arrow.png" alt="">
            </span>
          </div>
        </div>
        <div ref="scrollRef" class="page-wrapper main-bg">
          <div v-for="(item, index) in chatHistory" :key="index" class="history-list">
            <div v-if="item.type === 'date'" class="time fs24 text-gray">
              {{ item.content }}
            </div>
            <!-- 客服聊天框 -->
            <div v-if="item.type === 'service'" class="service-chat flex">
              <img class="avatar" src="@/assets/images/common/chat-icon.png" alt="">
              <div class="main-info f-col">
                <span class="name fs24 c-dark">{{ item.name }}</span>
                <span class="chat-content bg-white fs28 c-dark">{{ item.content }}</span>
              </div>
            </div>
            <!-- 内容标签(筛选条件) -->
            <div v-if="item.type === 'tags'" class="search-tag">
              <p class="fs28 c-dark">{{ item.content }}</p>
              <div class="tag-list fw">
                <div v-for="(_item, _index) in item.tagList" :key="_index" class="tag-item fcc" @click="tagSelect(_item, item.tagsType)">
                  {{ _item.name }}
                </div>
              </div>
            </div>
            <!-- 我的聊天框 -->
            <div v-if="item.type === 'mine'" class="mine-chat fe">   
              <div class="main-info f-col">
                <span class="name fs24 c-dark">{{ userInfo.nickName }}</span>
                <span class="chat-content bg-white fs28 c-dark">{{ item.content }}</span>
              </div>
              <img v-if="userInfo.avatar" class="avatar" :src="userInfo.avatar" alt="">
              <img v-else class="avatar" src="@/assets/images/common/avatar.png" alt="">
            </div>
            <!-- 项目列表(最终寻找的内容) -->
            <div v-if="item.type === 'project'" class="project-list">
              <ReservationItem v-for="_item in item.data" :key="_item.id" :doctor-id="doctorId" :data="_item" is-nav />
            </div>
          </div>
        </div>
      </div>
    </template>
    
    <script setup>
    import moment from 'moment';
    import useUserInfo from '@/stores/userInfo.store';
    import { 
      categoryList, 
      organizationList, 
      doctorList, 
      projectList,
    } from '@/services/index.service';
    import useTitle from '@/compositions/useTitle';
    
    const title = useTitle('智能导诊');
    const userInfo = ref({});
    const userInfoStore = useUserInfo();
    const step = ref(0);
    const scrollRef = ref(null);
    const stepList = ref([     // 操作步骤
      { value: 1, name: '选择项目' },
      { value: 2, name: '选择机构' },
      { value: 3, name: '选择医生' },
      { value: 4, name: '推荐项目' },
    ]);
    const chatHistory = ref([
      { type: 'date', content: moment().format('YYYY年MM月DD日 HH:mm') },
    ]);
    
    const categoryOneId = ref('');
    const categoryTwoId = ref('');
    const organizationId = ref('');
    const doctorId = ref('');
    
    userInfoStore.getUserInfo().then((res) => {
      userInfo.value = res;
    });
    
    // 获取一级项目列表
    const getCategoryListOne = async () => {
      step.value = 1;
      chatHistory.value.push({
        name: '客服导诊',
        type: 'service',
        content: '您好,请根据指引进行选择,我们将会为您推荐合适的项目。',
      });
    
      const { data } = await categoryList({ categoryId: 0 });
      chatHistory.value.push({
        name: '',
        type: 'tags',
        content: '点击标签选择一级项目',
        tagsType: 'category1',
        tagList: data,
      });
    };
    
    // 获取二级项目列表
    const getCategoryListTwo = async () => {
      step.value = 1;
      const { data } = await categoryList({ categoryId: categoryOneId.value });
      chatHistory.value.push({
        name: '',
        type: 'tags',
        content: '点击标签选择二级项目',
        tagsType: 'category2',
        tagList: data,
      });
    };
    
    // 获取机构列表
    const getOrganList = async () => {
      step.value = 2;
      const { data } = await organizationList({ categoryId: categoryTwoId.value });
      chatHistory.value.push({
        name: '',
        type: 'tags',
        content: '点击标签选择机构',
        tagsType: 'organization',
        tagList: data,
      });
    };
    
    // 获取选择医生列表
    const getDoctorList = async () => {
      step.value = 4;
      const { data } = await doctorList({ categoryId: categoryTwoId.value, organizationId: organizationId.value });
      chatHistory.value.push({
        name: '',
        type: 'tags',
        content: '点击标签选择医生',
        tagsType: 'doctor',
        tagList: data,
      });
    };
    
    // 获取项目列表
    const getProjectList = async () => {
      step.value = 5;
      const { data } = await projectList({ categoryId: categoryTwoId.value, organizationId: organizationId.value, doctorId: doctorId.value });
      chatHistory.value.push({
        name: '客服导诊',
        type: 'service',
        content: '根据您的需求路径,为您推荐以下项目:',
      });
    
      setTimeout(() => {
        chatHistory.value.push({
          name: '',
          type: 'project',
          data,
        });
      }, 1000);
    };
    
    // 标签选择
    const tagSelect = (tag, tagsType) => {
      chatHistory.value.pop();
      chatHistory.value.push({
        type: 'mine',
        content: tag.name,
      });
    
      switch (tagsType) {
      case 'category1':
        categoryOneId.value = tag.id;
        getCategoryListTwo();
        break;
      case 'category2':
        categoryTwoId.value = tag.id;
        getOrganList();
        break;
      case 'organization':
        organizationId.value = tag.id;
        getDoctorList();
        break;
      case 'doctor':
        doctorId.value = tag.id;
        getProjectList();
        break;
      default:
        break;
      }
    };
    
    const scrollToBottom = () => {   // 点击步骤条滚动到页面最下方位置
      setTimeout(() => {
        const scrollElem = scrollRef.value;
        scrollElem.scrollIntoView({
          behavior: 'smooth',
          block: 'end', 
          inline: 'nearest',
        });
      }, 500);
    };
    
    // 点击步骤条
    const skipTo = (item) => {
      console.log(item.value >= step.value, step.value);
      if (item.value >= step.value) {
        return;
      }
      if (chatHistory.value[chatHistory.value.length - 1].type === 'tags') {
        chatHistory.value.pop();
      }
      switch (item.value) {
      case 1:
        getCategoryListOne();
        break;
      case 2:
        getOrganList();
        break;
      case 3:
        getDoctorList();
        break;
      case 4:
        getProjectList();
        break;
      default:
        break;
      }
    
      scrollToBottom();
    };
    
    onMounted(() => {
      getCategoryListOne();
    });
    </script>
    
    <style lang="scss" scoped>
    .intelligent-guide-page {
      .step-wrapper {
        padding: 10px 114px 20px;
        .step-item {
          color: rgba(#fff, 0.5);
          img {
            width: 18px;
            height: 20px;
            margin: 0 14px;
          }
          &.active {
            color: #fff;
          }
        }
      }
      .page-wrapper {
        min-height: calc(100vh - 235px);
        overflow-y: auto;
        .history-list {
          .time {
            text-align: center;
          }
          .avatar {
            width: 66px;
            height: 66px;
            flex-shrink: 0;
          } 
          .chat-content {
            padding: 18px 15px;
            margin-top: 14px;
            max-width: 536px;
            line-height: 38px;
          }
          .service-chat {
            margin-top: 34px;
            padding-left: 30px;
            img {
              margin-right: 20px;
            }
          }
          .mine-chat {
            padding-right: 30px;
            margin-top: 60px;
            .name {
              text-align: right;
            }
            img {
              margin-left: 20px;
            }
          }
        }
        .search-tag {
          margin-top: 80px;
          .tag-list {
            margin-top: 20px;
            .tag-item {
              min-width: 210px;
              padding: 0 30px;
              height: 60px;
              border-radius: 34px;
              font-size: 28px;
              color: #838B9A;
              border: 2px solid #CBCBCB;
              margin-bottom: 30px;
              margin-right: 19px;
              &.button-hover {
                background: linear-gradient(180deg, #2A83FE 0%, rgba(42,131,254,0.7) 100%);
                color: #fff;
                border: none;
              }
            }
          }
        }
        .project-list {
          .reservation-item {
            padding: 34px;
            background: #fff;
            border-radius: 16px;
            margin-top: 20px;
          }
        }
      }
    }
    </style>
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    上次更新: 2024/03/12, 18:21:59
    每次进入页面都触发的功能(v3)
    js中几个优雅的运算符使用技巧

    ← 每次进入页面都触发的功能(v3) js中几个优雅的运算符使用技巧→

    最近更新
    01
    base64转doc文件
    01-03
    02
    手写签名
    01-03
    03
    base64图片加水印
    01-03
    更多文章>
    Theme by Vdoing | Copyright © 2023-2025 Adinnet
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式