AI数字人小屏带背景
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

492 lines
21 KiB

3 months ago
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
  8. <meta http-equiv="Pragma" content="no-cache" />
  9. <meta http-equiv="Expires" content="0" />
  10. <link rel="stylesheet" type="text/css" href="css/libs/reset.css" />
  11. <link rel="stylesheet" type="text/css" href="css/libs/animate.min.css" />
  12. <link rel="stylesheet" type="text/css" href="css/plugins/swiper-bundle.min.css" />
  13. <link rel="stylesheet" type="text/css" href="css/index.css" />
  14. <!--[if lt IE 9]>
  15. <script src="js/html5shiv.js"></script>
  16. <script src="js/respond.min.js"></script>
  17. <![endif]-->
  18. <title>AI数字人</title>
  19. </head>
  20. <body>
  21. <div class="ai-wrapper">
  22. <video class="ai-bg" src="images/bg.mp4" autoplay="autoplay" loop="loop" muted="muted"></video>
  23. <!-- <iframe style="position: absolute; top: 0; left: 0; border: none; z-index: 9;" width="100%" height="100%" src="https://f.3dman.cn/art/9fM6sgHv/avatars/GPBrJQBD/index.html"></iframe> -->
  24. <!-- <iframe style="position: absolute; top: 0; left: 0; border: none; z-index: 9;" width="100%" height="100%" src="https://f.3dman.cn/art/sDpbYwwJ/fbx/CdYqVH95/index.html"></iframe> -->
  25. <div class="page-content">
  26. <!-- 菜单 -->
  27. <ul class="ai-nav">
  28. <li class="nav-home"><p><span>主页</span></p></li>
  29. <!-- nav-talk -->
  30. <!-- talk-ing -->
  31. <!-- talk-end -->
  32. <li class="nav-talk"><p><span>提问</span></p></li>
  33. <li class="nav-help"><p><span>帮助</span></p></li>
  34. </ul>
  35. <!-- animate__swing / animate__tada / animate__wobble-->
  36. <!-- animate__rollIn / animate__bounceInDown -->
  37. <!-- animate__animated animate__tada -->
  38. <div class="ai-tip">喊一声“晓菲晓菲”,可以跟我对话</div>
  39. <div class="chat-container">
  40. <!-- <div class="chat-message user-message animate__animated animate__fadeInUp">
  41. <div class="message-content">
  42. <img src="images/1080_4.png" alt="" class="message-avatar" />
  43. <span class="message-text">你好!</span>
  44. </div>
  45. </div>
  46. <div class="chat-message ai-message animate__animated animate__flipInY">
  47. <div class="message-content">
  48. <img src="images/1080_5.png" alt="" class="message-avatar" />
  49. <span class="message-text" id="botReplyText">你好!请问有需要帮助的吗?</span>
  50. </div>
  51. </div> -->
  52. </div>
  53. <div class="other-content">
  54. <!-- animate__backInDown / animate__backInUp / animate__bounceIn / animate__bounceInDown /animate__bounceInUp -->
  55. <!-- 图书列表 -->
  56. <div class="book-box">
  57. <div class="layer-content layer-book-box animate__animated animate__bounceInUp">
  58. <div class="layer-header">
  59. <h3>图书列表</h3>
  60. <div class="layer-closed layer-index-closed"></div>
  61. </div>
  62. <div class="swiper mySwiper">
  63. <div class="swiper-wrapper">
  64. </div>
  65. <div class="book-last">
  66. <div class="book-result"></div>
  67. <div class="swiper-button-prev"></div>
  68. <div class="swiper-pagination"></div>
  69. <div class="swiper-button-next"></div>
  70. </div>
  71. </div>
  72. </div>
  73. <!-- 导航地址页 -->
  74. <div class="layer-content layer-place-box animate__animated animate__bounceInUp">
  75. <div class="layer-header">
  76. <h3>导航</h3>
  77. <div class="layer-closed layer-place-closed"></div>
  78. </div>
  79. <div class="map-content">
  80. </div>
  81. </div>
  82. </div>
  83. <!-- 导航地址页 -->
  84. <div class="layer-content layer-place2-box animate__animated animate__bounceInUp">
  85. <div class="layer-header">
  86. <h3>导航</h3>
  87. <div class="layer-closed layer-place-closed"></div>
  88. </div>
  89. <div class="map-content2">
  90. </div>
  91. </div>
  92. <!-- 视频播放 -->
  93. <div class="layer-content layer-video-box animate__animated animate__bounceInUp">
  94. <div class="layer-header">
  95. <h3>视频标题</h3>
  96. <div class="layer-closed layer-index-closed"></div>
  97. </div>
  98. <div class="video-box">
  99. <!-- <video width="100%" height="100%" controls autoplay muted>
  100. <source src="video/入门级开源机械臂ultraArm套装.mp4" type="video/mp4">
  101. </video> -->
  102. </div>
  103. </div>
  104. </div>
  105. <!-- 帮助 -->
  106. <div class="layer-help-box animate__animated animate__fadeInLeft">
  107. <div class="layer-closed layer-help-closed"></div>
  108. <h4>HI,您好!<br/>
  109. 我是您的AI助手晓菲!</h4>
  110. <p class="help-top-text">我可以为您提供图书查询、导航定位、参考咨询、智能推荐等服务。让我们一起在知识的海洋中航行,发现新大陆!有什么问题想要探讨吗?</p>
  111. <ul class="help-tip">
  112. <li class="animate__animated animate__bounceInUp">
  113. <span>图书查询</span>
  114. <p>"请帮我查一下《斗罗大陆》这本书"</p>
  115. </li>
  116. <li class="animate__animated animate__bounceInUp">
  117. <span>图书推荐</span>
  118. <p>"帮我推荐一下近期热门书籍"</p>
  119. </li>
  120. <li class="animate__animated animate__bounceInUp">
  121. <span>知识百科</span>
  122. <p>"请问《红楼梦》里王熙凤和贾宝玉是什么关系?"</p>
  123. </li>
  124. <li class="animate__animated animate__bounceInUp">
  125. <span>大模型</span>
  126. <p>"请帮我写一篇关于“日落”的300字文章"</p>
  127. </li>
  128. <li class="animate__animated animate__bounceInUp">
  129. <span>导航定位</span>
  130. <p>"请问少儿借阅室怎么走"</p>
  131. </li>
  132. </ul>
  133. </div>
  134. </div>
  135. </div>
  136. </body>
  137. <script type="text/javascript" src="js/libs/jquery-3.7.1.min.js"></script>
  138. <script type="text/javascript" src="js/libs/flexible.js"></script>
  139. <!-- 弹出框 -->
  140. <script type="text/javascript" src="js/plugins/swiper-bundle.min.js"></script>
  141. <script type="text/javascript" src="config.js"></script>
  142. <script type="text/javascript" src="data.js"></script>
  143. <script>
  144. var dataJson = data
  145. var shouldStopTyping = false; // 停止打字标识
  146. var helpTimer; // 帮助的自动消失定时器
  147. var intervalText; // 打字定时器
  148. var swiper;
  149. function helpShowHide() {
  150. clearTimeout(helpTimer);
  151. $('.chat-message').remove();
  152. $('.layer-content').hide();
  153. if ($('.layer-help-box').is(':visible')) {
  154. // 如果帮助框是可见的,则隐藏它
  155. $('.layer-help-box').hide();
  156. } else {
  157. // 如果帮助框是隐藏的,则显示它,并设置定时器
  158. $('.layer-help-box').show();
  159. helpTimer = setTimeout(() => {
  160. $('.layer-help-box').hide();
  161. }, 7000); // 7秒后隐藏帮助框
  162. }
  163. }
  164. // animate__swing / animate__tada / animate__wobble
  165. // animate__rollIn / animate__bounceInDown
  166. $(function(){
  167. // 顶部提示语动画
  168. setInterval(function() {
  169. $('.ai-tip').css('animation-duration', '1s').addClass('animate__animated animate__tada');
  170. setTimeout(function() {
  171. $('.ai-tip').removeClass('animate__animated animate__tada');
  172. }, 1000);
  173. }, 5000);
  174. // 禁用右键菜单
  175. document.addEventListener('contextmenu', function(event) {
  176. event.preventDefault();
  177. });
  178. // 帮助按钮点击事件
  179. $('.nav-help').on('click', function() {
  180. helpShowHide();
  181. });
  182. // 帮助的关闭按钮click
  183. $(".layer-help-closed").on("click",function(){
  184. clearTimeout(helpTimer); // 清除之前的定时器
  185. $('.layer-help-box').hide()
  186. })
  187. // 图书列表 / 视频弹框的关闭按钮
  188. $(".layer-index-closed").on("click",function(){
  189. // 销毁 Swiper 实例
  190. if (swiper) {
  191. swiper.destroy();
  192. }
  193. $('.layer-content').hide()
  194. $('.swiper-wrapper').html('')
  195. })
  196. // 新地址弹框
  197. $('.layer-place2-box .layer-place-closed').on("click",function(){
  198. $('.map-content2').html('');
  199. $('.layer-place2-box').hide();
  200. })
  201. })
  202. // 图书列表
  203. // getBookList(dataJson)
  204. // getBookList([{"BookName":"陈氏太极拳图说:简体版","Author":"陈鑫","Isbn":"7537727279","Publish":null,"Sortmark":"G852.111.9-64/1","BookCover":"aba3eec6723f4cef8d2ae0661946862e","SrcUrl":"http://static1.showapi.com/app2/isbn/unk/8587da2ac70e4a41a4ce3a30cd5c1035.jpg","Books":[{"Barcode":"4201120100108481","PlaceName":null}]},{"BookName":"孟子译注:简体字本","Author":"杨伯峻译注","Isbn":"9787101063585","Publish":null,"Sortmark":"B222.52/1","BookCover":"85ebce648e24408db5095528e6534356","SrcUrl":"http://static1.showapi.com/app2/isbn/101/b16902a8ad4646ed8296f51a6c2c3483.jpg","Books":[{"Barcode":"4201120100237455","PlaceName":"三楼图书借阅区001排A面06架05层"}]},{"BookName":"章太炎家书:手稿与简体字对照版","Author":"章太炎等","Isbn":"9787512673069","Publish":null,"Sortmark":"B259.25/6","BookCover":"dd5948c5f9454e959b25220b86d57c7c","SrcUrl":"https://book-resource.dataesb.com/cover/p/20210730/eae5b39e98f14d388c8e18e5276b9451.jpeg","Books":[{"Barcode":"4201120100417226","PlaceName":"三楼图书借阅区001排A面07架04层"},{"Barcode":"4201120100417225","PlaceName":null}]},{"BookName":"论语译注:简体字本","Author":"杨伯峻译注","Isbn":"7101054196","Publish":null,"Sortmark":"B222.22/5","BookCover":"732e35c6e0914443b6c375456eb1e3b5","SrcUrl":"https://book-resource.dataesb.com/cover/p/20200516/775ed0e2d7a14163bbf872dd47f4d31b.jpeg","Books":[{"Barcode":"4201120100237456","PlaceName":"三楼图书借阅区001排A面05架07层"}]}])
  205. function handleImageError(imgElement) {
  206. imgElement.src = 'images/dxh/default-img.png';
  207. if (!imgElement.classList.contains('dxh-class')) {
  208. imgElement.classList.add('dxh-class');
  209. }
  210. imgElement.onerror = null;
  211. }
  212. function getBookList(dataBook){
  213. var swiperHtml = '';
  214. var processedBooks = 0;
  215. var promises = [];
  216. for (let i = 0; i < dataBook.length; i++) {
  217. let book = dataBook[i];
  218. let places = book.books || book.Books || [];
  219. let placesHtml = places.map(function(place) {
  220. let noDataClass = ( place.placeName === null || place.PlaceName === null) ? 'no-data' : '';
  221. return '<a class="' + noDataClass + '" href="javascript:;" data-id="'+ (place.barcode || place.Barcode) +'">' + ( ( place.placeName || place.PlaceName ) || '暂无架位信息') + '</a>';
  222. }).join('');
  223. (function(book) {
  224. promises.push($.ajax({
  225. url: config.apiUrl+'/dxhtsg/getCoverByISBN',
  226. type: 'GET',
  227. data: {
  228. 'isbn': book.isbn || book.Isbn
  229. },
  230. success: function(res) {
  231. console.log('res',res)
  232. if (res) {
  233. book.cover = res;
  234. }
  235. swiperHtml += createBookHtml(book, placesHtml);
  236. processedBooks++;
  237. },
  238. error: function(err) {
  239. console.error(err);
  240. }
  241. }));
  242. })(book);
  243. }
  244. Promise.all(promises).then(function() {
  245. $('.book-result').html('共有 ' + dataBook.length + ' 册图书符合您的检索结果');
  246. $('.swiper-wrapper').html(swiperHtml);
  247. $('.layer-book-box').show();
  248. // list轮播切换
  249. swiper = new Swiper(".mySwiper", {
  250. spaceBetween: 30,
  251. centeredSlides: true,
  252. autoHeight: true,
  253. autoplay: {
  254. delay: 6000,
  255. disableOnInteraction: false,
  256. },
  257. pagination: {
  258. el: ".swiper-pagination",
  259. type: "fraction",
  260. },
  261. navigation: {
  262. nextEl: ".swiper-button-next",
  263. prevEl: ".swiper-button-prev",
  264. },
  265. on: {
  266. init: function () {
  267. // 轮播初始化后立即请求第一个图书的gist
  268. requestBookGist(this.slides[0].dataset.isbn);
  269. },
  270. touchStart: function(swiper,event){
  271. swiper.autoplay.stop();
  272. },
  273. touchEnd: function(swiper,event){
  274. swiper.autoplay.start();
  275. },
  276. slideChangeTransitionStart: function () {
  277. let currentBook = this.slides[this.activeIndex].dataset.isbn
  278. requestBookGist(currentBook);
  279. }
  280. }
  281. });
  282. // 图书导航列表点击
  283. // http://58.49.77.70:8443/anchoring/goNavigation.do?libcode=1201&barcode=4201120100440912
  284. $('.place-book a').on("click",function(){
  285. var _thisBarcode = $(this).attr('data-id');
  286. var _thisNoData = $(this).hasClass('no-data')
  287. if(!_thisNoData){
  288. // 点击时停止轮播
  289. swiper.autoplay.stop();
  290. $('.map-content').html('<iframe style="border: none;" width="100%" height="100%" src="'+config.apiUrl+'/anchoring/goNavigation.do?libcode='+config.libcode+'&barcode='+_thisBarcode+'"></iframe>');
  291. $('.layer-place-box').show();
  292. }
  293. })
  294. // 图书导航关闭按钮
  295. $('.layer-place-closed').on("click",function(){
  296. $('.map-content').html('');
  297. $('.layer-place-box').hide();
  298. // 弹框关闭后恢复轮播
  299. swiper.autoplay.start();
  300. })
  301. }).catch(function(error) {
  302. console.error(error);
  303. });
  304. function createBookHtml(book, placesHtml) {
  305. var imgClass = book.cover.includes('dxh') ? 'dxh-class' : '';
  306. return '<div class="swiper-slide" data-isbn='+ (book.isbn || book.Isbn) +'>' +
  307. '<div class="book-wrapper">' +
  308. '<div class="book-info">' +
  309. '<div class="info-img">' +
  310. '<img src="' + book.cover + '" alt="" class="' + imgClass + '" onerror="handleImageError(this);" />' +
  311. '</div>' +
  312. '<div class="info-text">' +
  313. '<p>' + ( book.bookName || book.BookName ) + '</p>' +
  314. '<p><i>著者:</i><span>' + (book.author || book.Author || '-') + '</span></p>' +
  315. '<p><i>出版社:</i><span>' + (book.publish || book.Publish || '-') + '</span></p>' +
  316. '<p><i>ISBN:</i><span>' + (book.isbn || book.Isbn || '-') + '</span></p>' +
  317. '<p class="gist-content"><span>' + (book.gist || book.Gist || '-') + '</span></p>' +
  318. '</div>' +
  319. '</div>' +
  320. '<div class="place-book">' + placesHtml + '</div>' +
  321. '</div>' +
  322. '</div>';
  323. }
  324. // http://58.49.77.70:8443/dxhtsg/LibraryBookByBarcode 通过barcode获取一本图书 {"barcode":"4201000201648913"}
  325. // http://58.49.77.70:8443/dxhtsg/LibraryBookByISBN 通过isbn获取第一本有简介的图书 {"isbn":"4201000201648913"}
  326. // http://58.49.77.70:8443/dxhtsg/LibraryBookByISBNTop1 通过isbn获取图书集合 {"isbn":"4201000201648913"}
  327. // http://58.49.77.70:19000/LibraryBookByBarcode
  328. function requestBookGist(isbn) {
  329. if (isbn) {
  330. $.ajax({
  331. url: config.apiUrl + '/dxhtsg/LibraryBookByISBN',
  332. type: 'POST',
  333. contentType:'application/json',
  334. dataType: "json",
  335. data: JSON.stringify({
  336. 'isbn': isbn
  337. }),
  338. success: function(res) {
  339. console.log(res)
  340. if(res.length !== 0){
  341. updateGist(res[0].gist);
  342. }else{
  343. updateGist('');
  344. }
  345. },
  346. error: function(err) {
  347. console.error(err);
  348. }
  349. });
  350. }
  351. }
  352. function updateGist(gist) {
  353. $('.gist-content span').text('')
  354. $('.gist-content span').text(gist);
  355. }
  356. }
  357. // newPlace('http://58.49.77.70:8443/anchoring/goNavigation.do?libcode=1201&barcode=4201120100331343')
  358. function newPlace(url){
  359. $('.map-content2').html('<iframe style="border: none;" width="100%" height="100%" src="'+url+'"></iframe>');
  360. $('.layer-place2-box').show();
  361. }
  362. // 获取视频播放
  363. function getVideo(title,videoSrc){
  364. $('.layer-video-box').show();
  365. $('.layer-video-box').find('h3').html(title);
  366. var html = '<video width="100%" height="100%" controls autoplay muted>'+
  367. '<source src="'+videoSrc+'" type="video/mp4">'+
  368. '</video>';
  369. $('.video-box').html(html);
  370. }
  371. // $(document).on('click', '.nav-talk', function() {
  372. // talkDefalutToIng()
  373. // setTimeout(()=>{
  374. // // 检测发送用户提问内容
  375. // userQuestion('测试一下')
  376. // // 模拟机器人的回答
  377. // setTimeout(function() {
  378. // talkIngToEnd()
  379. // var message = "所替代,万物复苏,生命在这个季节里得到了更新。在田野上,农民们忙碌地耕种,希望在秋天收获满满的果实。而在城市中,人们带着期待和希望迎接新的一年。孩子们在公园里欢笑玩耍,他们的笑声如同春天的风,温暖而清新。河边的柳树开始发芽,嫩绿的叶子在阳光下闪闪发光。花朵在春风的吹拂下慢慢绽放,她们像是一群群舞者,在舞台上展示着各自的美丽。春天是一首优美的诗,是一幅生动的画。它带给我们的不仅仅是美景,更是对生活的热爱和对未来的期待。让我们珍惜这个美丽的季节,感受大自然的魅力,享受生活的美好。"
  380. // digiPeopleReply(message)
  381. // getBookList(dataJson)
  382. // }, 4000);
  383. // $('.layer-help-box').hide();
  384. // $('.layer-content').hide()
  385. // },4000)
  386. // })
  387. // $(document).on('click', '.talk-end', function() {
  388. // talkEndToDefalut()
  389. // })
  390. // 提问 - 录音
  391. function talkDefalutToIng(){
  392. $('.nav-talk').html('<p><span>录音</span></p>').removeClass().addClass('talk-ing');
  393. $('.layer-help-box').hide();
  394. }
  395. // 录音 - 打断
  396. function talkIngToEnd(){
  397. $('.talk-ing').html('<p><span>打断</span></p>').removeClass().addClass('talk-end');
  398. }
  399. // 打断 - 提问
  400. function talkEndToDefalut(){
  401. $('.talk-end').html('<p><span>提问</span></p>').removeClass().addClass('nav-talk');
  402. shouldStopTyping = true; // 设置变量,指示应该停止打字
  403. clearInterval(intervalText); // 清除定时器
  404. }
  405. // 用户提问
  406. function userQuestion(message){
  407. if (swiper) {
  408. swiper.destroy();
  409. }
  410. $('.layer-help-box').hide();
  411. $('.layer-content').hide();
  412. $('.swiper-wrapper').html('')
  413. var $userMessageBox = $('<div class="chat-message user-message animate__animated animate__fadeInUp"></div>');
  414. $userMessageBox.html(
  415. '<div class="message-content">' +
  416. '<img src="images/1080_4.png" alt="" class="message-avatar" />' +
  417. '<span class="message-text">' + message + '</span>' +
  418. '</div>'
  419. );
  420. // 将用户的消息添加到聊天容器的最顶部
  421. $('.chat-container').prepend($userMessageBox);
  422. // 清空旧的消息,只保留最新的一条问答
  423. $('.chat-container').children('.chat-message').slice(1).remove();
  424. setTimeout(()=>{
  425. var $userMessageBox = $('.chat-container').children('.chat-message.user-message').last();
  426. var $botMessageBox = $('<div class="chat-message ai-message animate__animated animate__fadeInUp"></div>');
  427. $botMessageBox.html(
  428. '<div class="message-content">' +
  429. '<img src="images/1080_5.png" alt="" class="message-avatar" />' +
  430. '<span class="message-text" id="botReplyText"><img class="loading" src="images/loading.webp" alt="" /></span>' +
  431. '</div>'
  432. );
  433. $userMessageBox.after($botMessageBox);
  434. },1000)
  435. }
  436. // 数字人回答
  437. function digiPeopleReply(message) {
  438. shouldStopTyping = false;
  439. setTimeout(function() {
  440. // 隐藏loading
  441. $('.ai-message').find('.loading').hide();
  442. // 数字人回复逐字敲打出来
  443. var index = 0;
  444. intervalText = setInterval(function() {
  445. if (!shouldStopTyping && index < message.length) {
  446. $('#botReplyText').text(message.substring(0, index + 1));
  447. index++;
  448. $('#botReplyText').scrollTop($('#botReplyText')[0].scrollHeight);
  449. } else if (shouldStopTyping) {
  450. clearInterval(intervalText); // 停止打字动画
  451. }
  452. }, 100); // 100 打字速度,越小越快
  453. }, 1000);
  454. }
  455. </script>
  456. </html>