select-doctor.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. var d = dialog({contentType:'load', skin:'bk-popup'}).show();
  2. var Request = GetRequest(),
  3. // 如果从签约首页进入时携带existedSanShi参数,表明该用户已经签约了三师全科医生,
  4. // 根据该字段存在弹出提示是否与该医生签约家庭医生
  5. existedSanShi = Request["existedSanShi"],
  6. doctor = Request["doctor"],
  7. doctorName = Request["doctorName"];
  8. var pagetype = 16;
  9. var userAgent = window.localStorage.getItem(agentName);
  10. var $areaView = $('#area_view'),
  11. $areaList = $('#area_list');
  12. // 搜索框
  13. $('.searchbar').searchBar();
  14. $(function(){
  15. checkUserAgent();
  16. })
  17. var reqPromise = function(url,data) {
  18. return new Promise(function(resolve, reject) {
  19. sendPost(url, data, "json", "post",
  20. function queryFailed () {
  21. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show();
  22. // TODO 开启示例数据
  23. //resolve({ });
  24. }
  25. , function success(req) {
  26. resolve(req);
  27. });
  28. });
  29. },
  30. handleData = function(list) {
  31. if(!list) return [];
  32. // 签约状态对应的文本
  33. var signStatus = ["待签约","已签约","待解约"],
  34. groups = _.chain(list).map(function(o) {
  35. o.signStatusText = signStatus[o.signStatus] || "";
  36. o.dateText = (function() {
  37. switch(o.signStatus) {
  38. case 0: return "申请时间:"+o.sqDate
  39. case 1: return "签约时效:"+o.qyDate+' ~ '+o.endDate
  40. case 2: return "提交时间:"+o.qyDate
  41. }
  42. })();
  43. return o;
  44. }).groupBy(function(o) {
  45. return o.signType;
  46. }).value();
  47. return groups;
  48. };
  49. if(userAgent) {
  50. userAgent = JSON.parse(userAgent);
  51. }
  52. reqPromise("patient/family_contract/getSignMessage",{patientCode:userAgent.represented?userAgent.represented:userAgent.uid})
  53. .then(function(data) {
  54. var groups = handleData(data.list),
  55. familyList = groups[2] || [],
  56. sanshiList = groups[1] || [];
  57. return {
  58. familyDoctor: familyList[0],
  59. sanShiDoctor: (function() {
  60. return _.find(sanshiList,function(obj) {
  61. return obj.level==2;
  62. });
  63. })()
  64. }
  65. }).then(function(doctors) {
  66. //判断是否是从续签页面跳转过来的
  67. var referrer = document.referrer;
  68. if(referrer.indexOf("xuqian") == -1){
  69. var renew = window.localStorage.getItem("is_renew");
  70. if(renew){
  71. window.localStorage.removeItem("is_renew");
  72. }
  73. }
  74. if(doctors.familyDoctor && !Request.renew) {
  75. window.location.href = server + "wx/html/ssgg/html/doctor-homepage-new.html?state="+doctors.familyDoctor.code+"&openid="+userAgent.openid;
  76. }
  77. /* 屏蔽三师签约的逻辑
  78. else if(existedSanShi || doctors.sanShiDoctor) {
  79. var name = decodeURIComponent(doctorName||doctors.sanShiDoctor.name);
  80. var content = '您已存在三师签约,签约医生为'+ name +'医生,继续与'+name+'医生签约家庭医生服务吗?';
  81. dialog({
  82. content: content,
  83. okValue:'确定',
  84. ok: function (){
  85. window.location.href = server + "wx/html/ssgg/html/doctor-homepage-new.html?state="+(doctor||doctors.sanShiDoctor.code)+"&openid="+userAgent.openid;
  86. }
  87. }).showModal();
  88. return false;
  89. } */
  90. }).then(function(flag) {
  91. if(flag!==false) {
  92. // TODO 目前项目只有厦门,所以city设置为350200
  93. reqPromise("patient/hosptail/getTownByCityCode",{city:'350200'}).then(function(data) {
  94. // TODO 示例数据
  95. // data = {"msg":"查询成功","list":[{"code":"350203","name":"思明区"},{"code":"350205","name":"海沧区"},{"code":"350206","name":"湖里区"},{"code":"350211","name":"集美区"},{"code":"350212","name":"同安区"},{"code":"350213","name":"翔安区"}],"status":200}
  96. var html = template("area_li_tmpl", data);
  97. $areaList.html(html);
  98. d.close();
  99. }).catch(function(e) {
  100. console && console.error(e)
  101. })
  102. }
  103. }).catch(function(e) {
  104. console && console.error(e)
  105. });
  106. template.helper('getHospitalImg', function(str){
  107. var url = getImgUrl(str);
  108. if(url == ''){
  109. url = '../images/hospital_default.png';
  110. }
  111. return url;
  112. });