doctor-guidance.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. var d = dialog({contentType:'load', skin:'bk-popup'});
  2. var id = 0;
  3. var pageSize = 10;
  4. var generatedCount=0;
  5. var pagetype=3;
  6. var userAgent = window.localStorage.getItem(agentName);
  7. var iscrollState='';//判断滑动方向
  8. $(function(){
  9. // 判断是否登录
  10. checkUserAgent();
  11. // 点击咨询详情
  12. $("body").on("tap", ".n-list", function () {
  13. var id = $(this).data("id");
  14. var photo = $(this).data("photo");
  15. window.location.href = "guidance-detail.html?id=" + id;
  16. })
  17. //一键已读
  18. $("#read_all").on("tap", function(){
  19. d.show();
  20. sendPost("/patient/health/guidance/modifyStatus",{},'json','post', function(res){
  21. d.close();
  22. if (res && res.msg) {
  23. var d1 = dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg});
  24. } else {
  25. var d2 = dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'});
  26. }
  27. },
  28. function(res){
  29. if(res.status == 200){
  30. //隐藏所有的newicon
  31. $(".icon-news").hide();
  32. }
  33. d.close();
  34. })
  35. })
  36. mui.init({
  37. pullRefresh : {
  38. container:'#wrapper',
  39. down : {
  40. height:50,
  41. auto: false,
  42. contentdown : "下拉可以刷新",
  43. contentover : "释放立即刷新",
  44. contentrefresh : "正在刷新...",
  45. callback: function(){
  46. id = 0;
  47. iscrollState='down'
  48. queryInit()
  49. }
  50. },
  51. up : {
  52. height:50,
  53. contentinit: '',
  54. contentdown: '',
  55. contentrefresh : "正在加载...",
  56. contentnomore:'没有更多数据了',
  57. callback: function() {
  58. iscrollState='up'
  59. queryInit()
  60. }
  61. }
  62. }
  63. })
  64. })
  65. appendFamilyMember($('#memberContainer'),function(){
  66. $("#ul_guidance").empty();
  67. $(".div-no-info").hide();
  68. $(".main").show();
  69. $("#read_all").show();
  70. id=0;
  71. iscrollState='';
  72. mui('#wrapper').pullRefresh().refresh(true)
  73. queryInit();
  74. },function(){
  75. //判断有授权家人,修改样式
  76. if($('#memberContainer').is(':hidden')){
  77. $('#wrapper').css('top','0px');
  78. }else{
  79. $('#wrapper').css('top','90px');
  80. $('.div-no-info').css('padding-top','90px');
  81. }
  82. })
  83. /**
  84. * 界面数据初始化
  85. */
  86. function queryInit(){
  87. // 验证居民信息是否完善
  88. checkBaseInfo()
  89. var data = {};
  90. data.id = id;
  91. data.pagesize = pageSize;
  92. sendPost("patient/health/guidance/list", data, "json", "post", queryListFailed, queryAppoListSuccess);
  93. }
  94. function queryListFailed() {
  95. d.close();
  96. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'});
  97. }
  98. function queryAppoListSuccess(res){
  99. if (res.status == 200) {
  100. if (res.list.length > 0) {
  101. var list = res.list;
  102. var html=''
  103. for (var i = 0; i < list.length; i++){
  104. id = list[i].id;
  105. var content1 = list[i].content;
  106. var name = list[i].name;
  107. var createTime = list[i].createTime.substring(0,16);
  108. var photo = list[i].photo;
  109. var docType=list[i].level;
  110. var job = "健管师";
  111. if(docType==1){
  112. job = "专科医生";
  113. }if(docType==2){
  114. job = "全科医生";
  115. }
  116. if(photo == undefined || photo == null || photo == ""){
  117. photo = "../../../images/d-default.png";
  118. }
  119. var newHtml = "";
  120. if(list[i].readStatus == 0){ //readStatus: 0未读 1已读
  121. newHtml = '<div class="icon-news"></div>';
  122. }
  123. var content = '<li><div class="div-date">'+createTime+'</div>'+
  124. '<div class="n-list dr-item c-border" data-id="'+id+'" data-photo="'+photo+'">'+
  125. '<div class="n-list-li">'+
  126. '<div class="n-list-key">'+
  127. '<div class="div-title">健康指导</div><div class="n-avatar-l img-round">'+
  128. '<img src="'+getImgUrl(photo)+'">'+
  129. '</div>'+
  130. '<div class="div-name"><span class="span-name">'+name+'</span></div>'+
  131. '</div>'+
  132. '<div class="div-list-info pl10" >'+
  133. content1+
  134. '</div>'+
  135. newHtml+
  136. '</div>'+
  137. '<div class="list-area list-arrow-r">'+
  138. '<div class="c-list-info">'+
  139. '<p>点击查看</p>'+
  140. '</div>'+
  141. '</div>'+
  142. '</div></li>';
  143. html += content;
  144. }
  145. if(iscrollState == 'down'){
  146. $('#ul_guidance').empty().append(html);
  147. setTimeout(function(){
  148. mui('#wrapper').pullRefresh().endPulldownToRefresh(false);
  149. mui('#wrapper').pullRefresh().enablePullupToRefresh();//重置
  150. },1000)
  151. }else{
  152. $('#ul_guidance').append(html);
  153. if(list.length < pageSize){
  154. mui('#wrapper').pullRefresh().endPullupToRefresh(true);
  155. }else{
  156. mui('#wrapper').pullRefresh().endPullupToRefresh(false);
  157. }
  158. }
  159. } else {
  160. if(id!=0){
  161. setTimeout(function(){
  162. mui('#wrapper').pullRefresh().endPullupToRefresh(true);
  163. },1000)
  164. }else{
  165. //显示无数据的图片
  166. $(".main").hide();
  167. $("#read_all").hide();
  168. $(".div-no-info").show();
  169. mui('#wrapper').pullRefresh().enablePullupToRefresh();
  170. }
  171. }
  172. d.close()
  173. } else {
  174. queryListFailed()
  175. }
  176. }