doctor-appointment.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. mui.init();
  2. var docInfo = null;
  3. var pageIndex = 1;
  4. var pageSize = 10;
  5. var scroller1;
  6. mui.plusReady(function(){
  7. var self = plus.webview.currentWebview();
  8. docInfo = JSON.parse(plus.storage.getItem("docInfo"));
  9. queryInit();
  10. })
  11. function queryInit(){
  12. plus.nativeUI.showWaiting();
  13. initData();
  14. bindEvents();
  15. function bindEvents(){
  16. $(".c-list").on("click","li",function(event){
  17. var parentLi = $(this).closest("li");
  18. var id = parentLi.attr("data-id");
  19. openWebviewExtras("detail-appointment.html",{dataId:id});
  20. });
  21. $(".btntrue").bind("click",function(){
  22. openWebview("../../search/html/xuanzejumin_one.html",{origin:'wdyy'});
  23. })
  24. scroller1 = $("#wrapper2").initScroll(
  25. {
  26. pullDownAction: function(){
  27. location.reload();
  28. },pullUpAction: function() {
  29. getMyAppo();
  30. }
  31. }
  32. );
  33. }
  34. function initData(){
  35. $(".c-list").html("");
  36. pageIndex = 1;
  37. getMyAppo();
  38. }
  39. function getMyAppo(){
  40. var data={};
  41. data.doctor = docInfo.code;
  42. data.pageIndex = pageIndex;
  43. data.pageSize = pageSize;
  44. sendPost('third/guahao/GetDoctorReservationList', data, getListFail, successFun);
  45. }
  46. function successFun(res){
  47. plus.nativeUI.closeWaiting();
  48. if(res.status==200){
  49. updatePullUpText(scroller1,res.data);
  50. if(res.data&&res.data.length>0){
  51. pageIndex=pageIndex+1;
  52. appendMyAppo(res.data);
  53. }else{
  54. if(pageIndex==1){
  55. $(".main").hide();
  56. $(".div-no-info").show();
  57. }else{
  58. mui.toast("无更多数据");
  59. }
  60. }
  61. if(res.data.length < pageSize){
  62. $(".pullUp").hide();
  63. }else{
  64. $(".pullUp").show();
  65. }
  66. scroller1.refresh();
  67. }else{
  68. getListFail(res);
  69. }
  70. }
  71. function getListFail(res){
  72. plus.nativeUI.closeWaiting();
  73. if (res && res.msg) {
  74. mui.toast(res.msg);
  75. } else {
  76. mui.toast("加载失败!");
  77. }
  78. }
  79. function appendMyAppo(dataList){
  80. var appoHtml ="";
  81. for(var j in dataList){
  82. var data = dataList[j];
  83. var photo = getImgUrl(data.doctorPhoto) || "../../../images/d-male.png";
  84. console.log(photo);
  85. appoHtml+='<li class="mt10" data-id="'+data.id+'" data-doctorCode="'+data.doctorCode+'" data-orgCode="'+data.orgCode+'" data-deptCode="'+data.deptCode+'" >'
  86. +'<div class="n-list dr-item c-border">'
  87. +'<div class="n-list-li pl10">'
  88. +'<div class="n-list-key">'
  89. +'<div class="n-avatar-l img-round">'
  90. +'<img src="'+ photo +'">'
  91. +'</div>'
  92. +'</div>'
  93. +'<div class="pl15">'
  94. +'<div>'
  95. +'<span class="c-f16 c-bold c-323232">'+data.name+'</span>'
  96. +'</div>'
  97. +'<div class="c-f12 c-909090 pt5">挂号时间:&nbsp;&nbsp;'
  98. +'<span>'+data.czrq+'<span>'
  99. +'</div>'
  100. +'</div>'
  101. +'</div>'
  102. +'<div class="div-remark pl20 pt10 pb5">'
  103. +'<div>'
  104. +'<div class="left-yuan cb-333333"></div>'
  105. +'<div class="left-status c-333333 ml10 f-fs14">预约医生:'+data.doctorName+'</div>'
  106. +'</div>'
  107. +'<div>'
  108. +'<div class="left-yuan cb-333333"></div>'
  109. +'<div class="left-status c-333333 ml10 f-fs14">预约医院:'+data.orgName+'</div>'
  110. +'</div>'
  111. +'<div>'
  112. +'<div class="left-yuan cb-333333"></div>'
  113. +'<div class="left-status c-333333 ml10 f-fs14">就诊时间:'+data.startTime+'</div>'
  114. +'</div>'
  115. +'</div>'
  116. +'</div>'
  117. +'</li>';
  118. }
  119. $(".c-list").append(appoHtml);
  120. $(".main").show();
  121. $("#footer").show();
  122. }
  123. var updatePullUpText= function(scroller,list) {
  124. var $wrap = $(scroller.wrapper),
  125. $pullupLabel = $wrap.find('.pullUpLabel');
  126. $(".pullUp").removeClass("loading");
  127. if(!list || !list.length) {
  128. $pullupLabel.text('没有更多');
  129. } else {
  130. $pullupLabel.text('上拉加载更多');
  131. }
  132. scroller.on('refresh',function() {
  133. if(!list || !list.length) {
  134. $pullupLabel.text('没有更多');
  135. } else {
  136. $pullupLabel.text('上拉加载更多');
  137. }
  138. });
  139. }
  140. }
  141. window.addEventListener('update', function(e) {
  142. queryInit();
  143. });