index15.vue 3.7 KB

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