immune-appointment.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. var d = dialog({contentType:'load', skin:'bk-popup'});
  2. var pagetype = 48;
  3. var barCode;
  4. $(function(){
  5. checkUserAgent();
  6. getImmuneMembers();
  7. bindEvents();
  8. })
  9. function getImmuneMembers(){
  10. var data = {};
  11. sendPost("patient/family/members", data, "json", "get", queryListFailed, queryAppoListSuccesss);
  12. }
  13. function queryAppoListSuccesss(res){
  14. if (res.status == 200) {
  15. barCode = "";
  16. if (res.data.immunemembers.length > 0) {
  17. showMember(res);
  18. }
  19. if(res.data.immunemembers.length == 0){
  20. $('#wrapper2').css('top','0px');
  21. d.close();
  22. $(".main").hide();
  23. $(".div-no-info").show();
  24. }
  25. }else{
  26. //非200则为失败
  27. queryListFailed(res);
  28. }
  29. }
  30. function queryListFailed(res) {
  31. if (res && res.msg) {
  32. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  33. } else {
  34. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载家庭成员失败'}).show();
  35. }
  36. }
  37. function showMember(res){
  38. var html='',
  39. data=res.data.immunemembers;
  40. for(var i=0;i<data.length;i++){
  41. //"relation": 1//---1父亲 2母亲 3老公 4老婆 5儿子 6女儿 7其他
  42. if(data[i].relation==5){
  43. data[i].familyRelationName = '儿子'
  44. }else if(data[i].relation==6){
  45. data[i].familyRelationName = '女儿'
  46. }else{
  47. data[i].familyRelationName = '其他'
  48. }
  49. html = html + '<div class="mui-control-item" data-code="'+data[i].barcode+'" data-name="'+data[i].name+'" style="display: inline-block;margin-right: 15px;-webkit-user-select: none;vertical-align: middle;text-align: center;">\
  50. <img style="width: 40px;height: 40px;border-radius: 50%;overflow: hidden;border:solid 1px #dcdcdc;" src="../images/youer_moren_img.png"/>\
  51. <div class="name" style="font-size: 12px;color: #333;line-height: 20px;">'+data[i].name+'('+data[i].familyRelationName+')</div></div>'
  52. }
  53. html = '<div class="mui-scroll-wrapper family-member" style="position: absolute;z-index: 999;top: 0;bottom: 0;left: 0;overflow: hidden;width: 100%;height: 90px;background-color:#f3f3f3;padding-left: 15px;padding-top: 7px;border-bottom:solid 1px #dcdcdc;box-sizing: border-box;">\
  54. <div class="mui-scroll" style="position: absolute;width: auto;z-index: 99;white-space: nowrap;-webkit-transform: translateZ(0);transform: translateZ(0);">'+html+'</div></div>';
  55. $('#memberContainer').append(html);
  56. setTimeout(function(){
  57. addEvent();
  58. },200)
  59. initData();
  60. }
  61. function active(one){
  62. one.find('img').css({width: '55px',height: '55px'});
  63. one.find('.name').css({'font-size': '14px','line-height':'23px'});
  64. }
  65. function addEvent(){
  66. mui('.family-member').scroll({
  67. scrollY: false, //是否竖向滚动
  68. scrollX: true, //是否横向滚动
  69. });
  70. $('#memberContainer').on('tap','.mui-control-item',function(){
  71. var $this = $(this),
  72. $code = $this.data('code');
  73. barCode = $code;
  74. $('.mui-control-item').find('img').css({width: '40px',height: '40px'});
  75. $('.mui-control-item').find('.name').css({'font-size': '12px','line-height':'20px'});
  76. active($this);
  77. initData();
  78. })
  79. }
  80. function initData(){
  81. $(".c-list").html("");
  82. pageIndex = 1;
  83. getMyAppo();
  84. }
  85. function getMyAppo(){
  86. d.show();
  87. var data={};
  88. if(barCode==""){
  89. var $ul = $('#memberContainer').find('.mui-control-item');
  90. barCode = $ul.eq(0).data('code')
  91. if(barCode){
  92. active($ul.eq(0));
  93. }
  94. }
  95. if(barCode){
  96. $('#wrapper2').css('top','90px');
  97. $('.div-no-info').css('padding-top','150px');
  98. $(".main").show();
  99. $(".div-no-info").hide();
  100. data.BarCode = barCode;
  101. sendPost('/patient/guahao/imm/GetResImmuneListWithBarCode', data, 'json', 'get', getListFail, successFun);
  102. }else{
  103. $('#wrapper2').css('top','0px');
  104. d.close();
  105. $(".main").hide();
  106. $(".div-no-info").show();
  107. }
  108. }
  109. function successFun(res){
  110. if(res.status==200){
  111. if(res.data&&res.data.length>0){
  112. pageIndex=pageIndex+1;
  113. appendMyAppo(res.data);
  114. }else{
  115. if(pageIndex==1){
  116. $(".main").hide();
  117. $(".div-no-info").show();
  118. $("#footer").show();
  119. }else{
  120. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'无更多数据!',bottom:true}).show();
  121. }
  122. d.close();
  123. }
  124. }else{
  125. getListFail(res);
  126. }
  127. }
  128. function getListFail(res){
  129. d.close();
  130. if (res && res.msg) {
  131. if((res.msg).indexOf("SOAP")>=0){
  132. dialog({contentType:'tipsbox', skin:'bk-popup' , content:"医院接口访问异常,请刷新后重试!",bottom:true}).show();
  133. return false;
  134. }
  135. dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg,bottom:true}).show();
  136. } else {
  137. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'加载失败',bottom:true}).show();
  138. }
  139. }
  140. function appendMyAppo(dataList){
  141. var appoHtml ="";
  142. appoHtml = template("doctor_list_tmp", {list:dataList});
  143. $(".c-list").append(appoHtml);
  144. setTimeout(function(){
  145. scroller1.myScroll.refresh();
  146. },500)
  147. d.close();
  148. $(".main").show();
  149. $("#footer").show();
  150. }
  151. function bindEvents(){
  152. $(".c-list").on("click",".n-list-li,.n-list-content",function(event){
  153. var parentLi = $(this).closest("li");
  154. var id = parentLi.attr("data-id");
  155. var guahaoTime = parentLi.attr("guahao-time");
  156. var jiuzhenTime = parentLi.attr("jiuzhen-time");
  157. var jiezhongHospital = parentLi.attr("jiezhong-hospital");
  158. var jiuzhenName = parentLi.attr("jiuzhen-name");
  159. var idCard = parentLi.attr("id-card");
  160. var hospitalCard = parentLi.attr("hospital-card");
  161. var dataPhone = parentLi.attr("data-phone");
  162. var dataStatus = parentLi.attr("data-status");
  163. var SectionType = parentLi.attr("Section-type");
  164. var hospitalId = parentLi.attr("hospital-id");
  165. location.href = "detail-immune-appointment.html?barCode="+id+"&guahaoTime="+guahaoTime
  166. +"&jiuzhenTime="+jiuzhenTime+"&jiezhongHospital="+jiezhongHospital+"&jiuzhenName="+jiuzhenName+"&idCard="+idCard
  167. +"&hospitalCard="+hospitalCard+"&dataPhone="+dataPhone+"&dataStatus="+dataStatus+"&SectionType="+SectionType+"&hospitalId="+hospitalId;
  168. }).on("click",".div-again",function(){
  169. var parentLi = $(this).closest("li");
  170. var hospitalId = parentLi.attr("hospital-id");
  171. location.href = "immune-date.html?hospitalId="+hospitalId;
  172. })
  173. $(".div-add-btn").on("click",function(){
  174. location.href = "appointment-register.html";
  175. })
  176. }
  177. //下拉刷新
  178. function pullDownAction(theScrollerTemp) {
  179. // $(".main").hide();
  180. // $("#footer").hide();
  181. // $(".pullDown").show();
  182. // initData();
  183. // setTimeout(function () {
  184. // $(".pullDown").hide();
  185. // }, 1000);
  186. }
  187. //将scroller1的初始化代码放到外面来,不然从微信授权重定向过来这个页面的时候,
  188. //iscroll-pull-up-down 里监听的window的load方法不会触发,导致scroller初始化代码没有执行
  189. var scroller1 = new IScrollPullUpDown('wrapper2',{
  190. probeType:2,
  191. bounceTime: 250,
  192. bounceEasing: 'quadratic',
  193. mouseWheel:false,
  194. scrollbars:true,
  195. fadeScrollbars:true,
  196. click:true,
  197. interactiveScrollbars:false
  198. },pullDownAction,null);