guidance-detail_old.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. Request = GetRequest();
  2. var d = dialog({contentType:'load', skin:'bk-popup'});
  3. var id = Request["id"];
  4. var photo = Request["photo"];
  5. var toUser = Request["toUser"];
  6. var openid = Request["openid"];
  7. var pagetype=25;
  8. var type;
  9. var doctorCode;
  10. var userAgent = window.localStorage.getItem(agentName);
  11. var scroller1 = new IScrollPullUpDown('wrapper',{
  12. probeType:2,
  13. bounceTime: 250,
  14. bounceEasing: 'quadratic',
  15. mouseWheel:false,
  16. click:true,
  17. scrollbars:true,
  18. fadeScrollbars:true,
  19. interactiveScrollbars:false
  20. },null,null);
  21. $(function(){
  22. if(!userAgent) {
  23. localStorage.setItem("toUser",toUser);
  24. localStorage.setItem("id",id);
  25. window.location.href = server + "wx/html/home/html/login.html?openid=" + openid+"&type="+pagetype;
  26. return false;
  27. }
  28. if(toUser){
  29. var userInfo = JSON.parse(userAgent);
  30. if(userInfo && toUser!=userInfo.uid){
  31. var toName = decodeURIComponent(Request["toName"]);
  32. dialog({
  33. content:'对不起,该消息是发送给'+toName+'的,如需查看,请切换'+toName+'账号登录',
  34. okValue:'切换账号',
  35. ok: function() {
  36. window.localStorage.setItem(pageName, JSON.stringify({pageurl: location.href}))
  37. window.location.href = "../../grzx/html/change-login.html?type=0&openid="+ Request["openid"];
  38. },
  39. cancelValue: '我不看了',
  40. cancel: function () {
  41. wx.closeWindow();
  42. }
  43. }).showModal();
  44. return false;
  45. }
  46. }
  47. // 判断是否登录
  48. checkUserAgent();
  49. // 点击咨询详情
  50. $("#detail").on("tap", function () {
  51. querySignType();
  52. // window.location.href = "add-consult.html?id=" + id + "&type=0&doctorCode=" + doctorCode;
  53. });
  54. });
  55. // 禁止拖动
  56. document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
  57. /**
  58. * 界面数据初始化
  59. */
  60. function queryInit() {
  61. d.show();
  62. var data = {};
  63. data.id = id;
  64. sendPost("patient/health/guidance/id", data, "json", "post", queryListFailed, queryAppoListSuccesss);
  65. }
  66. function queryListFailed(res) {
  67. d.close();
  68. if (res && res.msg) {
  69. var d1 = dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg});
  70. } else {
  71. var d2 = dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'});
  72. }
  73. }
  74. function queryAppoListSuccesss(res) {
  75. if (res.status == 200) {
  76. var data = res.data;
  77. if (data) {
  78. doctorCode = data.doctor;
  79. // type = data.del;
  80. window.localStorage.setItem("guidance",data.content);
  81. var $detail = document.querySelector("#detailBox");
  82. var $li = document.createElement("li");
  83. var content = '<div class="div-date">'+data.czrq+'</div>'+
  84. '<ul class="c-list list-tool">'+
  85. '<li>'+
  86. '<div class="c-list-key">'+
  87. '<img src="'+ getImgUrl(data.photo)+'" width="34" height="34">'+
  88. '</div>'+
  89. '<div class="c-list-info">'+
  90. '<div class="talk" style="word-wrap:break-word;">'+
  91. '<p>'+data.content+'</p>'+
  92. '</div>'+
  93. '</div>'+
  94. '</li>'+
  95. '</ul>';
  96. $li.innerHTML = content;
  97. $detail.appendChild($li);
  98. }
  99. d.close();
  100. scroller1.myScroll.refresh();
  101. } else {
  102. //非200则为失败
  103. queryListFailed(res);
  104. }
  105. }
  106. function querySignType(){
  107. d.show();
  108. sendPost('patient/sign_doctors', {}, 'json', 'post', querySignTypeFailed, querySignTypeSuccess);
  109. }
  110. function querySignTypeFailed(res) {
  111. d.close();
  112. if (res && res.msg) {
  113. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  114. } else {
  115. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'获取咨询类型失败'}).show();
  116. }
  117. }
  118. function querySignTypeSuccess(data) {
  119. if (data.status == 200) {
  120. var doctors = data.familyDoctors;
  121. var docInfo,docQkInfo;
  122. $.each(doctors, function(i, v) {
  123. if(v.teamlevel){
  124. if(v.teamlevel == 3){
  125. docInfo = v;
  126. }
  127. if(v.teamlevel == 2){
  128. docQkInfo = v;
  129. }
  130. }else{
  131. if(v.level == 3){
  132. docInfo = v;
  133. }
  134. if(v.level == 2){
  135. docQkInfo = v;
  136. }
  137. }
  138. });
  139. if(!docInfo){
  140. docInfo = docQkInfo;
  141. }
  142. sendPost('patient/consult/is_consult_unfinished', {doctor: docInfo ? docInfo.code : docQkInfo.code}, 'json', 'post',
  143. function(res){
  144. d.close();
  145. if (res && res.msg) {
  146. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  147. } else {
  148. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'获取是否存在咨询失败'}).show();
  149. }
  150. }, function(res){
  151. if(res.status == 200){
  152. if(res.data == ""){
  153. //不存在
  154. // window.location.href = "add-consult.html?id=" + id + "&type=0&doctorCode=" + doctorCode;
  155. checkDocInWork(0, doctorCode, id);
  156. } else {
  157. d.close();
  158. dialog({
  159. content: '十分抱歉,您与'+ docInfo.name +'医生还有<br/>未结束咨询,无法发起新的咨询',
  160. okValue:'前往查看',
  161. ok: function (){
  162. var userInfo = JSON.parse(userAgent);
  163. window.location.href = "../../yszx/html/consulting-doctor.html?consult=" + res.data +"&toUser="+userInfo.uid;
  164. },
  165. cancelValue: '我知道了',
  166. cancel: function () {
  167. return;
  168. }
  169. }).showModal();
  170. }
  171. } else {
  172. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  173. }
  174. }
  175. );
  176. } else {
  177. querySignTypeFailed(res);
  178. }
  179. }
  180. function checkDocInWork(type, doctor, id){
  181. sendPost('patient/consult/is_doctor_working', {doctor:doctor}, 'json', 'get', queryFailed, function(res){
  182. if(res.status==200){
  183. d.close();
  184. if(res.data==2){
  185. dialog({
  186. content: '您好,由于您的签约医生工作繁忙,设置了每日回复咨询的时间段,所以,在该时间段外的时间,您的咨询将不会马上获得医生的回复。',
  187. okValue:'查看医生工作时间',
  188. ok: function (){
  189. window.location.href = "../../yszx/html/doctor-work-hours.html?doctor=" + doctor;
  190. },
  191. cancelValue: '继续新增咨询',
  192. cancel: function () {
  193. window.location.href = "add-consult.html?id=" + id + "&type="+ type +"&doctorCode=" + doctor;
  194. }
  195. }).showModal();
  196. }else if(res.data==0){//医生不接受咨询
  197. dialog({
  198. content: '对不起,该医生暂时关闭了咨询功能,<br/>暂时无法咨询该医生',
  199. cancelValue: '我知道了',
  200. cancel: function () {
  201. wx.closeWindow();
  202. }
  203. }).showModal();
  204. }else{
  205. //三师咨询或家庭签约咨询,跳转到新增咨询页面
  206. window.location.href = "add-consult.html?id=" + id + "&type="+ type +"&doctorCode=" + doctor;
  207. }
  208. }else{
  209. queryFailed(res);
  210. }
  211. })
  212. }
  213. //查询失败
  214. function queryFailed(res) {
  215. d.close();
  216. if (res && res.msg) {
  217. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  218. } else {
  219. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'查询失败'}).show();
  220. }
  221. }