my-appointment.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. mui.init();
  2. var patient = null;
  3. var docInfo = null;
  4. var pageIndex = 1;
  5. var pageSize = 10;
  6. var self;
  7. mui.plusReady(function(){
  8. self = plus.webview.currentWebview();
  9. docInfo = JSON.parse(plus.storage.getItem("docInfo"));
  10. patient = self.patient;
  11. queryInit();
  12. })
  13. function queryInit(){
  14. plus.nativeUI.showWaiting();
  15. initData();
  16. bindEvents();
  17. function bindEvents(){
  18. $(".c-list").on("click",".n-list-li,.n-list-content",function(event){
  19. //该患者跟医生无签约关系时不可看详细信息
  20. if(self.qyRelation == 0)
  21. return;
  22. var parentLi = $(this).closest("li");
  23. var id = parentLi.attr("data-id");
  24. openWebviewExtras("detail-appointment.html",{dataId:id});
  25. }).on("click",".div-again",function(){
  26. var parentLi = $(this).closest("li");
  27. var id = parentLi.attr("data-id");
  28. var doctorCode = parentLi.attr("data-doctorCode");
  29. var orgCode = parentLi.attr("data-orgCode");
  30. var deptCode = parentLi.attr("data-deptCode");
  31. var params = {};
  32. params.id=id;
  33. params.doctorId=doctorCode;
  34. params.hospitalId=orgCode;
  35. params.deptId = deptCode;
  36. params.type=2;
  37. params.patient = patient;
  38. openWebviewExtras("doctor-detail.html",params);
  39. })
  40. $(".div-add-btn").on("click",function(){
  41. openWebview("appointment-register.html");
  42. })
  43. scroller1 = $("#wrapper2").initScroll(
  44. {
  45. pullDownAction: function(){
  46. location.reload();
  47. },pullUpAction: function() {
  48. getMyAppo();
  49. }
  50. }
  51. );
  52. }
  53. function initData(){
  54. $(".c-list").html("");
  55. pageIndex = 1;
  56. getMyAppo();
  57. }
  58. function getMyAppo(){
  59. var data={};
  60. data.patient = patient;
  61. data.doctor = docInfo.code;
  62. data.pageIndex = pageIndex;
  63. data.pageSize = pageSize;
  64. sendPost('third/guahao/GetPatientReservationList', data, getListFail, successFun);
  65. }
  66. function successFun(res){
  67. plus.nativeUI.closeWaiting();
  68. if(res.status==200){
  69. updatePullUpText(scroller1,res.data);
  70. /*res.data = [{
  71. doctorName: "aa", startTime: "2016-06-06 06:06:06"
  72. }]*/
  73. if(res.data&&res.data.length>0){
  74. pageIndex=pageIndex+1;
  75. appendMyAppo(res.data);
  76. }else{
  77. if(pageIndex==1){
  78. $(".main").hide();
  79. $(".div-no-info").show();
  80. $("#footer").show();
  81. }else{
  82. mui.toast("无更多数据");
  83. }
  84. }
  85. }else{
  86. getListFail(res);
  87. }
  88. }
  89. function getListFail(res){
  90. plus.nativeUI.closeWaiting();
  91. if (res && res.msg) {
  92. mui.toast(res.msg);
  93. } else {
  94. mui.toast("加载失败!");
  95. }
  96. }
  97. function appendMyAppo(dataList){
  98. var appoHtml ="";
  99. for(var j in dataList){
  100. var data = dataList[j];
  101. //status:0 已撤销 1 预约成功 2 已就诊 3已停诊
  102. var clazz1 = "cb-47ABEF";
  103. var clazz2 = "c-47ABEF";
  104. var statusNm = "预约成功"
  105. if(data.status=="0"){
  106. clazz1 = "cb-FF6A56";
  107. clazz2 = "c-FF6A56";
  108. statusNm = "已撤销";
  109. }else if(data.status=="2"){
  110. clazz1 = "cb-74BF00";
  111. clazz2 = "c-74BF00";
  112. statusNm = "已就诊";
  113. }else if(data.status=="3"){
  114. clazz1 = "cb-909090";
  115. clazz2 = "c-909090";
  116. statusNm = "已停诊";
  117. }
  118. appoHtml+='<li class="mt10" data-id="'+data.id+'" data-doctorCode="'+data.doctorCode+'" data-orgCode="'+data.orgCode+'" data-deptCode="'+data.deptCode+'">'+
  119. '<div class="n-list dr-item c-border">'+
  120. '<div class="n-list-li pl10">'+
  121. '<div class="n-list-key">'+
  122. '<div class="n-avatar-l img-round">'+
  123. '<img src="../../../images/d-male.png">'+
  124. '</div>'+
  125. '</div>'+
  126. '<div class="pl15">'+
  127. '<div>'+
  128. '<span class="c-f16 c-bold c-323232">'+data.doctorName+'</span>'+
  129. '<span class="c-f12 c-666666 pl10">('+data.doctorJob+')</span>'+
  130. '<span class="c-f12 c-666666 pl10">'+data.deptName+'</span>'+
  131. '</div>'+
  132. '<div class="c-f14 c-323232 pt5">'+data.orgName+'</div>'+
  133. '</div>'+
  134. '</div>'+
  135. '<div class="mt10 c-f12 c-666666 n-list-content mb5 pl10">'+
  136. '<span>就诊时间:'+data.startTime.toString().substring(0,16)+'</span>'+
  137. '<span class="f-fr pr15">代预约:'+data.dname+'</span>'+
  138. '</div>'+
  139. '<div class="line"></div>';
  140. if(self.qyRelation==1){
  141. appoHtml +=
  142. '<div class="div-remark pl10">'+
  143. '<div class="f-fr pr15 div-again">'+
  144. '<div class="right-content">再次预约</div>'+
  145. '<img src="../images/tiaozhuan_lvse_icon.png">'+
  146. '</div>'+
  147. '</div>';
  148. }
  149. appoHtml += '</div></li>';
  150. }
  151. $(".c-list").append(appoHtml);
  152. $(".main").show();
  153. $("#footer").show();
  154. }
  155. var updatePullUpText= function(scroller,list) {
  156. var $wrap = $(scroller.wrapper),
  157. $pullupLabel = $wrap.find('.pullUpLabel');
  158. $(".pullUp").removeClass("loading");
  159. if(!list || !list.length) {
  160. $pullupLabel.text('没有更多');
  161. } else {
  162. $pullupLabel.text('上拉加载更多');
  163. }
  164. scroller.on('refresh',function() {
  165. if(!list || !list.length) {
  166. $pullupLabel.text('没有更多');
  167. } else {
  168. $pullupLabel.text('上拉加载更多');
  169. }
  170. });
  171. }
  172. }
  173. window.addEventListener('update', function(e) {
  174. queryInit();
  175. });