focused-doctor.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. // 验证居民信息是否完善
  14. checkBaseInfo()
  15. userAgent = JSON.parse(userAgent);
  16. initScroller();
  17. getDoctorList(true);
  18. bindEvents();
  19. getTemplateHelper();
  20. }
  21. function getDoctorList(isInit){
  22. d.show();
  23. if(isInit){
  24. page = 0;
  25. }
  26. var url = "/patient/concern/getConcernDoctors",
  27. params = {
  28. patient: userAgent.uid,
  29. page: page,
  30. pageSize: pageSize
  31. };
  32. sendPost(url, params, 'JSON', 'GET', queryFailed, function(res){
  33. if(res.status == 200){
  34. d.close();
  35. var list = res.data;
  36. if(list.length>0){
  37. page ++;
  38. var html = template("doctor_tmp", {list: list});
  39. if(isInit){
  40. $("#docList").empty().append(html);
  41. }else{
  42. $("#docList").append(html);
  43. }
  44. if(list.length < pageSize){
  45. mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true);
  46. }else{
  47. mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(false);
  48. }
  49. }else{
  50. if(isInit){
  51. $(".main").hide();
  52. $(".div-no-search-info").show();
  53. mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true);
  54. }else{
  55. mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true);
  56. }
  57. }
  58. }else{
  59. queryFailed(res);
  60. }
  61. })
  62. }
  63. function bindEvents(){
  64. //单个医生点击
  65. $("#docList").on("tap", "li .c-border-radius-l", function(){
  66. var doctorCode = $(this).parent("li").attr("data-code");
  67. window.location.href = "doctor-homepage.html?doctor="+doctorCode;
  68. })
  69. $("#docList").on("tap", "li .zixun", function(){
  70. var doctorCode = $(this).parent("li").attr("data-code");
  71. isdetailfull(doctorCode)
  72. })
  73. }
  74. function getTemplateHelper(){
  75. template.helper("getImgUrl", function(str){
  76. return getImgUrl(str);
  77. });
  78. }
  79. function initScroller(){
  80. //阻尼系数
  81. var deceleration = mui.os.ios?0.003:0.0009;
  82. mui('.mui-scroll-wrapper').scroll({
  83. bounce: false,
  84. indicators: true, //是否显示滚动条
  85. deceleration:deceleration
  86. });
  87. mui.ready(function() {
  88. mui(".mui-scroll-wrapper").pullRefresh({
  89. down:{
  90. callback: function(){
  91. getDoctorList(true);
  92. this.refresh(true);
  93. }
  94. },
  95. up: {
  96. callback: function() {
  97. var self = this;
  98. setTimeout(function() {
  99. getDoctorList(false);
  100. //self.endPullupToRefresh();
  101. }, 1000);
  102. }
  103. }
  104. });
  105. });
  106. }
  107. //请求失败处理事件
  108. function queryFailed(res, message){
  109. d.close();
  110. if(message){
  111. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content: message}).show();
  112. }else{
  113. if (res && res.msg) {
  114. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  115. } else {
  116. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show();
  117. }
  118. }
  119. }
  120. function isdetailfull(doctorCode){
  121. d.show();
  122. var reqParams = [{
  123. url: "patient/baseinfo",
  124. data: {},
  125. reqType: 'post'
  126. }]
  127. getReqPromises(reqParams).then(function(ress){
  128. d.close();
  129. if (ress[0].status == 200) {
  130. if(ress[0].data.label){
  131. checkDocInWork(doctorCode)
  132. }else{
  133. dialog({
  134. content: '请完善您的资料',
  135. okValue:'前往完善',
  136. ok: function (){
  137. window.location.href = "../../grzx/html/my-detail.html";
  138. // window.location.href = "../../grzx/html/updateService.html?doctor="+doctorCode;
  139. },
  140. cancelValue: '暂不咨询',
  141. cancel: function () {
  142. }
  143. }).showModal();
  144. }
  145. }
  146. });
  147. }
  148. //获取签约医生的工作时间
  149. function checkDocInWork(doctor){
  150. var url = 'patient/consult/isDoctorWorkWhenconsult',
  151. params = {
  152. doctor: doctor
  153. };
  154. sendPost(url, params, 'json', 'post', queryFailed, function(res){
  155. $("#isFocus").removeClass("disabled");
  156. if(res.status == 200){
  157. d.close();
  158. // data:0-医生不接受咨询/1-医生当前接受咨询/2-全科医生和健管师当前都不在工作时间/3-全科医生当前不在工作时间/4-健管师当前不在工作时间 健管师当前不在工作时间
  159. if(!(res.data == "1")){
  160. dialog({
  161. content: '您好,由于您关注的医生工作繁忙,设置了每日回复咨询的时间段,所以,在该时间段外的时间,您的咨询将不会马上获得医生的回复。',
  162. okValue:'查看医生工作时间',
  163. ok: function (){
  164. window.location.href = "doctor-work-hours.html?doctor=" + doctor;
  165. },
  166. cancelValue: '继续新增咨询',
  167. cancel: function () {
  168. window.location.href = "add-consult.html?doctorCode="+doctor;
  169. }
  170. }).showModal();
  171. }else{
  172. //跳转到新增咨询页面
  173. window.location.href = "add-consult.html?doctorCode="+doctor;
  174. }
  175. }else{
  176. queryFailed(res);
  177. }
  178. });
  179. }