Brak opisu

chats.html 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  6. <title></title>
  7. <link href="../css/mui.min.css" rel="stylesheet" />
  8. <link rel="stylesheet" type="text/css" href="../css/app.css" />
  9. <link href="../css/mui.imageviewer.css" rel="stylesheet" />
  10. <style>
  11. html,
  12. body {
  13. height: 100%;
  14. margin: 0px;
  15. padding: 0px;
  16. overflow: hidden;
  17. -webkit-touch-callout: none;
  18. -webkit-user-select: none;
  19. }
  20. footer {
  21. position: fixed;
  22. width: 100%;
  23. height: 50px;
  24. min-height: 50px;
  25. border-top: solid 1px #bbb;
  26. left: 0px;
  27. bottom: 0px;
  28. overflow: hidden;
  29. padding: 0px 50px;
  30. background-color: #fafafa;
  31. }
  32. .footer-left {
  33. position: absolute;
  34. width: 50px;
  35. height: 50px;
  36. left: 0px;
  37. bottom: 0px;
  38. text-align: center;
  39. vertical-align: middle;
  40. line-height: 100%;
  41. padding: 12px 4px;
  42. }
  43. .footer-right {
  44. position: absolute;
  45. width: 50px;
  46. height: 50px;
  47. right: 0px;
  48. bottom: 0px;
  49. text-align: center;
  50. vertical-align: middle;
  51. line-height: 100%;
  52. padding: 12px 5px;
  53. display: inline-block;
  54. }
  55. .footer-center {
  56. height: 100%;
  57. padding: 5px 0px;
  58. }
  59. .footer-center [class*=input] {
  60. width: 100%;
  61. height: 100%;
  62. border-radius: 5px;
  63. }
  64. .footer-center .input-text {
  65. background: #fff;
  66. border: solid 1px #ddd;
  67. padding: 10px !important;
  68. font-size: 16px !important;
  69. line-height: 18px !important;
  70. font-family: verdana !important;
  71. overflow: hidden;
  72. }
  73. .footer-center .input-sound {
  74. background-color: #eee;
  75. }
  76. .mui-content {
  77. height: 100%;
  78. padding: 44px 0px 50px 0px;
  79. overflow: auto;
  80. background-color: #eaeaea;
  81. }
  82. #msg-list {
  83. height: 100%;
  84. overflow: auto;
  85. -webkit-overflow-scrolling: touch;
  86. }
  87. .msg-item {
  88. padding: 8px;
  89. clear: both;
  90. }
  91. .msg-item .mui-item-clear {
  92. clear: both;
  93. }
  94. .msg-item .msg-user {
  95. width: 38px;
  96. height: 38px;
  97. border: solid 1px #d3d3d3;
  98. display: inline-block;
  99. background: #fff;
  100. border-radius: 3px;
  101. vertical-align: top;
  102. text-align: center;
  103. float: left;
  104. padding: 3px;
  105. color: #ddd;
  106. }
  107. .msg-item .msg-user-img{
  108. width: 38px;
  109. height: 38px;
  110. display: inline-block;
  111. border-radius: 3px;
  112. vertical-align: top;
  113. text-align: center;
  114. float: left;
  115. color: #ddd;
  116. }
  117. .msg-item .msg-content {
  118. display: inline-block;
  119. border-radius: 5px;
  120. border: solid 1px #d3d3d3;
  121. background-color: #FFFFFF;
  122. color: #333;
  123. padding: 8px;
  124. vertical-align: top;
  125. font-size: 15px;
  126. position: relative;
  127. margin: 0px 8px;
  128. max-width: 75%;
  129. min-width: 35px;
  130. float: left;
  131. }
  132. .msg-item .msg-content .msg-content-inner {
  133. overflow-x: hidden;
  134. }
  135. .msg-item .msg-content .msg-content-arrow {
  136. position: absolute;
  137. border: solid 1px #d3d3d3;
  138. border-right: none;
  139. border-top: none;
  140. background-color: #FFFFFF;
  141. width: 10px;
  142. height: 10px;
  143. left: -5px;
  144. top: 12px;
  145. -webkit-transform: rotateZ(45deg);
  146. transform: rotateZ(45deg);
  147. }
  148. .msg-item-self .msg-user,
  149. .msg-item-self .msg-content {
  150. float: right;
  151. }
  152. .msg-item-self .msg-content .msg-content-arrow {
  153. left: auto;
  154. right: -5px;
  155. -webkit-transform: rotateZ(225deg);
  156. transform: rotateZ(225deg);
  157. }
  158. .msg-item-self .msg-content,
  159. .msg-item-self .msg-content .msg-content-arrow {
  160. background-color: #4CD964;
  161. color: #fff;
  162. border-color: #2AC845;
  163. }
  164. footer .mui-icon {
  165. color: #999999;
  166. }
  167. footer .mui-icon:active {
  168. color: #FF9900 !important;
  169. }/*#007AFF*/
  170. footer .mui-icon-paperplane:before {
  171. content: "发送";
  172. }
  173. footer .mui-icon-paperplane {
  174. /*-webkit-transform: rotateZ(45deg);
  175. transform: rotateZ(45deg);*/
  176. font-size: 16px;
  177. word-break: keep-all;
  178. line-height: 100%;
  179. padding-top: 6px;
  180. color: rgba(0, 135, 250, 1);
  181. }
  182. #msg-sound {
  183. -webkit-user-select: none !important;
  184. user-select: none !important;
  185. }
  186. .rprogress {
  187. position: absolute;
  188. left: 50%;
  189. top: 50%;
  190. width: 140px;
  191. height: 140px;
  192. margin-left: -70px;
  193. margin-top: -70px;
  194. background-image: url(../images/arecord.png);
  195. background-repeat: no-repeat;
  196. background-position: center center;
  197. background-size: 30px 30px;
  198. background-color: rgba(0, 0, 0, 0.7);
  199. border-radius: 5px;
  200. display: none;
  201. -webkit-transition: .15s;
  202. }
  203. .rschedule {
  204. background-color: rgba(0, 0, 0, 0);
  205. border: 5px solid rgba(0, 183, 229, 0.9);
  206. opacity: .9;
  207. border-left: 5px solid rgba(0, 0, 0, 0);
  208. border-right: 5px solid rgba(0, 0, 0, 0);
  209. border-radius: 50px;
  210. box-shadow: 0 0 15px #2187e7;
  211. width: 46px;
  212. height: 46px;
  213. position: absolute;
  214. left: 50%;
  215. top: 50%;
  216. margin-left: -23px;
  217. margin-top: -23px;
  218. -webkit-animation: spin 1s infinite linear;
  219. animation: spin 1s infinite linear;
  220. }
  221. .r-sigh{
  222. display: none;
  223. border-radius: 50px;
  224. box-shadow: 0 0 15px #2187e7;
  225. width: 46px;
  226. height: 46px;
  227. position: absolute;
  228. left: 50%;
  229. top: 50%;
  230. margin-left: -23px;
  231. margin-top: -23px;
  232. text-align: center;
  233. line-height: 46px;
  234. font-size: 40px;
  235. font-weight: bold;
  236. color: #2187e7;
  237. }
  238. .rprogress-sigh{
  239. background-image: none !important;
  240. }
  241. .rprogress-sigh .rschedule{
  242. display: none !important;
  243. }
  244. .rprogress-sigh .r-sigh{
  245. display: block !important;
  246. }
  247. .rsalert {
  248. font-size: 12px;
  249. color: #bbb;
  250. text-align: center;
  251. position: absolute;
  252. border-radius: 5px;
  253. width: 130px;
  254. margin: 5px 5px;
  255. padding: 5px;
  256. left: 0px;
  257. bottom: 0px;
  258. }
  259. @-webkit-keyframes spin {
  260. 0% {
  261. -webkit-transform: rotate(0deg);
  262. }
  263. 100% {
  264. -webkit-transform: rotate(360deg);
  265. }
  266. }
  267. @keyframes spin {
  268. 0% {
  269. transform: rotate(0deg);
  270. }
  271. 100% {
  272. transform: rotate(360deg);
  273. }
  274. }
  275. #h {
  276. background: #fff;
  277. border: solid 1px #ddd;
  278. padding: 10px !important;
  279. font-size: 16px !important;
  280. font-family: verdana !important;
  281. line-height: 18px !important;
  282. overflow: visible;
  283. position: absolute;
  284. left: -1000px;
  285. right: 0px;
  286. word-break: break-all;
  287. word-wrap: break-word;
  288. }
  289. .cancel {
  290. background-color: darkred;
  291. }
  292. </style>
  293. </head>
  294. <body contextmenu="return false;">
  295. <header class="mui-bar mui-bar-nav toptitbox">
  296. <span class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left topback"></span>
  297. <h1 class="mui-title toptit">对方姓名</h1>
  298. <span class="mui-icon mui-icon-contact mui-pull-right personhead"></span>
  299. </header>
  300. <pre id='h'></pre>
  301. <script id='msg-template' type="text/template">
  302. <% for(var i in record){ var item=record[i]; %>
  303. <div class="msg-item <%= (item.sender=='self'?' msg-item-self':'') %>" msg-type='<%=(item.type)%>' msg-content='<%=(item.content)%>'>
  304. <% if(item.sender=='self' ) { %>
  305. <i class="msg-user mui-icon mui-icon-person"></i>
  306. <% } else { %>
  307. <img class="msg-user-img" src="../images/logo.png" alt="" />
  308. <% } %>
  309. <div class="msg-content">
  310. <div class="msg-content-inner">
  311. <% if(item.type=='text' ) { %>
  312. <%=( item.content|| '&nbsp;&nbsp;') %>
  313. <% } else if(item.type=='image' ) { %>
  314. <img class="msg-content-image" src="<%=(item.content)%>" style="max-width: 100px;" />
  315. <% } else if(item.type=='sound' ) { %>
  316. <span class="mui-icon mui-icon-mic" style="font-size: 18px;font-weight: bold;"></span>
  317. <span class="play-state">点击播放</span>
  318. <% } %>
  319. </div>
  320. <div class="msg-content-arrow"></div>
  321. </div>
  322. <div class="mui-item-clear"></div>
  323. </div>
  324. <% } %>
  325. </script>
  326. <div class="mui-content">
  327. <div class="operatebox">
  328. <div class="themespan mui-pull-left">
  329. <span class="">关于XXXXXX的咨询关于XXXXXX的咨询</span>
  330. </div>
  331. <div class="operatebtnbox mui-pull-right">
  332. <button class="mui-btn mui-btn-block mui-btn-outlined frmbtn operatebtn">点击确认完成咨询</button>
  333. </div>
  334. </div>
  335. <div id='msg-list'>
  336. </div>
  337. </div>
  338. <footer>
  339. <div class="footer-left">
  340. <i id='msg-image' class="mui-icon mui-icon-camera" style="font-size: 28px;"></i>
  341. </div>
  342. <div class="footer-center">
  343. <textarea id='msg-text' type="text" class='input-text'></textarea>
  344. <button id='msg-sound' type="button" class='input-sound' style="display: none;">按住说话</button>
  345. </div>
  346. <label for="" class="footer-right">
  347. <i id='msg-type' class="mui-icon mui-icon-mic"></i>
  348. </label>
  349. </footer>
  350. <div id='sound-alert' class="rprogress">
  351. <div class="rschedule"></div>
  352. <div class="r-sigh">!</div>
  353. <div id="audio_tips" class="rsalert">手指上滑,取消发送</div>
  354. </div>
  355. <script src="../js/public/mui.min.js"></script>
  356. <script src="../js/public/mui.imageViewer.js"></script>
  357. <script src="../js/public/arttmpl.js"></script>
  358. <script type="text/javascript" charset="utf-8">
  359. (function($, doc) {
  360. var MIN_SOUND_TIME = 800;
  361. $.init({
  362. gestureConfig: {
  363. tap: true, //默认为true
  364. doubletap: true, //默认为false
  365. longtap: true, //默认为false
  366. swipe: true, //默认为true
  367. drag: true, //默认为true
  368. hold: true, //默认为false,不监听
  369. release: true //默认为false,不监听
  370. }
  371. });
  372. template.config('escape', false);
  373. //$.plusReady=function(fn){fn();};
  374. $.plusReady(function() {
  375. plus.webview.currentWebview().setStyle({
  376. softinputMode: "adjustResize"
  377. });
  378. var showKeyboard = function() {
  379. if ($.os.ios) {
  380. var webView = plus.webview.currentWebview().nativeInstanceObject();
  381. webView.plusCallMethod({
  382. "setKeyboardDisplayRequiresUserAction": false
  383. });
  384. } else {
  385. var Context = plus.android.importClass("android.content.Context");
  386. var InputMethodManager = plus.android.importClass("android.view.inputmethod.InputMethodManager");
  387. var main = plus.android.runtimeMainActivity();
  388. var imm = main.getSystemService(Context.INPUT_METHOD_SERVICE);
  389. imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
  390. //var view = ((ViewGroup)main.findViewById(android.R.id.content)).getChildAt(0);
  391. imm.showSoftInput(main.getWindow().getDecorView(), InputMethodManager.SHOW_IMPLICIT);
  392. //alert("ll");
  393. }
  394. };
  395. var record = [{
  396. sender: 'zs',
  397. type: 'text',
  398. content: 'Hi,我是 科袖 小管家!'
  399. }];
  400. var ui = {
  401. body: doc.querySelector('body'),
  402. footer: doc.querySelector('footer'),
  403. footerRight: doc.querySelector('.footer-right'),
  404. footerLeft: doc.querySelector('.footer-left'),
  405. btnMsgType: doc.querySelector('#msg-type'),
  406. boxMsgText: doc.querySelector('#msg-text'),
  407. boxMsgSound: doc.querySelector('#msg-sound'),
  408. btnMsgImage: doc.querySelector('#msg-image'),
  409. areaMsgList: doc.querySelector('#msg-list'),
  410. boxSoundAlert: doc.querySelector('#sound-alert'),
  411. h: doc.querySelector('#h'),
  412. content: doc.querySelector('.mui-content')
  413. };
  414. ui.h.style.width = ui.boxMsgText.offsetWidth+'px';
  415. //alert(ui.boxMsgText.offsetWidth );
  416. var footerPadding = ui.footer.offsetHeight - ui.boxMsgText.offsetHeight;
  417. var msgItemTap = function(msgItem, event) {
  418. var msgType = msgItem.getAttribute('msg-type');
  419. var msgContent = msgItem.getAttribute('msg-content')
  420. if (msgType == 'sound') {
  421. player = plus.audio.createPlayer(msgContent);
  422. var playState = msgItem.querySelector('.play-state');
  423. playState.innerText = '正在播放...';
  424. player.play(function() {
  425. playState.innerText = '点击播放';
  426. }, function(e) {
  427. playState.innerText = '点击播放';
  428. });
  429. }
  430. };
  431. var imageViewer = new $.ImageViewer('.msg-content-image', {
  432. dbl: false
  433. });
  434. var bindMsgList = function() {
  435. //绑定数据:
  436. /*tp.bind({
  437. template: 'msg-template',
  438. element: 'msg-list',
  439. model: record
  440. });*/
  441. ui.areaMsgList.innerHTML = template('msg-template', {
  442. "record": record
  443. });
  444. var msgItems = ui.areaMsgList.querySelectorAll('.msg-item');
  445. [].forEach.call(msgItems, function(item, index) {
  446. item.addEventListener('tap', function(event) {
  447. msgItemTap(item, event);
  448. }, false);
  449. });
  450. imageViewer.findAllImage();
  451. ui.areaMsgList.scrollTop = ui.areaMsgList.scrollHeight + ui.areaMsgList.offsetHeight;
  452. };
  453. bindMsgList();
  454. window.addEventListener('resize', function() {
  455. ui.areaMsgList.scrollTop = ui.areaMsgList.scrollHeight + ui.areaMsgList.offsetHeight;
  456. }, false);
  457. var send = function(msg) {
  458. record.push(msg);
  459. bindMsgList();
  460. toRobot(msg.content);
  461. };
  462. var toRobot = function(info) {
  463. var apiUrl = 'http://www.tuling123.com/openapi/api';
  464. $.getJSON(apiUrl, {
  465. "key": 'acfbca724ea1b5db96d2eef88ce677dc',
  466. "info": info,
  467. "userid": plus.device.uuid
  468. }, function(data) {
  469. //alert(JSON.stringify(data));
  470. record.push({
  471. sender: 'zs',
  472. type: 'text',
  473. content: data.text
  474. });
  475. bindMsgList();
  476. });
  477. };
  478. function msgTextFocus() {
  479. ui.boxMsgText.focus();
  480. setTimeout(function() {
  481. ui.boxMsgText.focus();
  482. }, 150);
  483. }
  484. //解决长按“发送”按钮,导致键盘关闭的问题;
  485. ui.footerRight.addEventListener('touchstart', function(event) {
  486. if (ui.btnMsgType.classList.contains('mui-icon-paperplane')) {
  487. msgTextFocus();
  488. event.preventDefault();
  489. }
  490. });
  491. //解决长按“发送”按钮,导致键盘关闭的问题;
  492. ui.footerRight.addEventListener('touchmove', function(event) {
  493. if (ui.btnMsgType.classList.contains('mui-icon-paperplane')) {
  494. msgTextFocus();
  495. event.preventDefault();
  496. }
  497. });
  498. // ui.footerRight.addEventListener('touchcancel', function(event) {
  499. // if (ui.btnMsgType.classList.contains('mui-icon-paperplane')) {
  500. // msgTextFocus();
  501. // event.preventDefault();
  502. // }
  503. // });
  504. // ui.footerRight.addEventListener('touchend', function(event) {
  505. // if (ui.btnMsgType.classList.contains('mui-icon-paperplane')) {
  506. // msgTextFocus();
  507. // event.preventDefault();
  508. // }
  509. // });
  510. ui.footerRight.addEventListener('release', function(event) {
  511. if (ui.btnMsgType.classList.contains('mui-icon-paperplane')) {
  512. //showKeyboard();
  513. ui.boxMsgText.focus();
  514. setTimeout(function() {
  515. ui.boxMsgText.focus();
  516. }, 150);
  517. // event.detail.gesture.preventDefault();
  518. send({
  519. sender: 'self',
  520. type: 'text',
  521. content: ui.boxMsgText.value.replace(new RegExp('\n', 'gm'), '<br/>')
  522. });
  523. ui.boxMsgText.value = '';
  524. $.trigger(ui.boxMsgText, 'input', null);
  525. } else if (ui.btnMsgType.classList.contains('mui-icon-mic')) {
  526. ui.btnMsgType.classList.add('mui-icon-compose');
  527. ui.btnMsgType.classList.remove('mui-icon-mic');
  528. ui.boxMsgText.style.display = 'none';
  529. ui.boxMsgSound.style.display = 'block';
  530. ui.boxMsgText.blur();
  531. document.body.focus();
  532. } else if (ui.btnMsgType.classList.contains('mui-icon-compose')) {
  533. ui.btnMsgType.classList.add('mui-icon-mic');
  534. ui.btnMsgType.classList.remove('mui-icon-compose');
  535. ui.boxMsgSound.style.display = 'none';
  536. ui.boxMsgText.style.display = 'block';
  537. //--
  538. //showKeyboard();
  539. ui.boxMsgText.focus();
  540. setTimeout(function() {
  541. ui.boxMsgText.focus();
  542. }, 150);
  543. }
  544. }, false);
  545. ui.footerLeft.addEventListener('tap', function(event) {
  546. var btnArray = [{
  547. title: "拍照"
  548. }, {
  549. title: "从相册选择"
  550. }];
  551. plus.nativeUI.actionSheet({
  552. title: "选择照片",
  553. cancel: "取消",
  554. buttons: btnArray
  555. }, function(e) {
  556. var index = e.index;
  557. switch (index) {
  558. case 0:
  559. break;
  560. case 1:
  561. var cmr = plus.camera.getCamera();
  562. cmr.captureImage(function(path) {
  563. send({
  564. sender: 'self',
  565. type: 'image',
  566. content: "file://" + plus.io.convertLocalFileSystemURL(path)
  567. });
  568. }, function(err) {});
  569. break;
  570. case 2:
  571. plus.gallery.pick(function(path) {
  572. send({
  573. sender: 'self',
  574. type: 'image',
  575. content: path
  576. });
  577. }, function(err) {}, null);
  578. break;
  579. }
  580. });
  581. }, false);
  582. var setSoundAlertVisable=function(show){
  583. if(show){
  584. ui.boxSoundAlert.style.display = 'block';
  585. ui.boxSoundAlert.style.opacity = 1;
  586. }else{
  587. ui.boxSoundAlert.style.opacity = 0;
  588. //fadeOut完成再真正隐藏
  589. setTimeout(function(){
  590. ui.boxSoundAlert.style.display = 'none';
  591. },200);
  592. }
  593. };
  594. var recordCancel = false;
  595. var recorder = null;
  596. var audio_tips = document.getElementById("audio_tips");
  597. var startTimestamp = null;
  598. var stopTimestamp = null;
  599. var stopTimer = null;
  600. ui.boxMsgSound.addEventListener('hold', function(event) {
  601. recordCancel = false;
  602. if(stopTimer)clearTimeout(stopTimer);
  603. audio_tips.innerHTML = "手指上划,取消发送";
  604. ui.boxSoundAlert.classList.remove('rprogress-sigh');
  605. setSoundAlertVisable(true);
  606. recorder = plus.audio.getRecorder();
  607. if (recorder == null) {
  608. plus.nativeUI.toast("不能获取录音对象");
  609. return;
  610. }
  611. startTimestamp = (new Date()).getTime();
  612. recorder.record({
  613. filename: "_doc/audio/"
  614. }, function(path) {
  615. if (recordCancel) return;
  616. send({
  617. sender: 'self',
  618. type: 'sound',
  619. content: path
  620. });
  621. }, function(e) {
  622. plus.nativeUI.toast("录音时出现异常: " + e.message);
  623. });
  624. }, false);
  625. ui.body.addEventListener('drag', function(event) {
  626. //console.log('drag');
  627. if (Math.abs(event.detail.deltaY) > 50) {
  628. if (!recordCancel) {
  629. recordCancel = true;
  630. if (!audio_tips.classList.contains("cancel")) {
  631. audio_tips.classList.add("cancel");
  632. }
  633. audio_tips.innerHTML = "松开手指,取消发送";
  634. }
  635. } else {
  636. if (recordCancel) {
  637. recordCancel = false;
  638. if (audio_tips.classList.contains("cancel")) {
  639. audio_tips.classList.remove("cancel");
  640. }
  641. audio_tips.innerHTML = "手指上划,取消发送";
  642. }
  643. }
  644. }, false);
  645. ui.boxMsgSound.addEventListener('release', function(event) {
  646. //console.log('release');
  647. if (audio_tips.classList.contains("cancel")) {
  648. audio_tips.classList.remove("cancel");
  649. audio_tips.innerHTML = "手指上划,取消发送";
  650. }
  651. //
  652. stopTimestamp = (new Date()).getTime();
  653. if (stopTimestamp - startTimestamp < MIN_SOUND_TIME) {
  654. audio_tips.innerHTML = "录音时间太短";
  655. ui.boxSoundAlert.classList.add('rprogress-sigh');
  656. recordCancel = true;
  657. stopTimer=setTimeout(function(){
  658. setSoundAlertVisable(false);
  659. },800);
  660. }else{
  661. setSoundAlertVisable(false);
  662. }
  663. recorder.stop();
  664. }, false);
  665. ui.boxMsgSound.addEventListener("touchstart", function(e) {
  666. //console.log("start....");
  667. e.preventDefault();
  668. });
  669. ui.boxMsgText.addEventListener('input', function(event) {
  670. ui.btnMsgType.classList[ui.boxMsgText.value == '' ? 'remove' : 'add']('mui-icon-paperplane');
  671. ui.btnMsgType.setAttribute("for", ui.boxMsgText.value == '' ? '' : 'msg-text');
  672. ui.h.innerText = ui.boxMsgText.value.replace(new RegExp('\n', 'gm'), '\n-') || '-';
  673. ui.footer.style.height = (ui.h.offsetHeight + footerPadding) + 'px';
  674. ui.content.style.paddingBottom = ui.footer.style.height;
  675. });
  676. ui.boxMsgText.addEventListener('tap', function(event) {
  677. ui.boxMsgText.focus();
  678. setTimeout(function() {
  679. ui.boxMsgText.focus();
  680. }, 0);
  681. }, false);
  682. });
  683. }(mui, document));
  684. </script>
  685. </body>
  686. </html>