disease-community.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. var selectKey = 0 ;
  2. var selectName="";
  3. var d = dialog({contentType:'load', skin:'bk-popup'});
  4. var id = 0;
  5. var pageSize = 10;
  6. var pagetype=4;
  7. var status = 0;
  8. var tab_s =0;
  9. var scroller1;
  10. Request = GetRequest();
  11. var openid = Request["openid"];
  12. var tabType = Request['type'];
  13. //下拉刷新
  14. function pullDownAction(theScrollerTemp) {
  15. d.show();
  16. setTimeout(function () {
  17. $("#publicul").html("");
  18. id=0;
  19. fillList();
  20. }, 100);
  21. }
  22. //上拉加载数据
  23. function pullUpAction(theScrollerTemp) {
  24. d.show();
  25. setTimeout(function () {
  26. fillList();
  27. }, 100);
  28. }
  29. appendFamilyMember($('#memberContainer'),function(){
  30. id=0;
  31. $("#publicul").empty();
  32. selectKey = 0;
  33. selectName = '全部';
  34. $('.div-type').html(selectName);
  35. fillList();
  36. },function(){
  37. //判断有授权家人,修改样式
  38. if($('#memberContainer').is(':hidden')){
  39. $('#wrapper').css('top','41px');
  40. }else{
  41. $('#wrapper').css('top','130px');
  42. $('.div-no-info').css('padding-top','200px');
  43. $('.div-condition').css('top','90px');
  44. }
  45. });
  46. var userAgent = window.localStorage.getItem(agentName);
  47. checkUserAgent();
  48. $(function(){
  49. scroller1 = new IScrollPullUpDown('wrapper',{
  50. probeType:2,
  51. bounceTime: 250,
  52. bounceEasing: 'quadratic',
  53. mouseWheel:false,
  54. scrollbars:true,
  55. click:true,
  56. fadeScrollbars:true,
  57. interactiveScrollbars:false
  58. },pullDownAction,pullUpAction);
  59. //选择全部
  60. $('.div-type').mobiscroll({
  61. theme: 'ios',
  62. lang: 'zh',
  63. formatValue: function(d) {
  64. return d.join(',');
  65. },
  66. customWheels: true,
  67. wheels: [
  68. [{
  69. keys: ['0', '1', '2'],
  70. values: ['全部', '高血压', '糖尿病']
  71. }]
  72. ],
  73. onSelect: function(valueText, inst) {
  74. var dd = eval("[" + valueText + "]");
  75. $('.div-type').html(dd[0].values);
  76. selectKey = dd[0].keys;
  77. selectName = dd[0].values;
  78. //公共咨询
  79. if(tab_s==0){
  80. id=0;
  81. $("#publicul").html("");
  82. fillList();
  83. }
  84. //病友圈
  85. if(tab_s==1){
  86. id=0;
  87. $("#patinetsul").html("");
  88. fillList2();
  89. }
  90. }
  91. });
  92. bindEvents();
  93. var diseaseType = "";
  94. setTimeout(function(){
  95. if(diseaseType){
  96. tabType = diseaseType;
  97. }
  98. if(tabType==2){
  99. $("#patientsLi").click();
  100. }else{
  101. fillList();
  102. }
  103. },200);
  104. })
  105. function bindEvents() {
  106. //点击新增事件
  107. $(".timper-addfix").click(function(){
  108. window.location.href ="public-consult-add.html?openid="+openid;
  109. });
  110. //标签切换
  111. $(".pt-tab li").click(function(){
  112. var tabid = $(this).attr("id");
  113. $(".pt-tab li").removeClass("hit");
  114. $(this).addClass("hit");
  115. if(tabid=="publicLi"){
  116. window.localStorage.setItem("diseaseType","1");
  117. id=0;
  118. tab_s=0;
  119. $("#publicul").show();
  120. $("#patinetsList").hide();
  121. $("#publicul").html("");
  122. fillList();
  123. }
  124. })
  125. }
  126. function fillList() {
  127. var data = {};
  128. data.id = id;
  129. data.pagesize = pageSize;
  130. var dis = selectKey;
  131. if(dis&&dis!=0) data.disease = dis;
  132. var userAgent = window.localStorage.getItem(agentName);
  133. $.ajax(server + "patient/consult/public/list", {
  134. data: data,
  135. type: 'POST',
  136. dataType: 'json',
  137. beforeSend: function(request) {
  138. request.setRequestHeader("userAgent", userAgent);
  139. },
  140. error: function(res) {
  141. d.close();
  142. if(res.status == 999 || res.status == 998 || res.status == 997){
  143. loginUrl(res.status);
  144. return;
  145. }
  146. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show();
  147. },
  148. success: function(res) {
  149. if(res.status == 999 || res.status == 998 || res.status == 997){
  150. loginUrl(res.status);
  151. }
  152. else if (res.status == 200) {
  153. if (res.list.length > 0) {
  154. var list = res.list;
  155. var $list = $("#publicul");
  156. id=res.list[list.length-1].id;
  157. $("#nopubliclist").hide();
  158. $('#publicul').show();
  159. for (var i = 0; i < list.length; i++) {
  160. var consultCode = list[i].consult;
  161. var diseaseName = list[i].diseaseName;
  162. var photo = list[i].photo;
  163. if(!photo){
  164. photo = "../../../images/p-default.png";
  165. }
  166. if(!diseaseName) diseaseName = "";
  167. var content = '<li data-code="'+consultCode+'">'+
  168. '<div class="div-title">【'+
  169. list[i].diseaseName+'】'+list[i].title+
  170. '</div>' +
  171. '<div class="div-content">'+
  172. list[i].content+
  173. '</div>'+
  174. '<div class="div-remark-info">'+
  175. '<div class="n-avatar-l img-round pr10">'+
  176. '<img src="'+getImgUrl(photo)+'">'+
  177. '</div>'+
  178. '<div class="lab-user-name">'+list[i].name+'</div>'+
  179. '<div class="lab-time">'+list[i].czrq.substring(0,19)+'</div>'+
  180. '<div class="div-right">'+
  181. '<img src="../images/huifu_icon.png"/>'+
  182. '&ensp;<label class="lab-count">'+list[i].amount+'</label>'+
  183. '</div>'+
  184. '</div>'+
  185. '</li>';
  186. $list.append(content);
  187. }
  188. $("#publicul li").on("tap",function(){
  189. var code = this.getAttribute("data-code");
  190. window.open("public-consult-detail.html?code=" + code);
  191. })
  192. scroller1.myScroll.refresh();
  193. } else {
  194. if(id==0){
  195. $("#nopubliclist").show();
  196. $('#publicul').hide();
  197. }else{
  198. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'无更多数据!'}).show();
  199. }
  200. }
  201. d.close();
  202. } else {
  203. d.close();
  204. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show();
  205. }
  206. }
  207. });
  208. }
  209. function publicdetail(code){
  210. window.open("public-consult-detail.html?code=" + code);
  211. }