HomePage.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <template>
  2. <div id="index">
  3. <div class="one">
  4. <a-image :src="head" width="100%" :preview="false" />
  5. </div>
  6. <div class="two">
  7. <div class="left">
  8. <div class="left_1" ref="scrollRef">
  9. <a-spin size="large" :spinning="spinning">
  10. <div class="chat" v-for="(item, index) in list" :key="index" :class="[item.user ? 'message_right' : 'message_left']">
  11. <div class="chat_right" v-if="item.user">
  12. <span>{{ item.content || '暂无内容' }}</span>
  13. </div>
  14. <div class="chat_left" v-else>
  15. <span>{{ item.content || '暂无内容' }}</span>
  16. </div>
  17. </div>
  18. <div class="time">
  19. <p>{{ time }}</p>
  20. </div>
  21. <div class="kf">
  22. <div class="kf_1">
  23. <a-avatar :src="kf" />
  24. </div>
  25. <div class="kf_2">您好,小智正在为您服务</div>
  26. </div>
  27. <div class="chat" v-for="(item, index) in messageList" :key="index" :class="[item.user ? 'message_right' : 'message_left']">
  28. <div class="chat_right" v-if="item.user">
  29. <span>{{ item.content || '暂无内容' }}</span>
  30. </div>
  31. <div class="chat_left" v-else>
  32. <span>{{ item.content || '暂无内容' }}</span>
  33. </div>
  34. </div>
  35. </a-spin>
  36. </div>
  37. <div class="left_2">
  38. <div class="search"></div>
  39. <div class="text">
  40. <a-textarea :bordered="false" v-model:value="text" placeholder="请输入您的问题" allow-clear :auto-size="{ minRows: 4, maxRows: 5 }" />
  41. </div>
  42. <div class="send">
  43. <span>shift+enter换行,enter发送</span>
  44. <a-button type="primary" @click="onSend">发送</a-button>
  45. </div>
  46. </div>
  47. </div>
  48. <div class="right">
  49. <div class="right_1">
  50. <div class="title">
  51. <div class="title_1">常见问题</div>
  52. <div class="title_2" @click="toChange"><SyncOutlined /> <span>换一批</span></div>
  53. </div>
  54. <div class="list">
  55. <div class="list_1" v-for="(item, index) in problemList" :key="index" @click="toSend(item)">
  56. <div class="index">{{ index + 1 }}</div>
  57. <div class="content">{{ item.content || '暂无内容' }}</div>
  58. </div>
  59. </div>
  60. </div>
  61. <div class="right_1">
  62. <div class="title">
  63. <div class="title_1">历史记录</div>
  64. <div class="title_2" @click="toDel"><DeleteOutlined /> <span>清空</span></div>
  65. </div>
  66. <div class="list">
  67. <div class="list_2" v-for="(item, index) in historyList" :key="index" @click="toSend(item)">
  68. <div class="content">{{ item.content || '暂无内容' }}</div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. </template>
  76. <script setup>
  77. import moment from 'moment'
  78. // 图片引入
  79. import head from '/images/head-bg.png'
  80. import kf from '/images/kf.png'
  81. import { DeleteOutlined, SyncOutlined } from '@ant-design/icons-vue'
  82. const user = ref({ id: '1' })
  83. const time = computed(() => moment().format('YYYY-MM-DD HH:mm:ss'))
  84. const text = ref('')
  85. // 最底部
  86. const scrollRef = ref(null)
  87. // 加载中
  88. const spinning = ref(false)
  89. // 聊天记录
  90. const list = ref([
  91. { id: '1', content: '任务书提交不成功,显示暂未开启', time: '2024-09-20 11:13', user: user.value.id },
  92. { id: '2', content: '提供账号(身份证号码+密码)登录,确认项目名称以及是否填写完毕,提交。是二级代理商缓存的问题,最好使用360安全浏览器(极速模式),清理缓存,或使用笔记本电脑连接手机热点,然后等待30分钟左右再操作即可。', time: '2024-09-20 11:13' },
  93. { id: '3', content: '变更单位名称', time: '2024-09-20 11:13', user: user.value.id },
  94. { id: '4', content: '如果没有在研项目或有在研项目已结项,提供工商局变更手续扫描件发送至邮箱 3165837280@qq.com,并将最新营业执照上传至单位账号-信息维护中,可变更。如果有在研项目未结项,请联系咨询相关处室。', time: '2024-09-20 11:13' },
  95. { id: '5', content: '任务书提交后是否能修改?', time: '2024-09-20 11:13', user: user.value.id },
  96. { id: '6', content: '不能修改,只有审核不通过被退回时能修改。只要上方没有【保存】键都不能修改。', time: '2024-09-20 11:13' },
  97. { id: '7', content: '中省直单位的所属科技管理部门是否能选科技厅?', time: '2024-09-20 11:13', user: user.value.id },
  98. { id: '8', content: '如单位账号-单位性质处已显示中直或者省直,可直接选择科技厅(系统默认选择科技厅),中省直单位如单位性质处未选择中直或者省直,需联系系统后台,提供中省直财政预算代码,待确认无误后,可更改单位性质,可选科技厅。', time: '2024-09-20 11:13' }
  99. ])
  100. // 常见问题
  101. const problemList = ref([
  102. { id: '1', content: '任务书提交不成功,显示暂未开启' },
  103. { id: '2', content: '变更单位名称' },
  104. { id: '3', content: '任务书提交后是否能修改?' },
  105. { id: '4', content: '中省直单位的所属科技管理部门是否能选科技厅?' },
  106. { id: '5', content: '项目负责人注册时未找到本单位' },
  107. { id: '6', content: '任务书提交不成功,显示暂未开启' }
  108. ])
  109. // 历史记录
  110. const historyList = ref([
  111. { id: '1', content: '单位注册时名称写错,能修改吗?' },
  112. { id: '2', content: '用户名及密码找回' }
  113. ])
  114. // 实时记录
  115. const messageList = ref([])
  116. // 请求
  117. onMounted(async () => {
  118. spinning.value = true
  119. await search()
  120. spinning.value = false
  121. })
  122. const search = async () => {
  123. let res
  124. messageList.value.push({ content: 'Hi,很高兴为您服务,请问有什么需要帮助?', time: moment().format('YYYY-MM-DD HH:mm:ss') })
  125. await scrollToBottom()
  126. }
  127. // 发送问题
  128. const toSend = async (item) => {
  129. spinning.value = true
  130. const info = { content: item.content, time: moment().format('YYYY-MM-DD HH:mm:ss'), user: user.value.id }
  131. messageList.value.push(info)
  132. await scrollToBottom()
  133. spinning.value = false
  134. }
  135. // 换一批
  136. const toChange = () => {
  137. console.log('换一批')
  138. }
  139. // 清空
  140. const toDel = () => {
  141. console.log('清空')
  142. }
  143. // 发送
  144. const onSend = async () => {
  145. spinning.value = true
  146. const info = { content: text.value, time: moment().format('YYYY-MM-DD HH:mm:ss'), user: user.value.id }
  147. messageList.value.push(info)
  148. await scrollToBottom()
  149. spinning.value = false
  150. }
  151. // 滚动到最底部
  152. const scrollToBottom = () => {
  153. if (scrollRef.value) {
  154. scrollRef.value.scrollTo({ top: scrollRef.value.scrollHeight, behavior: 'smooth' })
  155. }
  156. }
  157. </script>
  158. <style scoped lang="scss">
  159. .one {
  160. width: 100%;
  161. }
  162. .two {
  163. display: flex;
  164. height: 91vh;
  165. width: 100%;
  166. .left {
  167. width: 80%;
  168. height: 100%;
  169. .left_1 {
  170. padding: 16px;
  171. height: 690px;
  172. -webkit-box-sizing: border-box;
  173. box-sizing: border-box;
  174. overflow: auto;
  175. background: url(/images/chat-bg.png) no-repeat bottom right #f6f9fb;
  176. .chat {
  177. .chat_left {
  178. background-color: #fff;
  179. border-radius: 0 15px 15px 15px;
  180. padding: 10px 20px;
  181. font-size: 16px;
  182. max-width: 560px;
  183. }
  184. .chat_right {
  185. max-width: 560px;
  186. background: rgba(0, 119, 255, 0.644);
  187. padding: 10px 20px;
  188. font-size: 16px;
  189. border-radius: 15px 0 15px 15px;
  190. color: #fff;
  191. }
  192. }
  193. .message_left {
  194. display: flex;
  195. justify-content: flex-start;
  196. margin: 10px 0;
  197. }
  198. .message_right {
  199. display: flex;
  200. justify-content: flex-end;
  201. margin: 10px 0;
  202. }
  203. .time {
  204. text-align: center;
  205. padding: 10px;
  206. p {
  207. display: inline-block;
  208. height: 26px;
  209. line-height: 26px;
  210. text-align: center;
  211. background-color: #d9e1e6;
  212. border-radius: 4px;
  213. font-size: 12px;
  214. color: #fff;
  215. padding: 0 12px;
  216. }
  217. }
  218. .kf {
  219. position: relative;
  220. text-align: center;
  221. .kf_1 {
  222. position: absolute;
  223. top: -20%;
  224. left: 49%;
  225. }
  226. .kf_2 {
  227. background: #fff;
  228. border-radius: 10px;
  229. display: inline-block;
  230. padding: 30px 10px 10px;
  231. line-height: 1;
  232. min-width: 200px;
  233. }
  234. }
  235. }
  236. .left_2 {
  237. height: 150px;
  238. background: #fff;
  239. border-top: 1px solid #f6f6f6;
  240. -webkit-box-sizing: border-box;
  241. box-sizing: border-box;
  242. .send {
  243. padding: 10px;
  244. display: flex;
  245. align-items: center;
  246. justify-content: flex-end;
  247. span {
  248. color: #ccc;
  249. margin: 0 10px 0 0;
  250. }
  251. }
  252. }
  253. }
  254. .right {
  255. background-color: #fff;
  256. width: 20%;
  257. height: 100%;
  258. .right_1 {
  259. border-bottom: 1px solid #ddd;
  260. padding: 10px 18px;
  261. .title {
  262. display: flex;
  263. justify-content: space-between;
  264. margin-bottom: 10px;
  265. .title_1 {
  266. font-size: 20px;
  267. color: #333;
  268. }
  269. .title_2 {
  270. cursor: pointer;
  271. font-size: 14px;
  272. color: #999;
  273. }
  274. }
  275. .list {
  276. max-height: 530px;
  277. overflow: auto;
  278. .list_1 {
  279. display: flex;
  280. align-items: center;
  281. cursor: pointer;
  282. margin-bottom: 10px;
  283. .index {
  284. width: 20px;
  285. height: 20px;
  286. line-height: 20px;
  287. background-color: #bad7fc;
  288. text-align: center;
  289. color: #fff;
  290. }
  291. .content {
  292. font-size: 14px;
  293. color: #666;
  294. margin-left: 12px;
  295. width: 100%;
  296. overflow: hidden;
  297. text-overflow: ellipsis;
  298. white-space: nowrap;
  299. }
  300. }
  301. .list_2 {
  302. display: flex;
  303. flex-flow: wrap;
  304. .content {
  305. padding: 6px 10px;
  306. background-color: #f5f7fa;
  307. text-align: center;
  308. border-radius: 18px;
  309. font-size: 14px;
  310. color: #676767;
  311. margin-right: 6px;
  312. margin-bottom: 6px;
  313. cursor: pointer;
  314. }
  315. }
  316. }
  317. }
  318. .right_1:last-child {
  319. border-bottom: none;
  320. }
  321. }
  322. }
  323. @media screen and (max-width: 1280px) {
  324. #index {
  325. min-width: 1920px;
  326. margin: 0 auto;
  327. }
  328. }
  329. @media screen and (min-width: 1921px) {
  330. #index {
  331. max-width: 1920px;
  332. margin: 0 auto;
  333. }
  334. }
  335. /* 自定义整个滚动条 */
  336. ::-webkit-scrollbar {
  337. width: 5px; /* 滚动条宽度 */
  338. }
  339. /* 自定义滚动条的滑块(thumb) */
  340. ::-webkit-scrollbar-thumb {
  341. background: #cfd6dd; /* 滑块颜色 */
  342. }
  343. /* 当hover或active状态时,自定义滑块的颜色 */
  344. ::-webkit-scrollbar-thumb:hover {
  345. background: #cfd6dd;
  346. }
  347. </style>