focused-doctor.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 .c-border-radius-l", function(){
  64. var doctorCode = $(this).parent("li").attr("data-code");
  65. window.location.href = "doctor-homepage.html?doctor="+doctorCode;
  66. })
  67. $("#docList").on("tap", "li .zixun", function(){
  68. var doctorCode = $(this).parent("li").attr("data-code");
  69. isdetailfull(doctorCode)
  70. })
  71. }
  72. function getTemplateHelper(){
  73. template.helper("getImgUrl", function(str){
  74. return getImgUrl(str);
  75. });
  76. }
  77. function initScroller(){
  78. //阻尼系数
  79. var deceleration = mui.os.ios?0.003:0.0009;
  80. mui('.mui-scroll-wrapper').scroll({
  81. bounce: false,
  82. indicators: true, //是否显示滚动条
  83. deceleration:deceleration
  84. });
  85. mui.ready(function() {
  86. mui(".mui-scroll-wrapper").pullRefresh({
  87. down:{
  88. callback: function(){
  89. getDoctorList(true);
  90. this.refresh(true);
  91. }
  92. },
  93. up: {
  94. callback: function() {
  95. var self = this;
  96. setTimeout(function() {
  97. getDoctorList(false);
  98. //self.endPullupToRefresh();
  99. }, 1000);
  100. }
  101. }
  102. });
  103. });
  104. }
  105. //请求失败处理事件
  106. function queryFailed(res, message){
  107. d.close();
  108. if(message){
  109. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content: message}).show();
  110. }else{
  111. if (res && res.msg) {
  112. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  113. } else {
  114. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show();
  115. }
  116. }
  117. }
  118. function isdetailfull(doctorCode){
  119. d.show();
  120. var reqParams = [{
  121. url: "patient/baseinfo",
  122. data: {},
  123. reqType: 'post'
  124. }]
  125. getReqPromises(reqParams).then(function(ress){
  126. d.close();
  127. if (ress[0].status == 200) {
  128. if(ress[0].data.label){
  129. checkDocInWork(doctorCode)
  130. }else{
  131. dialog({
  132. content: '请完善您的资料',
  133. okValue:'前往完善',
  134. ok: function (){
  135. window.location.href = "../../grzx/html/my-detail.html";
  136. // window.location.href = "../../grzx/html/updateService.html?doctor="+doctorCode;
  137. },
  138. cancelValue: '暂不咨询',
  139. cancel: function () {
  140. }
  141. }).showModal();
  142. }
  143. }
  144. });
  145. }
  146. //获取签约医生的工作时间
  147. function checkDocInWork(doctor){
  148. var url = 'patient/consult/isDoctorWorkWhenconsult',
  149. params = {
  150. doctor: doctor
  151. };
  152. sendPost(url, params, 'json', 'post', queryFailed, function(res){
  153. $("#isFocus").removeClass("disabled");
  154. if(res.status == 200){
  155. d.close();
  156. // data:0-医生不接受咨询/1-医生当前接受咨询/2-全科医生和健管师当前都不在工作时间/3-全科医生当前不在工作时间/4-健管师当前不在工作时间 健管师当前不在工作时间
  157. if(!(res.data == "1")){
  158. dialog({
  159. content: '您好,由于您关注的医生工作繁忙,设置了每日回复咨询的时间段,所以,在该时间段外的时间,您的咨询将不会马上获得医生的回复。',
  160. okValue:'查看医生工作时间',
  161. ok: function (){
  162. window.location.href = "doctor-work-hours.html?doctor=" + doctor;
  163. },
  164. cancelValue: '继续新增咨询',
  165. cancel: function () {
  166. window.location.href = "add-consult.html?doctorCode="+doctor;
  167. }
  168. }).showModal();
  169. }else{
  170. //跳转到新增咨询页面
  171. window.location.href = "add-consult.html?doctorCode="+doctor;
  172. }
  173. }else{
  174. queryFailed(res);
  175. }
  176. });
  177. }