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.
 
 
 
 
 
 

242 lines
6.1 KiB

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Hello MUI</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
  7. <meta name="apple-mobile-web-app-capable" content="yes">
  8. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  9. <link rel="stylesheet" href="css/mui.min.css">
  10. <style>
  11. <style>html,
  12. body {
  13. background-color: #efeff4;
  14. }
  15. .mui-content>.mui-table-view:first-child {
  16. margin-top: 0px;
  17. }
  18. .title {
  19. margin: 20px 15px 10px;
  20. color: #6d6d72;
  21. font-size: 15px;
  22. }
  23. .oa-contact-cell.mui-table .mui-table-cell {
  24. padding: 11px 0;
  25. vertical-align: middle;
  26. }
  27. .oa-contact-cell {
  28. position: relative;
  29. margin: -11px 0;
  30. }
  31. .oa-contact-avatar {
  32. width: 75px;
  33. }
  34. .oa-contact-avatar img {
  35. border-radius: 50%;
  36. }
  37. .oa-contact-content {
  38. width: 100%;
  39. }
  40. .oa-contact-name {
  41. margin-right: 20px;
  42. }
  43. .oa-contact-name,
  44. oa-contact-position {
  45. float: left;
  46. }
  47. </style>
  48. </style>
  49. </head>
  50. <body>
  51. <div class="mui-content">
  52. <ul class="mui-table-view mui-table-view-striped mui-table-view-condensed" id="table">
  53. </ul>
  54. </div>
  55. </body>
  56. <script src="js/mui.min.js"></script>
  57. <script src="js/userinfos.js"></script>
  58. <script type="text/javascript" src="js/serverurl.js"></script>
  59. <script type="text/javascript" charset="utf-8">
  60. (function($, doc) {
  61. mui.plusReady(function() {
  62. if(CheckLogin()) {
  63. var B = window.plus.bridge;
  64. var Yuntx = {
  65. ReadOffLineMessage: function(uln, unickname, successCallback, errorCallback) {
  66. var success = typeof successCallback !== 'function' ? null : function(args) {
  67. successCallback(args);
  68. },
  69. fail = typeof errorCallback !== 'function' ? null : function(code) {
  70. errorCallback(code);
  71. },
  72. callbackID = B.callbackId(success, fail);
  73. return B.exec("Yuntx", "ReadOffLineMessage", [callbackID, uln, unickname]);
  74. },
  75. OpenChat: function(uln, tln, successCallback, errorCallback) {
  76. var success = typeof successCallback !== 'function' ? null : function(args) {
  77. successCallback(args);
  78. },
  79. fail = typeof errorCallback !== 'function' ? null : function(code) {
  80. errorCallback(code);
  81. },
  82. callbackID = B.callbackId(success, fail);
  83. return B.exec("Yuntx", "OpenChat", [callbackID, uln, tln]);
  84. }
  85. };
  86. window.plus.Yuntx = Yuntx;
  87. var list = JSON.parse(localStorage.getItem('taigangteacherMsgList') || '[]');
  88. LoadList(list);
  89. GetMessage();
  90. }
  91. });
  92. }(mui, document));
  93. function GetMessage() {
  94. plus.Yuntx.ReadOffLineMessage(users.ID, users.username,
  95. function(contact) { //成功
  96. SaveMsgList(contact);
  97. },
  98. function(status) { //失败
  99. plus.nativeUI.toast("获取消息失败!");
  100. }
  101. );
  102. }
  103. function OpenChat(id) {
  104. plus.Yuntx.OpenChat(users.ID, id,
  105. function(contact) { //成功
  106. plus.nativeUI.closeWaiting();
  107. },
  108. function(status) { //失败
  109. plus.nativeUI.closeWaiting();
  110. });
  111. }
  112. function SaveMsgList(msg) {
  113. var list = JSON.parse(localStorage.getItem('taigangteacherMsgList') || '[]');
  114. var obj = JSON.parse(msg);
  115. if(list != undefined && list != null && list.length > 0) {
  116. for(var i in obj) {
  117. var hasid = false;
  118. for(j in list) {
  119. if(list[j].Form == obj[i].Form) {
  120. list[j] = obj[i];
  121. hasid = true;
  122. break;
  123. } else {
  124. continue;
  125. }
  126. }
  127. if(!hasid) {
  128. list.push(obj[i]);
  129. }
  130. }
  131. } else {
  132. for(j in obj) {
  133. var hasidnew = false;
  134. for(k in list) {
  135. if(list[k].Form == obj[j].Form) {
  136. list[k] = obj[j];
  137. hasidnew = true;
  138. break;
  139. } else {
  140. continue;
  141. }
  142. }
  143. if(!hasidnew) {
  144. list.push(obj[j]);
  145. }
  146. }
  147. }
  148. localStorage.setItem('taigangteacherMsgList', JSON.stringify(list));
  149. LoadList(list);
  150. }
  151. function DeleteMsgList(id) {
  152. var list = JSON.parse(localStorage.getItem('taigangteacherMsgList') || '[]');
  153. if(list.length > 0) {
  154. for(var i in list) {
  155. if(list[i].Form == id) {
  156. list.splice(i, 1);
  157. break;
  158. } else {
  159. continue;
  160. }
  161. }
  162. LoadList(list);
  163. }
  164. }
  165. function longPress(id) {
  166. timeOutEvent = 0;
  167. var btnArray = [{
  168. title: "删除消息记录",
  169. style: "destructive"
  170. }];
  171. plus.nativeUI.actionSheet({
  172. cancel: "取消",
  173. buttons: btnArray
  174. }, function(e) {
  175. var index = e.index;
  176. if(index==1)
  177. {
  178. DeleteMsgList(id);
  179. }
  180. });
  181. }
  182. function LoadList(contact) {
  183. var table = document.getElementById("table");
  184. table.innerHTML = "";
  185. if(contact != null && contact.length > 0) {
  186. for(var i in contact) {
  187. var li = document.createElement("li");
  188. li.setAttribute("userid",""+contact[i].Form+"");
  189. li.addEventListener("touchstart", function(id) {
  190. timeOutEvent = setTimeout("longPress('"+this.getAttribute('userid')+"')", 500);
  191. e.preventDefault();
  192. });
  193. li.addEventListener("touchend", function(id) {
  194. clearTimeout(timeOutEvent);
  195. if(timeOutEvent != 0) {}
  196. return false;
  197. });
  198. li.innerHTML = '<li class="mui-table-view-cell" onclick="OpenChat(\'' + contact[i].Form + '\');" id="' + contact[i].Form + '">' +
  199. '<div class="mui-slider-cell">' +
  200. '<div class="oa-contact-cell mui-table">' +
  201. '<div class="oa-contact-avatar mui-table-cell">' +
  202. '<img src="images/geren.png" />' +
  203. '</div>' +
  204. '<div class="oa-contact-content mui-table-cell">' +
  205. '<div class="mui-clearfix">' +
  206. '<h4 class="oa-contact-name">' + (contact[i].NickName != undefined && contact[i].NickName != null&& contact[i].NickName !='' ? contact[i].NickName : contact[i].Form) + '</h4>' +
  207. '<span class="oa-contact-position mui-h6" style="float: right;">' + contact[i].MsgTime + '</span>' +
  208. '</div>' +
  209. '<p class="oa-contact-email mui-h6">' +
  210. '聊天记录' +
  211. '</p>' +
  212. '</div>' +
  213. '</div>' +
  214. '</div>' +
  215. '</li>';
  216. table.appendChild(li, table.firstChild);
  217. }
  218. }
  219. }
  220. </script>
  221. </html>