doctor-guidance.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. var data = {};
  88. data.id = id;
  89. data.pagesize = pageSize;
  90. sendPost("patient/health/guidance/list", data, "json", "post", queryListFailed, queryAppoListSuccess);
  91. }
  92. function queryListFailed() {
  93. d.close();
  94. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'});
  95. }
  96. function queryAppoListSuccess(res){
  97. if (res.status == 200) {
  98. if (res.list.length > 0) {
  99. var list = res.list;
  100. var html=''
  101. for (var i = 0; i < list.length; i++){
  102. id = list[i].id;
  103. var content1 = list[i].content;
  104. var name = list[i].name;
  105. var createTime = list[i].createTime.substring(0,16);
  106. var photo = list[i].photo;
  107. var docType=list[i].level;
  108. var job = "健管师";
  109. if(docType==1){
  110. job = "专科医生";
  111. }if(docType==2){
  112. job = "全科医生";
  113. }
  114. if(photo == undefined || photo == null || photo == ""){
  115. photo = "../../../images/d-default.png";
  116. }
  117. var newHtml = "";
  118. if(list[i].readStatus == 0){ //readStatus: 0未读 1已读
  119. newHtml = '<div class="icon-news"></div>';
  120. }
  121. var content = '<li><div class="div-date">'+createTime+'</div>'+
  122. '<div class="n-list dr-item c-border" data-id="'+id+'" data-photo="'+photo+'">'+
  123. '<div class="n-list-li">'+
  124. '<div class="n-list-key">'+
  125. '<div class="div-title">健康指导</div><div class="n-avatar-l img-round">'+
  126. '<img src="'+getImgUrl(photo)+'">'+
  127. '</div>'+
  128. '<div class="div-name"><span class="span-name">'+name+'</span></div>'+
  129. '</div>'+
  130. '<div class="div-list-info pl10" >'+
  131. content1+
  132. '</div>'+
  133. newHtml+
  134. '</div>'+
  135. '<div class="list-area list-arrow-r">'+
  136. '<div class="c-list-info">'+
  137. '<p>点击查看</p>'+
  138. '</div>'+
  139. '</div>'+
  140. '</div></li>';
  141. html += content;
  142. }
  143. if(iscrollState == 'down'){
  144. $('#ul_guidance').empty().append(html);
  145. setTimeout(function(){
  146. mui('#wrapper').pullRefresh().endPulldownToRefresh(false);
  147. mui('#wrapper').pullRefresh().enablePullupToRefresh();//重置
  148. },1000)
  149. }else{
  150. $('#ul_guidance').append(html);
  151. if(list.length < pageSize){
  152. mui('#wrapper').pullRefresh().endPullupToRefresh(true);
  153. }else{
  154. mui('#wrapper').pullRefresh().endPullupToRefresh(false);
  155. }
  156. }
  157. } else {
  158. if(id!=0){
  159. setTimeout(function(){
  160. mui('#wrapper').pullRefresh().endPullupToRefresh(true);
  161. },1000)
  162. }else{
  163. //显示无数据的图片
  164. $(".main").hide();
  165. $("#read_all").hide();
  166. $(".div-no-info").show();
  167. mui('#wrapper').pullRefresh().enablePullupToRefresh();
  168. }
  169. }
  170. d.close()
  171. } else {
  172. queryListFailed()
  173. }
  174. }