choose-region.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. var d = dialog({contentType:'load', skin:'bk-popup'});
  2. var d1 = dialog({contentType:'load', skin:'bk-popup', content:'提交中...'});
  3. var pagetype = 7;
  4. var doctor = "";
  5. $(function (){
  6. checkUserAgent();
  7. })
  8. //判断是否有家庭签约信息
  9. function queryInit() {
  10. d.show();
  11. sendPost('patient/family_contract/checkOpenid', {}, 'json', 'post', queryFailed, openidSuccess2);
  12. }
  13. function queryFailed(res) {
  14. d.close();
  15. if (res && res.msg) {
  16. dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg}).show();
  17. } else {
  18. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'加载失败'}).show();
  19. }
  20. }
  21. //成功
  22. function openidSuccess2(res) {
  23. if (res.status == 200) {
  24. if(res.data == null || res.data == ""){
  25. $("#div-area").show();
  26. checkTeacter();
  27. }
  28. else{
  29. $("#div-doctorPage").show();
  30. doctor = res.data;
  31. queryDoctor();
  32. }
  33. } else {
  34. queryFailed(res);
  35. }
  36. }
  37. function closeWindow(){
  38. var Request = new Object();
  39. Request = GetRequest();
  40. var code = Request["code"];
  41. //从后台那边获取签名等信息
  42. var params = {};
  43. params.pageUrl = server + "wx/html/ssgg/html/choose-region.html?code=" + code + "&state=STATE";
  44. $.ajax(server + "weixin/getSign", {
  45. data: params,
  46. dataType: "json",
  47. type: "post",
  48. success: function(res){
  49. if (res.status == 200) {
  50. var t = res.data.timestamp;
  51. var noncestr = res.data.noncestr;
  52. var signature = res.data.signature;
  53. wx.config({
  54. //debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  55. appId: appId, // 必填,公众号的唯一标识
  56. timestamp: t, // 必填,生成签名的时间戳
  57. nonceStr: noncestr, // 必填,生成签名的随机串
  58. signature: signature,// 必填,签名,见附录1
  59. jsApiList: [
  60. 'closeWindow'
  61. ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
  62. });
  63. }
  64. }
  65. });
  66. wx.ready(function(){
  67. wx.closeWindow();
  68. });
  69. }
  70. //判断是否有三师信息
  71. function checkTeacter(){
  72. var data = {};
  73. sendPost('patient/teachers', data, 'json', 'post', queryFailed, querySuccess);
  74. }
  75. function querySuccess(res) {
  76. if (res.status == 200) {
  77. d.close();
  78. var list = res.data.list;
  79. if(list.length > 0){
  80. var doctor = "";
  81. var doctorName = "";
  82. for(var i=0; i<list.length; i++){
  83. var data = list[i];
  84. if(Number(data.type) == 2){
  85. doctor = data.code;
  86. doctorName = data.name;
  87. }
  88. }
  89. dialog({
  90. title:'提示',
  91. content:'您已存在三师签约,签约医生为' + doctorName + '医生,继续与' + doctorName + '医生签约家庭医生服务吗?',
  92. ok: function (){
  93. window.location.href = "doctor-home-page.html?doctor=" + doctor+"&isQr=false";
  94. }
  95. }).showModal();
  96. }
  97. } else if(res.status == 1 || res.status == 2){
  98. d.close();
  99. }
  100. else{
  101. queryFailed(res);
  102. }
  103. }
  104. function changeValue(name, code){
  105. window.location.href='hospital-list.html?areaName=' + encodeURI(name) + '&areaCode=' + code;
  106. }
  107. //获取家庭签约的医生信息
  108. function queryDoctor(){
  109. var data={};
  110. data.doctor = doctor;
  111. sendPost('patient/family_contract/homepage', data, 'json', 'post', queryFailed, querySuccess3);
  112. }
  113. function querySuccess3(res) {
  114. if (res.status == 200) {
  115. var name = res.data.name;
  116. var jobName = res.data.job;
  117. var hospitalName = res.data.hospital;
  118. var deptName = res.data.dept;
  119. var photo = getImgUrl(res.data.photo);
  120. var expertise = res.data.expertise;
  121. var introduce = res.data.intro;
  122. var sign = Number(res.data.sign);
  123. var group = Number(res.data.group);
  124. var url2 = "../../../images/d-default.png";
  125. if(photo != null && photo != ""){
  126. url2 = photo;
  127. }
  128. if(!jobName) jobName = "";
  129. if(!deptName) deptName = "";
  130. if(!expertise) expertise = "无";
  131. if(!introduce) introduce = "无";
  132. document.getElementById("photo").src = url2;
  133. document.getElementById("name").innerHTML = name;
  134. document.getElementById("jobName").innerHTML = jobName;
  135. document.getElementById("hospitalName").innerHTML = hospitalName;
  136. document.getElementById("deptName").innerHTML = deptName;
  137. document.getElementById("expertise").innerHTML = expertise;
  138. document.getElementById("introduce").innerHTML = introduce;
  139. if(group == 1){
  140. $("#ul-health").show();
  141. }else if(group == 2){
  142. $("#ul-disease").show();
  143. }else if(group == 3){
  144. $("#ul-sixfive").show();
  145. }else{
  146. $("#ul-common").show();
  147. }
  148. if(sign == 0){
  149. document.getElementById("btnSign").innerHTML ='<a onclick="cancelSign()" class="c-btn c-btn-E0A526 c-btn-full c-btn-radius c-f18">取消申请</a>';
  150. }
  151. else if(sign == 1){
  152. document.getElementById("btnSign").innerHTML ='<a onclick="overSign()" class="c-btn c-btn-E0A526 c-btn-full c-btn-radius c-f18">申请解约</a>';
  153. }
  154. else if(sign == -1){
  155. document.getElementById("btnSign").innerHTML ='<a onclick="startSign()" class="c-btn c-btn-4dcd70 c-btn-full c-btn-radius c-f18">申请签约</a>';
  156. $("#divAgree").hide();
  157. }
  158. else if(sign == 2){
  159. document.getElementById("btnSign").innerHTML = '<span class="c-f18" style="color: #E71F19;">您已申请了解约,流程审核中,请等待!!</span>';
  160. }
  161. else{
  162. document.getElementById("btnSign").innerHTML = '<span class="c-f18" style="color: #E71F19;">医生申请与您解约,流程审核中,请等待!!</span>';
  163. }
  164. d.close();
  165. }
  166. else{
  167. queryFailed(res);
  168. }
  169. }
  170. //申请签约
  171. function startSign(){
  172. var doctorName = encodeURI(document.getElementById("name").innerHTML);
  173. var hospitalName = encodeURI(document.getElementById("hospitalName").innerHTML);
  174. window.location.href = "sign-agreement.html?doctor=" + doctor + "&doctorName=" + doctorName + "&hospitalName=" + hospitalName;
  175. }
  176. function changeAgreement(){
  177. window.location.href = "sign-agreement1.html";
  178. }
  179. function cancelSign(){
  180. dialog({
  181. title: '提示',
  182. content: '您确定继续取消和' + document.getElementById("name").innerHTML + '医生的签约吗?',
  183. ok: function (){
  184. d1.showModal();
  185. var data = {};
  186. data.doctor = doctor;
  187. sendPost('patient/family_contract/unsign', data, 'json', 'post', submitFailed, submitSuccess);
  188. },
  189. cancel: function () {
  190. return;
  191. }
  192. }).showModal();
  193. }
  194. function overSign(){
  195. $("#txtInfo").hide();
  196. dialog({
  197. title: '申请解约',
  198. skin:"ui-dialog ax-popup pror",
  199. content:$("#xf-artd").get(0),
  200. ok: function (){
  201. var data = {};
  202. data.doctor = doctor;
  203. data.doctorName = document.getElementById("name").innerHTML;
  204. data.reason = $("#textReason").val();
  205. if(data.reason == "" || data.reason == null){
  206. $("#txtInfo").show();
  207. return false;
  208. }
  209. else{
  210. $("#txtInfo").hide();
  211. d1.showModal();
  212. sendPost('patient/family_contract/surrender', data, 'json', 'post', submitFailed, submitSuccess2);
  213. return;
  214. }
  215. },
  216. cancel: function () {
  217. return;
  218. }
  219. }).showModal();
  220. }
  221. function submitFailed(res) {
  222. d1.close();
  223. if (res && res.msg) {
  224. dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg}).show();
  225. } else {
  226. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'操作失败'}).show();
  227. }
  228. }
  229. function submitSuccess(res) {
  230. if (res.status == 200) {
  231. d1.close();
  232. $("#div-area").hide();
  233. $("#div-doctorPage").hide();
  234. queryInit();
  235. } else{
  236. submitFailed(res);
  237. }
  238. }
  239. function submitSuccess2(res) {
  240. if (res.status == 200) {
  241. document.getElementById("btnSign").innerHTML = '<span class="c-f18" style="color: #E71F19;">您已申请了解约,流程审核中,请等待!!</span>';
  242. d1.close();
  243. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'解约申请成功'}).show();
  244. window.scrollTo(0,0);
  245. } else{
  246. submitFailed(res);
  247. }
  248. }