work_team.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. mui.plusReady(function() {
  2. // mui(".c-list").on("tap", "li", function() {
  3. // openWebview("my-doctor-advice-detail.html");
  4. // });
  5. //查询列表
  6. // clearHTML();
  7. queryList();
  8. //返回xiaoxi页面时红点消失
  9. var old_back = mui.back;
  10. mui.back = function(){
  11. var mainWv1 = plus.webview.getWebviewById("xiaoxi.html");
  12. mui.fire(mainWv1, "red_xinxi_none",{
  13. });
  14. old_back();
  15. }
  16. });
  17. function queryList() {
  18. plus.nativeUI.showWaiting();
  19. //拼请求内容
  20. var params = {};
  21. //发送ajax请求
  22. sendPost("doctor/teams", params, queryListFailed, queryListSuccesss);
  23. }
  24. function queryListFailed(res) {
  25. if (res && res.msg) {
  26. plus.nativeUI.toast(res.msg);
  27. } else {
  28. plus.nativeUI.toast("数据加载失败");
  29. }
  30. plus.nativeUI.closeWaiting();
  31. }
  32. function queryListSuccesss(res) {
  33. console.log(JSON.stringify(res));
  34. if (res.status == 200) {
  35. //成功
  36. showList(res.list);
  37. // template.helper("setIcon", function(i) {
  38. // return i || "../images/list-tb3.png"
  39. // });
  40. // template.helper("setJson", function(j) {
  41. // return JSON.stringify(j);
  42. // });
  43. // var cont = template("work_team_tmpl", res);
  44. // $("#work_team_list").html(cont);
  45. } else {
  46. //非200则为失败
  47. queryListFailed(res);
  48. }
  49. plus.nativeUI.closeWaiting();
  50. }
  51. /*
  52. * 条目点击事件
  53. */
  54. //$("#work_team_list").on("click", "li", function() {
  55. // // var attr_code = $(this).attr('attr_code');
  56. // // var attr_first_doc = $(this).attr('attr_first_doc');
  57. // // var attr_icon = $(this).attr('attr_icon');
  58. // // var attr_name = $(this).attr('attr_name');
  59. // var infoStr = $(this).attr("data-json");
  60. //
  61. // mui.openWindow('../../message/html/qunzuduihua.html', 'qunzudui', {
  62. // extras: {
  63. // info: infoStr
  64. // }
  65. // });
  66. //
  67. //});
  68. /**
  69. * 清空tbody
  70. */
  71. function clearHTML() {
  72. $("#work_team_list").html("");
  73. }
  74. /**
  75. * 显示查询结果
  76. * @param {Object} list
  77. */
  78. function showList(list) {
  79. // clearHTML();
  80. var _html = "";
  81. var new_num_S="";
  82. for (var i = 0; i < list.length; i++) {
  83. var data = list[i];
  84. if (!data) {
  85. continue;
  86. }
  87. var icon_url=""
  88. if(data.icon=="" || data.icon==null){
  89. icon_url="../images/list-tb3.png";
  90. }
  91. var groupId=data.code;
  92. new_num_S = plus.storage.getItem(groupId + '_new');//获取新消息数量
  93. var new_info_num = "";
  94. if (new_num_S == null) {
  95. new_info_num = "";
  96. } else {
  97. new_info_num = new_num_S;
  98. }
  99. //组名大于15个字则后续用省略号代替
  100. var groupName=data.name;
  101. if(groupName.length>15){
  102. groupName=groupName.substring(0,15)+"...";
  103. }
  104. _html += "<li class='c-list-link c-list-function' data-json='" + JSON.stringify(data) + "' >"
  105. _html += "<div class='c-avatar-m'><img src='" + getImgUrl(icon_url) + "' class='c-images-cycle'></div>"
  106. _html += "<div class='c-list-info'>"
  107. _html += "<h4 class='c-nowrap'>" + groupName + "</h4>"
  108. _html += "<p class='c-nowrap'>创建人:" + data.doctor + "</p>"
  109. _html += "</div>"
  110. _html += "<div class='c-list-badge' style='color: red;' id='"+groupId+"'>"+new_info_num+"</div>"
  111. _html += "<span class='list-icon arrow-right'></span>"
  112. _html += "</li>"
  113. }
  114. $("#work_team_list").html(_html);
  115. $("#work_team_list").on("click", "li", function() {
  116. var infoStr = $(this).attr("data-json");
  117. var Did=infoStr.code;
  118. var Didv="#"+Did;
  119. $(Didv).html(""); //点击具体工作组后新消息数目清空
  120. mui.openWindow('../../message/html/qunzuduihua.html', 'qunzudui', {
  121. extras: {
  122. info: infoStr
  123. }
  124. });
  125. });
  126. }
  127. //添加数据添加监听
  128. window.addEventListener("update_info", function(e) {
  129. clearHTML();
  130. //刷新列表
  131. queryList();
  132. });
  133. //退出群组对话时新消息数目设为空事件 ,事件设定在qunzuduihua.html
  134. window.addEventListener("zero_xinxi", function() {
  135. // alert(event.detail.id);
  136. var Did=event.detail.id;
  137. var Didv="#"+Did;
  138. // alert(Didv);
  139. $(Didv).html("");//html代码上显示为空
  140. var new_c=plus.storage.getItem(Did+ '_new');//将本地存储的新消息数设为空
  141. if(new_c!=null){
  142. plus.storage.removeItem(Did+ '_new');
  143. }
  144. });
  145. //实时更新新消息数目(当处于gongzuozu.html时)
  146. window.addEventListener("update_xinxi", function() {
  147. // alert(event.detail.id);
  148. var Did=event.detail.id;
  149. var Num=event.detail.num;
  150. var Didv="#"+Did;
  151. $(Didv).html(Num);
  152. });