index32.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <view id='app' style="bottom: {{KeyBoardHeight}}px;">
  3. <view class="placeholder" :style="`height: ${styleData.screenWidth}vh`"></view>
  4. <view class="head" :style="{backgroundColor:styleData.color}">
  5. <text :style="{color:styleData.fontColor}">睿宝AI</text>
  6. <view class="switch">
  7. <switch @change="styleChange(styleData)" />
  8. <switch class='second' @change="screenChange()" />
  9. </view>
  10. </view>
  11. <view class="pageView" :style="{backgroundColor:styleData.color}">
  12. <view class="sidebar-left"></view>
  13. <view class="body" :style="`height:${95-styleData.screenWidth}vh`">
  14. <view class="list-wrap">
  15. <scroll-view id="content-box" scroll-y="true" class="scrollview" :scroll-top="msgList.scrollTop">
  16. <!-- 聊天主体 -->
  17. <view id="content-overflow">
  18. <view class="scrollview-item" v-for="(item,index) in msgList.chatList" :key='index'>
  19. <!-- user方-聊天内容 -->
  20. <view class="item self" v-if="item.userContent != ''">
  21. <image class="avtar" src="../../static/user-avatar.png" mode="aspectFit"></image>
  22. <view class="content right" disabled
  23. :style="{backgroundColor:styleData.contentColor,color:styleData.fontColor}">
  24. {{ item.userContent }}</view>
  25. </view>
  26. <!-- ai方-聊天内容 -->
  27. <view class="item other">
  28. <view class="">
  29. <view class="loadingPoint" v-if='msgList.isloading[index]'>
  30. <loadingPointsVue></loadingPointsVue>
  31. </view>
  32. <view class="content left" v-if='!msgList.isloading[index]'
  33. :style="{backgroundColor:styleData.contentColor,color:styleData.fontColor}">
  34. {{ msgList.otherChatList[index] }}
  35. </view>
  36. </view>
  37. <image class="avtar" src="../../static/Ai-avatar.png" mode="aspectFit"></image>
  38. </view>
  39. </view>
  40. </view>
  41. </scroll-view>
  42. </view>
  43. <view class="chat-bottom">
  44. <view class="uni-label">
  45. <label v-for="(item,index) in labelList" :key="index" @click="shortcuts(msgList,item)"
  46. :style="{backgroundColor:styleData.labelColor,color:styleData.fontColor,borderColor:styleData.borderColor}">{{item}}</label>
  47. </view>
  48. <view class="send-msg">
  49. <view class="uni-textarea">
  50. <!-- bindkeyboardheightchange='getKeyBoardHeight' - 添加键盘弹起触发属性 -->
  51. <textarea id="input-textarea" type="text" v-model="msgList.chatMsg" placeholder="快来聊天吧"
  52. confirm-type="send" @confirm="handleSend(msgList)" maxlength="300" />
  53. </view>
  54. <view class="uni-button">
  55. <button class="send-btn" @click="handleSend(msgList)" type="primary"
  56. :disabled="msgList.isClick" :style="{backgroundColor:styleData.btnColor}">发送</button>
  57. </view>
  58. </view>
  59. </view>s
  60. </view>
  61. <view class="sidebar-right" :style="`height:${95-styleData.screenWidth}vh`">
  62. <image src="../../static/logo.png" mode="aspectFit" :style="`top:${70-styleData.screenWidth}vh`"></image>
  63. </view>
  64. </view>
  65. </view>
  66. </template>
  67. <script setup>
  68. import {
  69. nextTick,
  70. reactive,
  71. ref,
  72. watch
  73. } from 'vue';
  74. import {
  75. getDataList
  76. } from '../../api/ChatApp.js'
  77. import axios from 'axios';
  78. import loadingPointsVue from '../../components/loadingPoints.vue';
  79. import {
  80. styleChange,
  81. handleSend,
  82. scrollToBottom,
  83. shortcuts
  84. } from "../../until/fun.js"
  85. const msgList = reactive({
  86. // 输入框
  87. chatMsg: '',
  88. // 聊天数据列表
  89. chatList: [],
  90. // 滚动距离
  91. scrollTop: 0,
  92. //
  93. timer: '',
  94. textCount: '',
  95. otherContent: '',
  96. otherChatList: [],
  97. len: 0,
  98. isloading: [],
  99. isClick: false,
  100. // 键盘弹起高度
  101. KeyBoardHeight: 0
  102. })
  103. const styleData = reactive({
  104. value: false,
  105. color: '#f5f5f5',
  106. fontColor: "black",
  107. btnColor: "rgb(30,144,255)",
  108. contentColor: "#fff",
  109. labelColor: "#fff",
  110. borderColor: "rgb(30,144,255)",
  111. screenWidth:40,
  112. isScreen:false,
  113. })
  114. const labelList = ref([
  115. "我要加油",
  116. "92号",
  117. "95号",
  118. "98号",
  119. "加油卡",
  120. "易捷加油"
  121. ])
  122. //滚动至聊天底部
  123. watch([msgList.otherChatList, msgList.chatList], (newVal) => {
  124. scrollToBottom(msgList)
  125. })
  126. // 屏幕 去除上屏
  127. const screenChange = ()=>{
  128. styleData.isScreen = !styleData.isScreen
  129. if(styleData.isScreen == true){
  130. styleData.screenWidth = 0
  131. }else{
  132. styleData.screenWidth = 40
  133. }
  134. }
  135. // 键盘弹起事件 --- 真机调试时,测试之后再看能不能这样用
  136. //
  137. // const getKeyBoardHeight = ((event)=>{
  138. // // 获取键盘弹起的高度
  139. // msgList.KeyBoardHeight = event.detail.height
  140. // console.log(msgList.KeyBoardHeight)
  141. // })
  142. </script>
  143. <style>
  144. @import url("../../theme/chat32.css");
  145. @import url("../../theme/public.css");
  146. .second {
  147. padding-left: 50rpx;
  148. }
  149. </style>