doctor-index.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. var d = dialog({
  2. contentType: 'load',
  3. skin: 'bk-popup'
  4. });
  5. var userAgent = localStorage.getItem(agentName);
  6. if(userAgent){
  7. userAgent = JSON.parse(userAgent);
  8. }
  9. var request = GetRequest(),
  10. code = request.id,
  11. renew = request.renew;
  12. var doctorName = "";
  13. $(function() {
  14. getDocInfo();
  15. });
  16. function getDocInfo(){
  17. d.show();
  18. var url = "family_contract/homepage/homepage",
  19. params = {doctor: code};
  20. // url2 = "patient/family_contract/getPatientSign",
  21. // params2 = {homePageDoctorCode: code, invitePatientCode: userAgent.uid};
  22. sendPost(url, params, 'json', 'post', queryFailed, querySuccess);
  23. sendPost("patient/consult/evaluate/doctor/label", params, 'json', 'get', queryFailed, success2);
  24. // getReqPromises();
  25. }
  26. function success2(res) {
  27. var html='';
  28. if(res.list.length > 0){
  29. $.each(res.list, function(i,v) {
  30. html += '<li class="one">'+v.content+'</li>';
  31. });
  32. }else{
  33. html = '<span>暂无标签</span>';
  34. }
  35. $('#tag_group').append(html);
  36. d.close();
  37. }
  38. function queryFailed(res) {
  39. d.close();
  40. if(res && res.msg) {
  41. dialog({
  42. contentType: 'tipsbox',
  43. skin: 'bk-popup',
  44. content: res.msg
  45. }).show();
  46. } else {
  47. dialog({
  48. contentType: 'tipsbox',
  49. skin: 'bk-popup',
  50. content: '加载失败'
  51. }).show();
  52. }
  53. }
  54. function querySuccess(res) {
  55. if(res.status == 200){
  56. d.close();
  57. var data = res.data;
  58. doctorName = res.data.name;
  59. $(".doc-photo").attr("src", getImgUrl(data.photo));
  60. $("#docName").text(data.name);
  61. $("#docJob").text(data.jobName);
  62. $("#docHospital").text(data.hospital);
  63. $("#intro").text(data.intro);
  64. $("#expertise").text(data.expertise);
  65. if(data.evaluateScore == 0){
  66. $("#docScore").text('暂无评分');
  67. }else{
  68. $("#docScore").text(data.evaluateScore);
  69. }
  70. //判断签约状态
  71. var sign = res.data.sign;
  72. if(sign == 0) { // 待签约
  73. $('#btnSign').show();
  74. }
  75. d.close();
  76. } else {
  77. queryFailed(res);
  78. }
  79. }
  80. function cancelSign() {
  81. var url = 'patient/family_contract/unsign',
  82. msg = '您确定取消和' + doctorName + '医生的签约申请吗?';
  83. if(renew){
  84. url = 'patient/family_contract/unsignRenew';
  85. msg = '您确定取消和' + doctorName + '医生的续签申请吗?'
  86. }
  87. dialog({
  88. content: msg,
  89. ok: function() {
  90. d.showModal();
  91. var data = {};
  92. var userAgent = localStorage.getItem(agentName);
  93. data.patientCode = JSON.parse(userAgent).represented?JSON.parse(userAgent).represented:JSON.parse(userAgent).uid;
  94. data.doctor = code;
  95. sendPost(url , data, 'json', 'post', submitFailed, submitSuccess);
  96. },
  97. cancel: function() {
  98. return;
  99. }
  100. }).showModal();
  101. }
  102. function submitFailed(res) {
  103. d1.close();
  104. if(res && res.msg) {
  105. dialog({
  106. contentType: 'tipsbox',
  107. skin: 'bk-popup',
  108. content: res.msg
  109. }).show();
  110. } else {
  111. dialog({
  112. contentType: 'tipsbox',
  113. skin: 'bk-popup',
  114. content: '操作失败'
  115. }).show();
  116. }
  117. }
  118. function submitSuccess(res) {
  119. if(res.status == 200) {
  120. d.close();
  121. dialog({
  122. content: '您已成功取消了与'+doctorName+'医生的签约申请,是否需要选择其他医生签约?',
  123. okValue:'选择其他医生',
  124. ok: function() {
  125. window.location.href = "select-doctor.html";
  126. },
  127. cancelValue: "不了,谢谢",
  128. cancel: function(){
  129. history.go(-1);
  130. }
  131. }).showModal();
  132. } else {
  133. submitFailed(res);
  134. }
  135. }