index15.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <view id='app'>
  3. <view class="head" :style="{backgroundColor:styleData.color}">
  4. <text :style="{color:styleData.fontColor}">睿宝AI</text>
  5. <view class="switch">
  6. <switch @change="styleChange(styleData)" />
  7. </view>
  8. </view>
  9. <view class="pageView" :style="{backgroundColor:styleData.color}">
  10. <view class="sidebar-left"></view>
  11. <view class="body">
  12. <view class="list-wrap">
  13. <scroll-view id="content-box" scroll-y="true" class="scrollview" :scroll-top="msgList.scrollTop">
  14. <!-- 聊天主体 -->
  15. <view id="content-overflow">
  16. <view class="scrollview-item" v-for="(item,index) in msgList.chatList" :key='index'>
  17. <!-- user方-聊天内容 -->
  18. <view class="item self" v-if="item.userContent != ''">
  19. <image class="avtar" src="../../static/user-avatar.png" mode="aspectFit"></image>
  20. <view class="content right" disabled :style="{backgroundColor:styleData.contentColor,color:styleData.fontColor}">{{ item.userContent }}</view>
  21. </view>
  22. <!-- ai方-聊天内容 -->
  23. <view class="item other">
  24. <view class="">
  25. <view class="loadingPoint" v-if='msgList.isloading[index]'>
  26. <loadingPointsVue></loadingPointsVue>
  27. </view>
  28. <view class="content left" v-if='!msgList.isloading[index]' :style="{backgroundColor:styleData.contentColor,color:styleData.fontColor}">
  29. {{ msgList.otherChatList[index] }}</view>
  30. </view>
  31. <image class="avtar" src="../../static/Ai-avatar.png" mode="aspectFit"></image>
  32. </view>
  33. </view>
  34. </view>
  35. </scroll-view>
  36. </view>
  37. <view class="chat-bottom">
  38. <view class="uni-label">
  39. <label v-for="(item,index) in labelList" :key="index" @click="shortcuts(msgList,item)" :style="{backgroundColor:styleData.labelColor,color:styleData.fontColor,borderColor:styleData.borderColor}">{{item}}</label>
  40. </view>
  41. <view class="send-msg">
  42. <view class="uni-textarea">
  43. <textarea id="input-textarea" type="text" v-model="msgList.chatMsg" placeholder="快来聊天吧"
  44. confirm-type="send" @confirm="handleSend(msgList)" maxlength="300" />
  45. </view>
  46. <view class="uni-button">
  47. <button class="send-btn" @click="handleSend(msgList)" type="primary" :disabled="msgList.isClick" :style="{backgroundColor:styleData.btnColor}">发送</button>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="sidebar-right">
  53. <image src="../../static/logo.png" mode="aspectFit"></image>
  54. </view>
  55. </view>
  56. </view>
  57. </template>
  58. <script setup>
  59. import {
  60. nextTick,
  61. reactive,
  62. ref,
  63. watch
  64. } from 'vue';
  65. import {
  66. getDataList
  67. } from '../../api/ChatApp.js'
  68. import axios from 'axios';
  69. import loadingPointsVue from '../../components/loadingPoints.vue';
  70. import {styleChange,handleSend,scrollToBottom,shortcuts} from "../../until/fun.js"
  71. const msgList = reactive({
  72. // 输入框
  73. chatMsg: '',
  74. // 聊天数据列表
  75. chatList: [],
  76. // 滚动距离
  77. scrollTop: 0,
  78. // setTimeout的返回值,唯一确定结束对应的setTimeout
  79. timer: 0,
  80. //
  81. textCount: 0,
  82. otherContent: '',
  83. // 处理后的ai数据返回值
  84. otherChatList: [],
  85. // 发送/返回的次数
  86. len: 0,
  87. // 加载符号是否显示
  88. isloading: [],
  89. isClick:false
  90. })
  91. const styleData = reactive({
  92. value:false,
  93. color:'#f5f5f5',
  94. fontColor:"black",
  95. btnColor:"blue",
  96. contentColor:"#fff",
  97. borderColor:"rgb(30,144,255)"
  98. })
  99. const labelList = ref([
  100. "我要加油",
  101. "92号",
  102. "95号",
  103. "98号",
  104. "加油卡",
  105. "易捷加油"
  106. ])
  107. //滚动至聊天底部
  108. watch([msgList.otherChatList,msgList.chatList], (newVal) => {
  109. scrollToBottom(msgList)
  110. })
  111. </script>
  112. <style>
  113. @import url("../../theme/chat15.css");
  114. @import url("../../theme/public.css");
  115. </style>