focused-doctor.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. var d = dialog({contentType:'load', skin:'bk-popup'});
  2. var page = 0,
  3. pageSize = 10,
  4. userAgent = window.localStorage.getItem(agentName),
  5. pagetype = 2;
  6. // 获取链接带参
  7. var request = GetRequest(),
  8. deptId =request["deptId"] || null;
  9. $(function(){
  10. checkUserAgent();
  11. });
  12. function queryInit(){
  13. userAgent = JSON.parse(userAgent);
  14. initScroller();
  15. getDoctorList(true);
  16. bindEvents();
  17. getTemplateHelper();
  18. }
  19. function getDoctorList(isInit){
  20. d.show();
  21. if(isInit){
  22. page = 0;
  23. }
  24. var url = "/patient/concern/getConcernDoctors",
  25. params = {
  26. patient: userAgent.uid,
  27. page: page,
  28. pageSize: pageSize
  29. };
  30. sendPost(url, params, 'JSON', 'GET', queryFailed, function(res){
  31. if(res.status == 200){
  32. d.close();
  33. var list = res.data;
  34. if(list.length>0){
  35. page ++;
  36. var html = template("doctor_tmp", {list: list});
  37. if(isInit){
  38. $("#docList").empty().append(html);
  39. }else{
  40. $("#docList").append(html);
  41. }
  42. if(list.length < pageSize){
  43. mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true);
  44. }else{
  45. mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(false);
  46. }
  47. }else{
  48. if(isInit){
  49. $(".main").hide();
  50. $(".div-no-search-info").show();
  51. mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true);
  52. }else{
  53. mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true);
  54. }
  55. }
  56. }else{
  57. queryFailed(res);
  58. }
  59. })
  60. }
  61. function bindEvents(){
  62. //单个医生点击
  63. $("#docList").on("tap", "li", function(){
  64. var doctorCode = $(this).attr("data-code");
  65. window.location.href = "doctor-homepage.html?doctor="+doctorCode;
  66. })
  67. }
  68. function getTemplateHelper(){
  69. template.helper("getImgUrl", function(str){
  70. return getImgUrl(str);
  71. });
  72. }
  73. function initScroller(){
  74. //阻尼系数
  75. var deceleration = mui.os.ios?0.003:0.0009;
  76. mui('.mui-scroll-wrapper').scroll({
  77. bounce: false,
  78. indicators: true, //是否显示滚动条
  79. deceleration:deceleration
  80. });
  81. mui.ready(function() {
  82. mui(".mui-scroll-wrapper").pullRefresh({
  83. down:{
  84. callback: function(){
  85. getDoctorList(true);
  86. this.endPulldownToRefresh();
  87. }
  88. },
  89. up: {
  90. callback: function() {
  91. var self = this;
  92. setTimeout(function() {
  93. getDoctorList(false);
  94. // self.endPullupToRefresh();
  95. }, 1000);
  96. }
  97. }
  98. });
  99. });
  100. }
  101. //请求失败处理事件
  102. function queryFailed(res, message){
  103. d.close();
  104. if(message){
  105. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content: message}).show();
  106. }else{
  107. if (res && res.msg) {
  108. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  109. } else {
  110. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show();
  111. }
  112. }
  113. }