jiankangtijian.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. var d= dialog({contentType:'load', skin:'bk-popup'});
  2. var $eventListWrapper = $('#recent_event_list_wrap'),
  3. $eventList = $('#recent_event_list'),
  4. // 搜索无结果时显示
  5. $noResultWrap = $('#no_result_wrap');
  6. // 分页查询当前页数
  7. var curPage = 1,
  8. // iscroll 滚动条实例
  9. iscroller;
  10. var pagetype = 32;
  11. appendFamilyMember($('#memberContainer'),function(){
  12. queryInit();
  13. },function(){
  14. //判断有授权家人,修改样式
  15. if($('#memberContainer').is(':hidden')){
  16. $('#recent_event_scroller').css('top','0px');
  17. $('.no-result-img').css('margin-top','150px')
  18. }else{
  19. $('#recent_event_scroller').css('top','90px');
  20. }
  21. })
  22. template.helper("toJson", function(v, i) {
  23. return JSON.stringify(v);
  24. });
  25. // 初始化就诊事件列表
  26. var initEventList = function(list) {
  27. var html = template("recent_event_tmpl", {list: list})
  28. $eventList.append(html);
  29. },
  30. // 分页查询列表
  31. searchByPaging = function () {
  32. var userAgent = JSON.parse(window.localStorage.getItem(agentName));
  33. var url = "patient/archives/list_medical",
  34. curPage = 1,
  35. pagesize = 50,
  36. params = {
  37. pageIndex: curPage,
  38. pageSize: pagesize
  39. };
  40. getReqPromise(url,params,'','POST').then(function(res){
  41. if(!iscroller) {
  42. iscroller = initScroller($eventListWrapper,url);
  43. }
  44. if(res.status == 200) {
  45. curPage++;
  46. var list = res.list;
  47. if(!list|| !list.length) {
  48. $eventListWrapper.hide();
  49. $noResultWrap.show();
  50. } else {
  51. $noResultWrap.hide();
  52. $eventListWrapper.show();
  53. initEventList(list);
  54. }
  55. } else {
  56. dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg,bottom:true}).show();
  57. }
  58. iscroller.refresh();
  59. }).catch(function(e) {
  60. console && console.error(e)
  61. });
  62. },
  63. // 滚动条分页实例初始化
  64. initScroller = function($el,url,getData,pullUpAction) {
  65. var scroller = $el.initScroll({pullDown: false,pullUp: false});
  66. return scroller;
  67. },
  68. checkSignPromise = function (){
  69. d.show();
  70. return getReqPromise("patient/is_sign",{},'','POST').then(function(res) {
  71. d.close();
  72. if (res.status == 200) {
  73. // -1 未签约 0 待签约 1 已签约 2待解约
  74. var is_sign = res.data;
  75. if(is_sign > 0){
  76. return true;
  77. }else{
  78. return false;
  79. }
  80. } else {
  81. dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg,bottom:true}).show();
  82. }
  83. }).catch(function(e) {
  84. d.close();
  85. console && console.error(e);
  86. })
  87. },
  88. // 绑定页面事件
  89. bindEvents = function () {
  90. $eventList.on('click','li',function() {
  91. var data = JSON.parse($(this).attr("data-json"));
  92. checkSignPromise()
  93. .then(function(isSign) {
  94. if(isSign === true) {
  95. window.location.href = "jiankangtijianxiangqing.html?medicalNo="+data.medicalNo
  96. } else if(isSign === false) {
  97. dialog({
  98. title: '提示',
  99. content: '对不起,签约家庭医生之后才能查看健康档案!',
  100. okValue:'我要签约',
  101. ok: function (){
  102. window.location.href = "../../qygl/html/signing-doctors.html";
  103. },
  104. cancelValue: '了解签约',
  105. cancel: function () {
  106. window.location.href = "../../qygl/html/signing-share2.html";
  107. }
  108. }).showModal();
  109. }
  110. })
  111. });
  112. };
  113. function queryInit(){
  114. curPage = 1;
  115. $eventList.empty();
  116. Promise.resolve().then(function() {
  117. searchByPaging();
  118. bindEvents();
  119. }).catch(function(e) {
  120. console && console.error(e);
  121. });
  122. }
  123. $(function() {
  124. checkUserAgent();
  125. // 页面业务处理流程开始
  126. })