doctor-homepage-new.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955
  1. var d = dialog({contentType: 'load',skin: 'bk-popup'});
  2. var d1 = dialog({contentType: 'load',skin: 'bk-popup',content: '提交中...'});
  3. var doctor = "";
  4. var name = "";
  5. var isQr = "";
  6. var waitSign;
  7. var level="";
  8. // 链接中是否有openid
  9. var openidInLink = false;
  10. // 存储链接中携带的invilogcode参数,用来判断是否是从推送消息进入处理“签约邀请”(暂时无法实现此方式)
  11. var signInvitationInLink;
  12. var inviCode;
  13. // 通过推送消息方式进入,查询得到的被邀请对象的code
  14. var patientCode;
  15. var userAgent;
  16. var invitationState;
  17. var pagetype = 18;
  18. var loginParams = "";
  19. var Request = new Object();
  20. Request = GetRequest();
  21. var represented = Request["represented"];
  22. var openid = Request["openid"];
  23. //续签处理模板消息跳转过来的数据
  24. var is_renew, //1是续签 0是签约
  25. signState; //1同意 0是拒绝
  26. $(function() {
  27. code = Request["code"];
  28. is_renew = Request["isRenew"];
  29. signState = Request["signState"];
  30. isRepresent(function(){
  31. nextWork()
  32. })
  33. function nextWork(){
  34. userAgent = window.localStorage.getItem(agentName);
  35. var currentSigner = "";// 点击邀请的推送链接携带的签约者
  36. var handerAccount = "";// 点击邀请的推送链接携带的处理者的账号
  37. isQr = Request["isQr"];
  38. level = Request["level"];
  39. openidInLink = (openid!==undefined)?true:false;
  40. loginParams = Request["loginParams"];
  41. if(loginParams) {
  42. loginParams = JSON.parse(loginParams);
  43. }
  44. invitationState = Request["state"];
  45. signInvitationInLink = Request["invilogcode"];
  46. //shenzaixin 修改,增加openid的获取
  47. if(!openidInLink && code != undefined && code != "") {
  48. sendPost("weixin/getOpenidByCode",{"code":code},'JSON','GET',
  49. function(res){
  50. handleBusiness();
  51. },function(res){
  52. if(res.status==200){
  53. openid = res.openid;
  54. openidInLink = openid!==undefined?true:false;
  55. }
  56. handleBusiness();
  57. });
  58. }
  59. else{
  60. handleBusiness();
  61. }
  62. }
  63. })
  64. function handleBusiness(){
  65. if(invitationState.indexOf("__")>-1) {
  66. doctor = invitationState.split("__")[0];
  67. } else {
  68. doctor = invitationState;
  69. }
  70. if(!userAgent) {
  71. if(!openid)
  72. {
  73. if(invitationState){
  74. $('#doctor_qrcode').find("img").attr('src',server+'qrcode/doctor_img?doctor='+doctor);
  75. $('#doctor_qrcode').show();
  76. }
  77. } else{
  78. // 如果invitationState含有“-”,则表示是从消息推送中跳转过来
  79. if(invitationState) {
  80. localStorage.setItem("doccode",invitationState);
  81. }
  82. //window.location.href = server + "wx/html/home/html/zhmm-login.html?type=" + pagetype + "&openid=" + openid;
  83. }
  84. data = { doctor: doctor };
  85. sendPost('family_contract/homepage/homepage', data, 'json', 'post', queryFailed, querySuccess);
  86. }else{
  87. var userAgentStr = window.localStorage.getItem(agentName);
  88. var userJson = userAgentStr && JSON.parse(userAgentStr);
  89. var patient = userJson.represented?userJson.represented:userJson.uid;
  90. // 获取微信授权
  91. closeWindow();
  92. // 如果invitationState含有“-”,则表示是从消息推送中跳转过来
  93. if(invitationState) {
  94. var codes = invitationState.split("__");
  95. if(codes &&codes.length >= 4) {
  96. doctor = codes[0];
  97. inviCode = codes[1];
  98. currentSigner = codes[2];
  99. handerAccount = codes[3];
  100. if(codes.length==5)
  101. name = codes[4];
  102. if(currentSigner != patient) {
  103. var Request = GetRequest();
  104. dialog({
  105. content:'对不起,该消息是发送给'+ decodeURIComponent(name) +'的,您无权查看',
  106. okValue:'切换账号',
  107. ok: function() {
  108. window.localStorage.setItem(pageName, JSON.stringify({pageurl: location.href}))
  109. // window.location.href = "../../home/html/zhmm-login.html?type=0&openid="+ Request["openid"];
  110. window.location.href = "../../grzx/html/change-login.html";
  111. },
  112. cancelValue: '我知道了',
  113. cancel: function () {
  114. wx.closeWindow();
  115. }
  116. }).showModal();
  117. return ;
  118. }
  119. signInvitationInLink = true;
  120. }
  121. }
  122. queryInit();
  123. bindEvents();
  124. }
  125. }
  126. function bindEvents(){
  127. // 点击“+”号的控制
  128. $('.btn-main').on('click',function() {
  129. $(this).hide();
  130. $('#btnMenu').show();
  131. $("#overlay_pop").show();
  132. $("#overlay_pop").css("background-color","transparent");
  133. $("body,html").css("overflow-y","hidden");
  134. });
  135. //点击遮罩事件
  136. $("#overlay_pop").on('click',function() {
  137. $(this).hide();
  138. $('#btnMenu').hide();
  139. $('.btn-main').show();
  140. $('#introduce_guide').hide();
  141. $('#introduce_text').hide();
  142. $("body,html").css("overflow-y","initial");
  143. });
  144. $('#btnMenu').on('click','.btn-item',function () {
  145. var type = $(this).attr('data-type');
  146. $('#btnMenu').hide();
  147. $('.btn-main').show();
  148. $("#overlay_pop").hide();
  149. $("body,html").css("overflow-y","hidden");
  150. switch(type) {
  151. case 'break':
  152. // 点击“解约”控制
  153. overSign();
  154. break;
  155. case 'introduce':
  156. //window.scrollTo(0,0);
  157. // 点击“推荐”控制
  158. $('#overlay_pop').show();
  159. $("#overlay_pop").css("background-color","rgba(0,0,0,0.7)");
  160. $('#introduce_guide').show();
  161. $('#introduce_text').show();
  162. break;
  163. case 'consultation':
  164. // 点击“推荐”控制 (其实这里已经要跳转了,画面不用做什么显示控制)
  165. location.href = "../../yszx/html/doctor-consultation.html";
  166. break;
  167. default:
  168. // 点击“取消”的控制
  169. $("body,html").css("overflow-y","initial");
  170. }
  171. });
  172. }
  173. function popThanksDialog() {
  174. dialog({
  175. content: '<div class="c-t-left">您的签约申请已提交,请等待医生的审核。请您的亲友们也一起享受家庭医生的服务吧~</div>',
  176. okValue:'前往分享',
  177. ok: function (){
  178. location.href = '../../qygl/html/signing-share.html?guide=1'
  179. },
  180. cancelValue: '我知道了',
  181. cancel: function () {
  182. return;
  183. }
  184. }).showModal();
  185. }
  186. function closeWindow() {
  187. var Request = new Object();
  188. Request = GetRequest();
  189. var code = Request["code"];
  190. //从后台那边获取签名等信息
  191. var params = {};
  192. params.pageUrl = window.location.href;
  193. $.ajax(server + "weixin/getSign", {
  194. data: params,
  195. dataType: "json",
  196. type: "post",
  197. success: function(res) {
  198. if(res.status == 200) {
  199. var t = res.data.timestamp;
  200. var noncestr = res.data.noncestr;
  201. var signature = res.data.signature;
  202. wx.config({
  203. //debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  204. appId: appId, // 必填,公众号的唯一标识
  205. timestamp: t, // 必填,生成签名的时间戳
  206. nonceStr: noncestr, // 必填,生成签名的随机串
  207. signature: signature, // 必填,签名,见附录1
  208. jsApiList: [
  209. 'closeWindow'
  210. ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
  211. });
  212. }
  213. }
  214. });
  215. }
  216. function popOverlay(flag) {
  217. var height = document.body.scrollHeight,
  218. $pop = $('#overlay_pop');
  219. $('#introduce_guide').hide();
  220. $('#introduce_text').hide();
  221. if(flag) {
  222. $pop.one('click',function() {
  223. $('.btn-main img').attr('src','../images/geduoxuanfu_icon.png');
  224. $('.btn-item').hide();
  225. $('.btn-main').addClass('close');
  226. $('#introduce_guide').hide();
  227. $('#introduce_text').hide();
  228. $pop.hide();
  229. });
  230. $pop.height(height).show();
  231. } else {
  232. $pop.hide();
  233. }
  234. }
  235. // 签约邀请处理
  236. function invitSignHandle() {
  237. sendPost('patient/family_contract/getPatientSign', {homePageDoctorCode: doctor,invitePatientCode: inviCode}, 'json', 'post', queryFailed, function(res) {
  238. var data = res.data;
  239. // 被邀请人是否已签约家庭医生
  240. var isSignedFamilyDoctor = data.type=="1" && data.sign_type != -1 && data.sign_type != 0,
  241. // 被邀请人是否已申请签约
  242. isRequetSigning = data.sign_type==0,
  243. // 申请签约的医生是否为该医生
  244. isSignedDoctor = doctor == data.sign_doctor,
  245. // 是否签约三师
  246. isSignedSanShi = data.type=="2" && data.sign_type != -1,
  247. // 签约的三师中全科医生是否为发出邀请的医生
  248. isSanShiDoctor = doctor == data.sign_doctor;
  249. patientCode = data.patient_code;
  250. // 被邀请人是否已签约家庭医生
  251. if(isSignedFamilyDoctor) {
  252. dialog({
  253. content: data.patient_name+'已经签约,请忽略该邀请。',
  254. okValue:'我知道了',
  255. ok: function() {
  256. wx.closeWindow();
  257. }
  258. }).showModal();
  259. }
  260. // 被邀请人是否已申请签约
  261. else if (isRequetSigning) {
  262. if(isSignedDoctor){
  263. document.getElementById("btnSign").innerHTML = '<a onclick="cancelSign(\''+data.patient_name+'\')" class="c-btn c-btn-E0A526 c-btn-full c-btn-radius c-f18">取消'+data.patient_name+'的签约申请</a>';
  264. $('#btnSign').show();
  265. $('#btnSign').closest("div").addClass("h64");
  266. updateBodyHeight();
  267. } else {
  268. dialog({
  269. content: data.patient_name+'已向其他医生申请签约,取消申请后,方可与该医生签约。',
  270. okValue:'我知道了',
  271. ok: function() {
  272. wx.closeWindow();
  273. }
  274. }).showModal();
  275. }
  276. }
  277. // 是否签约三师
  278. /*else if(isSignedSanShi) {
  279. // 签约的三师中全科医生是否为发出邀请的医生
  280. if(isSanShiDoctor) {
  281. document.getElementById("sign_invitation").innerHTML =
  282. '<div class="c-row">'
  283. +'<div class="c-50 c-tac height-50 lheight-50 bc-ff9526 c-fff" onclick="ignoreSignInvitation()">忽略签约邀请</div>'
  284. +'<div class="c-50 c-tac height-50 lheight-50 bc-75bf00 c-fff"><a href="javascript:void(0);" onclick="agreeSignInvitation()" class="c-fff">同意与其签约</a></div>'
  285. +'</div>';
  286. } else {
  287. dialog({
  288. content: data.patient_name+'已存在三师签约,签约医生为'+data.sign_doctorName+'医生,不可与其他医生签约家庭医生。',
  289. okValue:'我知道了',
  290. ok: function() {
  291. wx.closeWindow();
  292. }
  293. }).showModal();
  294. }
  295. }*/ else {
  296. document.getElementById("sign_invitation").innerHTML =
  297. '<div class="c-row">'
  298. +'<div class="c-50 c-tac height-50 lheight-50 bc-ff9526 c-fff" onclick="ignoreSignInvitation()">忽略签约邀请</div>'
  299. +'<div class="c-50 c-tac height-50 lheight-50 bc-75bf00 c-fff"><a href="javascript:void(0);" onclick="agreeSignInvitation()" class="c-fff">同意与其签约</a></div>'
  300. +'</div>';
  301. }
  302. sendPost('patient/family_contract/homepage', {
  303. doctor: doctor
  304. }, 'json', 'post', queryFailed, querySuccess);
  305. });
  306. }
  307. function queryInit() {
  308. // d.show();
  309. var data = {};
  310. var Request = new Object();
  311. Request = GetRequest();
  312. doctor = doctor || Request["state"];
  313. if(doctor.indexOf("__")>-1) {
  314. doctor = doctor.split("__")[0];
  315. }
  316. waitSign = Request["waitSign"];
  317. data.doctor = doctor;
  318. var flag = window.localStorage.getItem("popThanksDialog");
  319. if(!flag && waitSign) {
  320. window.localStorage.setItem("popThanksDialog","1");
  321. popThanksDialog();
  322. } else {
  323. window.localStorage.removeItem("popThanksDialog");
  324. }
  325. if(signInvitationInLink) {
  326. sendPost('patient/family/findPatientInviteLog',{invitePatientCode:inviCode}, 'json', 'post',function(){
  327. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求失败'}).show();
  328. },function(res) {
  329. invitSignHandle();
  330. });
  331. }else{
  332. sendPost('patient/family_contract/homepage', data, 'json', 'post', queryFailed, querySuccess);
  333. }
  334. }
  335. function queryFailed(res) {
  336. d.close();
  337. if(res && res.msg) {
  338. dialog({
  339. contentType: 'tipsbox',
  340. skin: 'bk-popup',
  341. content: res.msg
  342. }).show();
  343. } else {
  344. dialog({
  345. contentType: 'tipsbox',
  346. skin: 'bk-popup',
  347. content: '加载失败'
  348. }).show();
  349. }
  350. }
  351. function querySuccess(res) {
  352. // TODO 示例数据
  353. // res = {
  354. // "msg": "医生主页查询成功!",
  355. // "data": {
  356. // "doctor": "D20160322000002",
  357. // "jobName": "主任医师",
  358. // "intro": "慢性阻塞性肺疾病、支气管扩张等能够较为熟练地结合中医辨证与西医辨病两套方法进",
  359. // "name": "聂青",
  360. // "sign": -1,
  361. // "photo": "http://172.19.103.85:8882/res/images/2016/07/27/20160727010854_298.jpeg",
  362. // "dept": "呼吸内科",
  363. // "services": [],
  364. // "job": "",
  365. // "hospital": "金山社区医疗服务中心",
  366. // "expertise": "及实验研究工作十年余,先后参加国家级、省部级多项课题的研究,在科室积极开展的中医特色疗法如穴位注射和敷贴、中药雾化等,疗效显著,对疑难疾病的诊治能坚持自己的观点,和科室同仁一道成功抢救许多肺心病、肺性脑病和呼吸衰竭等危重患。",
  367. // "group": "0"
  368. // },
  369. // "status": 200
  370. // };
  371. if(res.status == 200) {
  372. var name = res.data.name;
  373. var jobName = "全科医生";
  374. level = res.data.level;
  375. if(level){
  376. jobName = level==1?"专科医生":(level==2?"全科医生":"健康管理师");
  377. }
  378. var hospitalName = res.data.hospital;
  379. var deptName = res.data.dept;
  380. var photo = getImgUrl(res.data.photo);
  381. var expertise = res.data.expertise;
  382. var introduce = res.data.intro;
  383. var sign = Number(res.data.sign);
  384. var group = Number(res.data.group);
  385. var url2 = "../../../images/d-male.png";
  386. if(res.data.sex==2){
  387. url2 = "../../../images/d-female.png";
  388. }
  389. if(photo != null && photo != "") {
  390. url2 = photo;
  391. }
  392. if(!jobName) jobName = "";
  393. if(!deptName) deptName = "";
  394. if(!expertise) expertise = "无";
  395. if(!introduce) introduce = "无";
  396. document.getElementById("photo").src = url2;
  397. document.getElementById("name").innerHTML = name;
  398. document.getElementById("jobName").innerHTML = jobName;
  399. document.getElementById("hospitalName").innerHTML = hospitalName;
  400. document.getElementById("deptName").innerHTML = deptName;
  401. document.getElementById("expertise").innerHTML = expertise;
  402. document.getElementById("introduce").innerHTML = introduce;
  403. document.getElementById("doctor_name").innerHTML = name;
  404. //判断签约人数是否达到上限
  405. var isSignLimit = false;
  406. if(res.data.signTotal >= res.data.limitTotal){
  407. isSignLimit = true;
  408. }
  409. document.getElementById("signNum").innerHTML = isSignLimit ? '签约已达上限' : res.data.signTotal;
  410. //动态修改title的值
  411. var $body = $('body');
  412. document.title = name+"医生诚挚为您服务";
  413. // hack在微信等webview中无法修改document.title的情况
  414. var $iframe = $('<iframe src="/favicon.ico"></iframe>');
  415. $iframe.on('load',function() {
  416. setTimeout(function() {
  417. $iframe.off('load').remove();
  418. }, 0);
  419. }).appendTo($body);
  420. if(group == 1) {
  421. $("#ul-health").show();
  422. } else if(group == 2) {
  423. $("#ul-disease").show();
  424. } else if(group == 3) {
  425. $("#ul-sixfive").show();
  426. } else {
  427. $("#ul-common").show();
  428. }
  429. if(signInvitationInLink) {
  430. d.close();
  431. return ;
  432. }
  433. if(sign == 0) { // 待签约
  434. document.getElementById("btnSign").innerHTML = '<a onclick="cancelSign()" class="c-btn c-btn-E0A526 c-btn-full c-btn-radius c-f18">取消申请</a>';
  435. $('#btnSign').show();
  436. $('#btnSign').closest("div").addClass("h64");
  437. updateBodyHeight();
  438. } else if(sign == 1) { // 已签约
  439. //document.getElementById("btnSign").innerHTML = '<a onclick="overSign()" class="c-btn c-btn-E0A526 c-btn-full c-btn-radius c-f18">申请解约</a>';
  440. $('#btnSign').hide();
  441. $('.btn-main').show();
  442. $('#btnSign').closest("div").removeClass("h64");
  443. } else if(sign == -1) { // 患者解约
  444. // 有openid显示“申请签约”按钮
  445. var userAgentStr = window.localStorage.getItem(agentName);
  446. var userJson = userAgentStr && JSON.parse(userAgentStr);
  447. if(openidInLink || (userJson&&userJson.openid)) {
  448. //判断是否是从续签申请后跳转回来的页面,续签申请后跳转回来的页面不显示按钮
  449. var is_renew1 = window.localStorage.getItem("is_renew");
  450. if(!(is_renew1 && waitSign)){
  451. //判断从续签处理的模板消息页面跳转过来的页面对按钮的处理
  452. if(is_renew == 1 || is_renew == "1"){
  453. if(signState == "0"){
  454. if(isSignLimit){
  455. document.getElementById("btnSign").innerHTML = '<a onclick="javascript:void();" class="c-btn bgc-dcdcdc c-btn-full c-btn-radius c-f16">医生签约已达上限,请选择其他医生</a>';
  456. }else{
  457. document.getElementById("btnSign").innerHTML = '<a onclick="startSign()" class="c-btn c-btn-4dcd70 c-btn-full c-btn-radius c-f16">申请续签</a>';
  458. }
  459. window.localStorage.setItem("is_renew", "1");
  460. $('#btnSign').show();
  461. $('#btnSign').closest("div").addClass("h64");
  462. updateBodyHeight();
  463. $("#btnMenu").hide();
  464. }
  465. }else{
  466. if(isSignLimit){
  467. document.getElementById("btnSign").innerHTML = '<a onclick="javascript:void();" class="c-btn bgc-dcdcdc c-btn-full c-btn-radius c-f16">医生签约已达上限,请选择其他医生</a>';
  468. }else{
  469. document.getElementById("btnSign").innerHTML = '<a onclick="startSign()" class="c-btn c-btn-4dcd70 c-btn-full c-btn-radius c-f16">申请签约</a>';
  470. }
  471. $('#btnSign').show();
  472. $('#btnSign').closest("div").addClass("h64");
  473. updateBodyHeight();
  474. $("#btnMenu").hide();
  475. }
  476. }
  477. }
  478. // 邀请签约时显示
  479. // else if(signInvitationInLink) {
  480. // document.getElementById("sign_invitation").innerHTML =
  481. // '<div class="c-row">'
  482. // +'<div class="c-50 c-tac height-50 lheight-50 bc-ff9526 c-fff" onclick="ignoreSignInvitation()">忽略签约邀请</div>'
  483. // +'<div class="c-50 c-tac height-50 lheight-50 bc-75bf00 c-fff"><a href="javascript:void(0);" onclick="agreeSignInvitation()" class="c-fff">同意与其签约</a></div>'
  484. // +'</div>';
  485. // }
  486. // 否则显示医生二维码
  487. else {
  488. if(level&&level!=2){
  489. $('#doctor_qrcode').hide();
  490. }else{
  491. if(doctor){
  492. $('#doctor_qrcode').find("img").attr('src',server+'qrcode/doctor_img?doctor='+doctor);
  493. }
  494. $('#doctor_qrcode').show();
  495. }
  496. }
  497. $("#divAgree").hide();
  498. } else if(sign == 2) { // 待解约
  499. document.getElementById("btnSign").innerHTML = '<span class="c-f18" style="color: #E71F19;">您已申请了解约,流程审核中,请等待!!</span>';
  500. $('#btnSign').show();
  501. $('#btnSign').closest("div").addClass("h64");
  502. updateBodyHeight();
  503. } else {
  504. document.getElementById("btnSign").innerHTML = '<span class="c-f18" style="color: #E71F19;">医生申请与您解约,流程审核中,请等待!!</span>';
  505. $('#btnSign').show();
  506. $('#btnSign').closest("div").addClass("h64");
  507. updateBodyHeight();
  508. }
  509. d.close();
  510. } else {
  511. queryFailed(res);
  512. }
  513. }
  514. function updateBodyHeight() {
  515. var height = $(document.body).height();
  516. $("body>.c-main").height(height-64);
  517. }
  518. //申请签约
  519. function startSign() {
  520. layer.open({
  521. title: ['温馨提示', 'font-weight:700;font-size:16px'],
  522. content: '<div id="hukou" class="tishiwenzi">1、二乙伤残军人 、外来在职(非厦门户口)、外来退休身份暂不属于办理家庭医生签约范围人员,无法正常签约缴费。</br></br>2、港澳人员在厦门 i健康暂不允许注册及签约。</br></br>3、签约在线缴费需使用实名且与医保卡同名的微信公众号进行绑卡及支付,如需为家人代理缴费,需先到市行政服务中心申请家庭共济关系后,才可以绑定家人的医保卡并缴费哟~</div>',
  523. btn:['开始签约','暂不签约'],
  524. shadeClose: false,
  525. yes:function(index){
  526. if(!userAgent) {
  527. var params = JSON.stringify({doctor: doctor});
  528. localStorage.setItem("doccode",doctor);
  529. window.location.href = server + "wx/html/home/html/zhmm-login.html?type=" + pagetype + "&openid=" + openid+"&loginParams="+params;
  530. }
  531. if(isQr != false) {
  532. sendPost('patient/family_contract/checkOpenid', {}, 'json', 'post', queryFailed, openidSuccess2);
  533. } else {
  534. d.show()
  535. //判断当前患者是否有上一个年度生效的签约关系
  536. var url = "/patient/family_contract/checkCanRenew",
  537. params = {patient: patientCode};
  538. sendPost(url, params, "json", "post", queryFailed , function(res){
  539. if(res.status == 200){
  540. d.close();
  541. var code = res.data.code,
  542. isrenew = true;
  543. switch (parseInt(code)){
  544. case -5:
  545. //"医生已同意您的续签,您无需再次签约";
  546. case -4:
  547. //"您当前无可续签的家庭医生,可在签约管理页面签约医生";
  548. case -3:
  549. //"您已提交过申请,无需重复提交";
  550. case -2:
  551. //"您已完成2017~2018年度签约,不能再次签约";
  552. case -1:
  553. //"当前时间段不允许续签,可前往签约管理页面签约医生";
  554. case 0:
  555. //"患者数据有误";
  556. isrenew = false;
  557. break;
  558. default:
  559. isrenew = true;
  560. break;
  561. }
  562. if(isrenew){
  563. window.localStorage.setItem("is_renew", "1");
  564. }
  565. var doctorName = encodeURI(document.getElementById("name").innerHTML);
  566. var hospitalName = encodeURI(document.getElementById("hospitalName").innerHTML);
  567. // window.location.href = "../../qygl/html/agreement.html?doctor=" + doctor + "&doctorName=" + doctorName + "&hospitalName=" + hospitalName+'&patientCode='+patientCode+'&inviCode='+inviCode+"&level="+level;
  568. }else{
  569. queryFailed(res);
  570. }
  571. });
  572. }
  573. },
  574. no:function(index){
  575. layer.close(index);
  576. },
  577. })
  578. }
  579. function changeAgreement() {
  580. window.location.href = "../../qygl/html/agreement.html?readonly=1";
  581. }
  582. var patientNameDec ="";
  583. function cancelSign(patientName) {
  584. patientNameDec = patientName;
  585. dialog({
  586. content: '您确定继续取消和' + document.getElementById("name").innerHTML + '医生的签约吗?',
  587. ok: function() {
  588. d1.showModal();
  589. var data = {};
  590. if(patientCode) {
  591. data.patientCode = patientCode;
  592. }
  593. data.doctor = doctor;
  594. sendPost('patient/family_contract/unsign', data, 'json', 'post', submitFailed, submitSuccess);
  595. },
  596. cancel: function() {
  597. return;
  598. }
  599. }).showModal();
  600. }
  601. function overSign() {
  602. $("#txtInfo").hide();
  603. dialog({
  604. title: '申请解约',
  605. skin: "ui-dialog ax-popup pror reqest-unsign-pop",
  606. content: $("#xf-artd").get(0),
  607. ok: function() {
  608. var data = {};
  609. data.doctor = doctor;
  610. data.doctorName = document.getElementById("name").innerHTML;
  611. data.reason = $("#textReason").val();
  612. if(data.reason == "" || data.reason == null) {
  613. $("#txtInfo").show();
  614. return false;
  615. } else {
  616. $("#txtInfo").hide();
  617. d1.showModal();
  618. sendPost('patient/family_contract/surrender', data, 'json', 'post', submitFailed, submitSuccess2);
  619. $("body,html").css("overflow-y","initial");
  620. return;
  621. }
  622. },
  623. cancel: function() {
  624. $("body,html").css("overflow-y","initial");
  625. return;
  626. }
  627. }).showModal();
  628. }
  629. function submitFailed(res) {
  630. d1.close();
  631. if(res && res.msg) {
  632. dialog({
  633. contentType: 'tipsbox',
  634. skin: 'bk-popup',
  635. content: res.msg
  636. }).show();
  637. } else {
  638. dialog({
  639. contentType: 'tipsbox',
  640. skin: 'bk-popup',
  641. content: '操作失败'
  642. }).show();
  643. }
  644. }
  645. function submitSuccess(res) {
  646. if(res.status == 200) {
  647. d1.close();
  648. //shenzaixin 修改20160827 ,使取消签约时,页面会显示申请签约按钮,而不是二维码。
  649. if(!patientNameDec){
  650. window.location.href = "doctor-homepage-new.html?openid="+openid+"&state="+doctor;
  651. }else{
  652. //location.reload();
  653. // window.location.href = "choose-region.html";
  654. dialog({
  655. content: '已成功取消了'+patientNameDec+'<br/>与'+document.getElementById("name").innerHTML+'医生的签约申请',
  656. okValue:'我知道了',
  657. ok: function() {
  658. wx.closeWindow();
  659. }
  660. }).showModal();
  661. }
  662. } else {
  663. submitFailed(res);
  664. }
  665. }
  666. function submitSuccess2(res) {
  667. if(res.status == 200) {
  668. document.getElementById("btnSign").innerHTML = '<span class="c-f18" style="color: #E71F19;">您已申请了解约,流程审核中,请等待!!</span>';
  669. $('#btnSign').closest("div").addClass("h64");
  670. updateBodyHeight();
  671. d1.close();
  672. dialog({
  673. contentType: 'tipsbox',
  674. skin: 'bk-popup',
  675. content: '解约申请成功'
  676. }).show();
  677. window.scrollTo(0, 0);
  678. location.reload();
  679. //window.location.href = "doctor-home-page.html?doctor=" + doctor;
  680. } else {
  681. submitFailed(res);
  682. }
  683. }
  684. //判断是否有三师信息
  685. function checkTeacter() {
  686. var data = {};
  687. data.signDoctor=doctor;
  688. sendPost('patient/teachers', data, 'json', 'post', queryFailedTeacter, querySuccessTeacter);
  689. }
  690. function querySuccessTeacter(res) {
  691. if(res.status == 200) {
  692. d.close();
  693. var list = res.data.list;
  694. if(list.length > 0) {
  695. var doctorTemp = "";
  696. var doctorName = "";
  697. for(var i = 0; i < list.length; i++) {
  698. var data = list[i];
  699. if(Number(data.type) == 2) {
  700. doctorTemp = data.code;
  701. doctorName = data.name;
  702. }
  703. }
  704. if(level==2){
  705. var doctorNameTemp = document.getElementById("name").innerHTML;
  706. if(doctorNameTemp != doctorName) {
  707. dialog({
  708. content: '您已签约三师,故只可与' + doctorName + '医生签约家庭医生,是否前往与'+doctorName+'医生签约?',
  709. okValue:'立即前往',
  710. ok: function() {
  711. window.location.href = "doctor-homepage-new.html?state=" + doctorTemp;
  712. },
  713. cancelValue: '不了,谢谢',
  714. cancel:function(){
  715. return;
  716. }
  717. }).showModal();
  718. } else {
  719. familyDoctor();
  720. }
  721. }else if(level==3){
  722. if(res.data.team&&res.data.team.length>0){
  723. familyDoctor();
  724. }else{
  725. dialog({
  726. content: '您已签约三师,故只可与' + doctorName + '医生签约家庭医生,是否前往与'+doctorName+'医生签约?',
  727. okValue:'立即前往',
  728. ok: function() {
  729. window.location.href = "doctor-homepage-new.html?state=" + doctorTemp;
  730. },
  731. cancelValue: '不了,谢谢',
  732. cancel:function(){
  733. return;
  734. }
  735. }).showModal();
  736. }
  737. }
  738. } else {
  739. familyDoctor();
  740. }
  741. } else if(res.status == 1 || res.status == 2) {
  742. d.close();
  743. familyDoctor();
  744. } else {
  745. queryFailedTeacter(res);
  746. }
  747. }
  748. //成功
  749. function openidSuccess2(res) {
  750. if(res.status == 200) {
  751. // if(res.data == null || res.data == "") {
  752. // checkTeacter();
  753. // } else {
  754. queryDoctor(res);
  755. // }
  756. } else {
  757. queryFailed(res);
  758. }
  759. }
  760. //获取家庭签约的医生信息
  761. function queryDoctor(res) {
  762. var data = {};
  763. if(res.data){
  764. data.doctor = res.data;
  765. }else{
  766. data.doctor = doctor;
  767. }
  768. sendPost('patient/family_contract/homepage', data, 'json', 'post', queryFailed, querySuccess3);
  769. }
  770. function querySuccess3(res) {
  771. if(res.status == 200) {
  772. var doctorName = document.getElementById("name").innerHTML;
  773. //判断当前是否是续签变更医生的情况
  774. var is_renew = window.localStorage.getItem("is_renew");
  775. if(parseInt(is_renew)){
  776. familyDoctor();
  777. return;
  778. }
  779. if(res.data.name != doctorName) {
  780. dialog({
  781. content: '您已签约家庭医生,无法再次签约',
  782. ok: function() {
  783. wx.closeWindow();
  784. }
  785. }).showModal();
  786. } else {
  787. familyDoctor();
  788. }
  789. } else {
  790. queryFailed(res);
  791. }
  792. }
  793. function familyDoctor(querystr) {
  794. var doctorName = encodeURI(document.getElementById("name").innerHTML);
  795. var hospitalName = encodeURI(document.getElementById("hospitalName").innerHTML);
  796. var patient = '';
  797. if(inviCode&&patientCode) {
  798. patient = patientCode;
  799. } else if(userAgent){
  800. var userInfo = JSON.parse(userAgent);
  801. patient = userInfo.represented?userInfo.represented:userInfo.uid;
  802. }
  803. if(window.localStorage.getItem("is_renew") == '1'){
  804. window.location.href = "../../qygl/html/agreement.html?doctor=" + doctor + "&doctorName=" + doctorName + "&hospitalName=" + hospitalName+(querystr||"")+'&patientCode='+patient+'&code='+code+'&inviCode='+inviCode+'&level='+level;
  805. }else{
  806. //二维码扫码时,判断患者去年是否有签约记录
  807. d.show()
  808. var url = "/patient/family_contract/checkCanRenew",
  809. params = {patient: patient};
  810. sendPost(url, params, "json", "post", queryFailed , function(res){
  811. if(res.status == 200){
  812. d.close();
  813. var code = res.data.code,
  814. isrenew = true;
  815. switch (parseInt(code)){
  816. case -5:
  817. //"医生已同意您的续签,您无需再次签约";
  818. case -4:
  819. //"您当前无可续签的家庭医生,可在签约管理页面签约医生";
  820. case -3:
  821. //"您已提交过申请,无需重复提交";
  822. case -2:
  823. //"您已完成2017~2018年度签约,不能再次签约";
  824. case -1:
  825. //"当前时间段不允许续签,可前往签约管理页面签约医生";
  826. case 0:
  827. //"患者数据有误";
  828. isrenew = false;
  829. break;
  830. default:
  831. isrenew = true;
  832. break;
  833. }
  834. if(isrenew){
  835. window.localStorage.setItem("is_renew", "1");
  836. }
  837. window.location.href = "../../qygl/html/agreement.html?doctor=" + doctor + "&doctorName=" + doctorName + "&hospitalName=" + hospitalName+(querystr||"")+'&patientCode='+patient+'&code='+code+'&inviCode='+inviCode+'&level='+level;
  838. }else{
  839. queryFailed(res);
  840. }
  841. });
  842. }
  843. }
  844. function queryFailedTeacter(res) {
  845. d.close();
  846. if(res && res.msg) {
  847. dialog({
  848. contentType: 'tipsbox',
  849. skin: 'bk-popup',
  850. content: res.msg
  851. }).show();
  852. } else {
  853. dialog({
  854. contentType: 'tipsbox',
  855. skin: 'bk-popup',
  856. content: '加载失败'
  857. }).show();
  858. }
  859. }
  860. // 忽略签约邀请
  861. function ignoreSignInvitation() {
  862. sendPost('patient/family/updatePatientInviteLog', {patientInviteLogCode:inviCode,type:2}, 'json', 'post', function(){
  863. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求失败'}).show();
  864. }, function(req) {
  865. if(req.status==200) {
  866. // 关闭页面,返回公众号
  867. wx.closeWindow();
  868. } else {
  869. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'处理失败'}).show();
  870. }
  871. });
  872. }
  873. // 同意与其签约
  874. function agreeSignInvitation() {
  875. sendPost('patient/family/updatePatientInviteLog', {patientInviteLogCode:inviCode,type:1}, 'json', 'post', function(){
  876. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求失败'}).show();
  877. }, function(req) {
  878. if(req.status==200) {
  879. // 跳转到协议页面
  880. familyDoctor("&signInvitationCode="+inviCode+"&doctor="+doctor);
  881. } else {
  882. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'处理失败'}).show();
  883. }
  884. });
  885. }