xitongxiaoxi.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. var myScroll, page = 1,self;
  2. var unReadCount = 0; //标记未读消息数量
  3. var doctorCode;
  4. mui.plusReady(function() {
  5. self = plus.webview.currentWebview();
  6. backParent();
  7. myScroll = $('#lscroll').lscroll({pullUpAction: function(g){
  8. getMsgLs(page);
  9. }, top: 46});
  10. getMsgLs(1, true);
  11. doctorCode = JSON.parse(plus.storage.getItem("docInfo")).code;
  12. });
  13. function getMsgLs(curpage, isRefresh){
  14. var pagesize = 10;
  15. plus.nativeUI.showWaiting();
  16. // sendPost("doctor/message/findMessage", {
  17. //新的接口
  18. sendGet("/doctor/message/getSystemMessage",{
  19. // type: 3,
  20. // id: lastId,
  21. page: curpage,
  22. pagesize: pagesize
  23. }, null, function(res) {
  24. if (res.status == 200) {
  25. plus.nativeUI.closeWaiting();
  26. if (page == 1 && res.list.length == 0) {
  27. $("#wushuju").removeClass("c-hide");
  28. $('#list').hide();
  29. return;
  30. }
  31. $("#wushuju").addClass("c-hide");
  32. for(i = 0; i< res.list.length; i++){
  33. if(res.list[i].read == 1){
  34. unReadCount += 1;
  35. }
  36. }
  37. if(unReadCount > 0){
  38. $("#read_btn").removeClass("disabled");
  39. }
  40. if(isRefresh){
  41. $("#lscroll").empty().append(template("sign_tmpl", res));
  42. }else{
  43. $("#lscroll").append(template("sign_tmpl", res));
  44. }
  45. myScroll.refresh(res.list.length<pagesize);
  46. page = page + 1;
  47. } else
  48. mui.toast("加载消息出错!");
  49. })
  50. }
  51. mui("#list").on("tap", ".msg-box", function() {
  52. var $dom = $(this);
  53. if($dom.hasClass('new-msg')){
  54. sendPost("/doctor/message/read_health", {msgid: $(this).attr('data-code')}, null, function(res){
  55. if(res.status==200){
  56. $dom.removeClass('new-msg');
  57. $dom.addClass('bg-fff');
  58. //添加类型判断
  59. var type = $dom.attr("data-type"),
  60. dstr = $dom.attr("data-date");
  61. if(type == 4){ //随访消息
  62. var date = dstr.substr(0,4)+"/"+dstr.substr(5,2)+"/"+dstr.substr(8,2);
  63. mui.openWindow("../../suifang/html/index.html",'index',{extras:{date:date}});
  64. }else if(type == 5){//咨询
  65. var count = parseInt($dom.attr("data-count"));
  66. var sessionid = $dom.attr("data-sessionid");
  67. var sessionname = $dom.attr("data-sessionname");
  68. if(count == 1){
  69. openWebview("p2dzixun.html",{type: 2, sessionId: sessionid, sessionName: sessionname});
  70. }else{
  71. openWebview("../../xiaoxi/html/jiankangzixun.html");
  72. }
  73. }else if(type == 8){ //续方分配配送员
  74. var docCode = $dom.attr("data-receiver"),
  75. teamInfo = JSON.parse(plus.storage.getItem("teamInfo")),
  76. teamCode;
  77. for(var i=0; i<teamInfo.data.length; i++){
  78. var item = teamInfo.data[i];
  79. if(item.leaderCode == docCode){
  80. teamCode = item.id;
  81. break;
  82. }
  83. }
  84. openWebview('../../prescription/html/daifenpei.html', {
  85. teamCode: teamCode
  86. })
  87. }else if(type == 9){ //线下调整
  88. mui.openWindow({
  89. id: "change-chufang1",
  90. url: "../../prescription/html/change-chufang1.html",
  91. extras: {
  92. prescriptionCode:$dom.attr("data-relationcode")
  93. }
  94. })
  95. } else if(type == 10 || type == 11){ //意见反馈,账号申诉
  96. var fbType = type == 10 ? 2 : 1;
  97. mui.openWindow({
  98. id: "feedback-detail.html",
  99. url: "../../mine/html/feedback-detail.html",
  100. extras: {
  101. type: fbType,
  102. code: $dom.attr("data-relationcode")
  103. }
  104. })
  105. }else if(type == 13){ //产检记录
  106. mui.openWindow({
  107. id: "yunjianjihua",
  108. url: "../../fybj/html/yunjianjihua.html",
  109. extras: {
  110. patiCode: $dom.attr('pati-code'),
  111. doctorCode:doctorCode
  112. }
  113. })
  114. }
  115. else{
  116. mui.openWindow({
  117. id: "zhuanyijumin",
  118. url: "../../search/html/zhuanyijumin.html",
  119. extras: {
  120. type: "分配",
  121. }
  122. });
  123. }
  124. } else {
  125. mui.toast(res.msg);
  126. }
  127. })
  128. } else{
  129. //添加类型判断
  130. var type = $dom.attr("data-type"),
  131. dstr = $dom.attr("data-date");
  132. if(type == 4){ //随访
  133. var date = dstr.substr(0,4)+"/"+dstr.substr(5,2)+"/"+dstr.substr(8,2);
  134. mui.openWindow("../../suifang/html/index.html",'index',{extras:{date:date}});
  135. }else if(type == 5){//咨询
  136. var count = parseInt($dom.attr("data-count"));
  137. var sessionid = $dom.attr("data-sessionid");
  138. var sessionname = $dom.attr("data-sessionname");
  139. if(count == 1){
  140. openWebview("p2dzixun.html",{type: 2, sessionId: sessionid, sessionName: sessionname});
  141. }else{
  142. openWebview("../../xiaoxi/html/jiankangzixun.html");
  143. }
  144. }else if(type == 8){ //续方分配配送员
  145. var docCode = $dom.attr("data-receiver"),
  146. teamInfo = JSON.parse(plus.storage.getItem("teamInfo")),
  147. teamCode;
  148. for(var i=0; i<teamInfo.data.length; i++){
  149. var item = teamInfo.data[i];
  150. if(item.leaderCode == docCode){
  151. teamCode = item.id;
  152. break;
  153. }
  154. }
  155. openWebview('../../prescription/html/daifenpei.html', {
  156. teamCode: teamCode
  157. })
  158. }else if(type == 9){ //线下调整
  159. mui.openWindow({
  160. id: "change-chufang1",
  161. url: "../../prescription/html/change-chufang1.html",
  162. extras: {
  163. prescriptionCode:$dom.attr("data-relationcode")
  164. }
  165. })
  166. }else if(type == 10 || type == 11){ //意见反馈,账号申诉
  167. var fbType = type == 10 ? 2 : 1;
  168. mui.openWindow({
  169. id: "feedback-detail.html",
  170. url: "../../mine/html/feedback-detail.html",
  171. extras: {
  172. type: fbType,
  173. code: $dom.attr("data-relationcode")
  174. }
  175. })
  176. }else if(type == 13){ //产检记录
  177. mui.openWindow({
  178. id: "yunjianjihua",
  179. url: "../../fybj/html/yunjianjihua.html",
  180. extras: {
  181. patiCode: $(this).attr('pati-code'),
  182. doctorCode:doctorCode
  183. }
  184. })
  185. }
  186. else{
  187. mui.openWindow({
  188. id: "zhuanyijumin",
  189. url: "../../search/html/zhuanyijumin.html",
  190. extras: {
  191. type: "分配",
  192. }
  193. });
  194. }
  195. }
  196. });
  197. $("#read_btn").on('tap', function(){
  198. var $this = $(this);
  199. if(!$this.hasClass("disabled")){
  200. plus.nativeUI.showWaiting();
  201. sendPost("doctor/message/setMessageReaded", {type: 3}, null, function(res){
  202. if(res.status == 200){
  203. $this.addClass("disabled");
  204. getMsgLs(1, true);
  205. }else{
  206. mui.toast(res.msg);
  207. }
  208. plus.nativeUI.closeWaiting();
  209. });
  210. }
  211. })
  212. function backParent(){
  213. var old_back = mui.back;
  214. mui.back = function() {
  215. if(self.opener()){
  216. mui.fire(self.opener(), "refresh");
  217. }
  218. old_back();
  219. }
  220. }