argument.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. var d = dialog({contentType:'load', skin:'bk-popup', content:''});
  2. var userAgent = localStorage.getItem(agentName);
  3. var patient, doctor, healthDoctor, doctorName, healthDoctorName;
  4. var doctors = [];
  5. var request = GetRequest();
  6. var changeDoctor = request.changeDoctor; //标记是否是从医生发起的模板消息
  7. var request = GetRequest();
  8. var signStatus = request.signStatus;
  9. var isSignLimit = false; //判断签约人数是否达到上限
  10. if(userAgent){
  11. userAgent = JSON.parse(userAgent);
  12. patient = userAgent.represented?userAgent.represented:userAgent.uid;
  13. }
  14. $(function() {
  15. // var referrer = document.referrer;
  16. getSignMessage();
  17. $('#agree_btn').on('click',function() {
  18. //判断协议checkbox是否选中
  19. var $checkbox = $("#agree-checkbox");
  20. if(!$checkbox.prop("checked")){
  21. dialog({
  22. content:'您还未同意家庭医生签约协议',
  23. skin:'bk-popup',
  24. contentType:'tipsbox',
  25. bottom: true
  26. }).show();
  27. return false;
  28. }else{
  29. checkRenewEnable();
  30. }
  31. });
  32. $("#changeDoctor").on("click", function(){
  33. window.localStorage.setItem("is_renew", "1");
  34. window.location.href = "../../qygl/html/select-doctor.html?renew=1";
  35. });
  36. });
  37. function checkRenewEnable(){
  38. //判断是否可以续签
  39. var url = "/patient/family_contract/checkCanRenew",
  40. params = {patient: userAgent.represented?userAgent.represented:userAgent.uid};
  41. d.show();
  42. sendPost(url, params, "json", "post", reqFailed , function(res){
  43. if(res.status == 200){
  44. d.close();
  45. var code = res.data.code,
  46. msg = res.data.mes,
  47. enable = true;
  48. var now = new Date(),
  49. signYear = now.getFullYear()+"~"+(now.getFullYear()+1);
  50. switch (parseInt(code)){
  51. case -5:
  52. msg = "医生已同意您的续签,您无需再次签约";
  53. enable = false;
  54. break;
  55. case -4:
  56. msg = "您当前无可续签的家庭医生,可在签约管理页面签约医生";
  57. enable = false;
  58. break;
  59. case -3:
  60. //已经提交续签申请了
  61. msg = "您已提交过申请,无需重复提交";
  62. enable = false;
  63. break;
  64. case -2:
  65. msg = "您已完成"+signYear+"年度签约,不能再次签约";
  66. enable = false;
  67. break;
  68. case -1:
  69. msg = "当前时间段不允许续签,可前往签约管理页面签约医生";
  70. enable = false;
  71. break;
  72. case 0:
  73. msg = "患者数据有误";
  74. enable = false;
  75. break;
  76. }
  77. if(!enable){
  78. if(code == "-4" || code == "-1"){
  79. dialog({
  80. content: msg,
  81. okValue: "我知道了",
  82. ok: function(){
  83. location.href = "../../qygl/html/signing_management.html";
  84. }
  85. }).showModal();
  86. }else{
  87. dialog({
  88. content: msg,
  89. okValue: "我知道了",
  90. ok: function(){
  91. }
  92. }).showModal();
  93. }
  94. }else{
  95. showDialogInfo(code);
  96. }
  97. }else{
  98. reqFailed(res);
  99. }
  100. });
  101. }
  102. //弹框信息
  103. function showDialogInfo(status){
  104. if(status == 1){
  105. if(parseInt(changeDoctor)){
  106. if(isSignLimit){
  107. dialog({
  108. content: doctors.join("、")+"医生签约人数已达上限,请重新选择签约医生",
  109. okValue: "选择其他医生",
  110. ok: function(){
  111. window.localStorage.setItem("is_renew", "1");
  112. window.location.href = "../../qygl/html/select-doctor.html?renew=1";
  113. },
  114. cancelValue: "我再看看",
  115. cancel: function(){}
  116. }).showModal();
  117. }else{
  118. dialog({
  119. content: "您希望"+doctors.join("、")+"继续作为家庭医生,为您提供健康服务吗?",
  120. okValue: "立即提交",
  121. ok: function(){
  122. var renew = window.localStorage.getItem("is_renew");
  123. if(renew){
  124. window.localStorage.setItem("is_renew", "0");
  125. }
  126. // renewSign();
  127. getBaseInfo(); //获取是否有医疗保险号信息,没有需弹框提示患者输入
  128. },
  129. cancelValue: "我再看看",
  130. cancel: function(){}
  131. }).showModal();
  132. }
  133. }else{
  134. var content = "";
  135. if(isSignLimit){
  136. content = doctors.join("、")+"医生签约人数已达上限,请重新选择签约医生";
  137. $("#renewSign").hide();
  138. }else{
  139. content = "您希望"+doctors.join("、")+"继续作为家庭医生,为您提供健康服务吗?";
  140. }
  141. $("#remind-msg").text(content);
  142. mui('#sheet1').popover('toggle');
  143. }
  144. }
  145. if(status == 2){ //签约过期的患者
  146. getOverdueSignMessage();
  147. }
  148. }
  149. /*获取签约信息*/
  150. function getSignMessage(){
  151. d.show();
  152. var url = "/patient/family_contract/getSignMessage",
  153. params = {patientCode: patient};
  154. sendPost(url, params, "json", "post", reqFailed, function(res){
  155. if(res.status == 200){
  156. d.close();
  157. var len = res.list.length;
  158. for(i=0; i< len; i++){
  159. var item = res.list[i];
  160. if(item.level == 2){
  161. doctor = item.code;
  162. doctorName = item.name;
  163. }
  164. if(item.level == 3){
  165. healthDoctor = item.code;
  166. healthDoctorName = item.name;
  167. }
  168. }
  169. if(doctorName){
  170. doctors.push(doctorName);
  171. }
  172. if(healthDoctorName){
  173. doctors.push(healthDoctorName);
  174. }
  175. if(doctor){
  176. getDoctorInfo();
  177. }
  178. }else{
  179. reqFailed(res);
  180. }
  181. });
  182. }
  183. //获取已过期的签约信息
  184. function getOverdueSignMessage(){
  185. doctors.length=0;
  186. var url = "/patient/family_contract/getSignMessageOverdue",
  187. params = {patientCode: patient};
  188. d.show();
  189. sendPost(url, params, "json", "get", reqFailed, function(res){
  190. if(res.status == 200){
  191. d.close();
  192. var len = res.list.length;
  193. for(i=0; i< len; i++){
  194. var item = res.list[i];
  195. if(item.level == 2){
  196. doctor = item.code;
  197. doctorName = item.name;
  198. }
  199. if(item.level == 3){
  200. healthDoctor = item.code;
  201. healthDoctorName = item.name;
  202. }
  203. }
  204. if(doctorName){
  205. doctors.push(doctorName);
  206. }
  207. if(healthDoctorName){
  208. doctors.push(healthDoctorName);
  209. }
  210. //如果获取不到全科医生的信息,即全科医生变成健管师
  211. if(!doctor){
  212. dialog({
  213. content: "您要续签的医生不再提供全科服务,请重选续签医生~",
  214. okValue: "选择其他医生",
  215. ok: function(){
  216. window.localStorage.setItem("is_renew", "1");
  217. window.location.href = "../../qygl/html/select-doctor.html?renew=1";
  218. },
  219. cancelValue: "我再看看",
  220. cancel: function(){}
  221. }).showModal();
  222. return false;
  223. }
  224. getDoctorInfo(function(){
  225. if(parseInt(changeDoctor)){
  226. if(isSignLimit){
  227. dialog({
  228. content: doctors.join("、")+"医生签约人数已达上限,请重新选择签约医生",
  229. okValue: "选择其他医生",
  230. ok: function(){
  231. window.localStorage.setItem("is_renew", "1");
  232. window.location.href = "../../qygl/html/select-doctor.html?renew=1";
  233. },
  234. cancelValue: "我再看看",
  235. cancel: function(){}
  236. }).showModal();
  237. }else{
  238. dialog({
  239. content: "您希望"+doctors.join("、")+"继续作为家庭医生,为您提供健康服务吗?",
  240. okValue: "立即提交",
  241. ok: function(){
  242. var renew = window.localStorage.getItem("is_renew");
  243. if(renew){
  244. window.localStorage.setItem("is_renew", "0");
  245. }
  246. // renewSign();
  247. getBaseInfo(); //获取是否有医疗保险号信息,没有需弹框提示患者输入
  248. },
  249. cancelValue: "我再看看",
  250. cancel: function(){}
  251. }).showModal();
  252. }
  253. }else{
  254. var content = "";
  255. if(isSignLimit){
  256. content = doctors.join("、")+"医生签约人数已达上限,请重新选择签约医生";
  257. $("#renewSign").hide();
  258. }else{
  259. content = "您希望"+doctors.join("、")+"继续作为家庭医生,为您提供健康服务吗?";
  260. }
  261. $("#remind-msg").text(content);
  262. mui('#sheet1').popover('toggle');
  263. }
  264. });
  265. }else{
  266. reqFailed(res);
  267. }
  268. });
  269. }
  270. //获取医生是否签约达到上限
  271. function getDoctorInfo(cb){
  272. var url = 'family_contract/homepage/homepage',
  273. data = {doctor: doctor};
  274. sendPost(url, data, 'json', 'post', reqFailed, function(res){
  275. if(res.status == 200){
  276. //判断签约人数是否达到上限
  277. if(res.data.signTotal >= res.data.limitTotal){
  278. isSignLimit = true;
  279. }
  280. if(cb && (typeof cb == "function")){
  281. cb();
  282. }
  283. }else{
  284. reqFailed(res);
  285. }
  286. });
  287. }
  288. var medicareNumber = "";
  289. //获取是否有医疗保险号信息,没有需弹框提示患者输入
  290. function getBaseInfo(){
  291. var submited = false
  292. sendPost('patient/baseinfo', {}, 'json', 'post', reqFailed, function(res) {
  293. if(res.status == 200){
  294. if(res.data.medicareNumber){
  295. medicareNumber = res.data.medicareNumber;
  296. renewSign();
  297. }else{
  298. mui('#sheet1').popover('toggle');
  299. var width = window.innerWidth - 50 - 30;
  300. var content = '<div>请完善医疗保险信息</div>'+
  301. '<div><input type="text" class="c-f14" style="width:'+width+'px" id="medicareNumber" placeholder="输入医疗保险号"></div>'+
  302. '<div class="warning-text c-hide"><span>* 医疗保险号不能为空!</span></div>';
  303. dialog({
  304. content: content,
  305. okValue: "立即提交",
  306. ok: function(){
  307. if(submited === false) {
  308. submited = true
  309. medicareNumber = $("#medicareNumber").val();
  310. if(!medicareNumber){
  311. $("#medicareNumber").focus();
  312. $("#medicareNumber").addClass("required-input");
  313. $(".warning-text").show();
  314. return false;
  315. }else{
  316. renewSign();
  317. }
  318. }
  319. },
  320. cancelValue: "我再看看",
  321. cancel: function(){}
  322. }).showModal();
  323. }
  324. }else{
  325. reqFailed(res);
  326. }
  327. });
  328. }
  329. //续签
  330. function renewSign(){
  331. //续签时,需要获取患者的医疗保险号
  332. var url = "/patient/family_contract/signRenew",
  333. params = {
  334. doctor: doctor || "",
  335. healthDoctor: healthDoctor || "",
  336. patient: patient,
  337. medicareNumber: medicareNumber
  338. };
  339. d.showModal();
  340. sendPost(url, params, "json", "post", reqFailed, function(res){
  341. if(res.status == 200){
  342. d.close();
  343. window.location.href = "../../qygl/html/signing_management.html";
  344. }else{
  345. reqFailed(res);
  346. }
  347. })
  348. }
  349. function reqFailed(res){
  350. d.close();
  351. if(res.msg){
  352. dialog({
  353. contentType:'tipsbox',
  354. bottom:true,
  355. skin:'bk-popup',
  356. content: res.msg
  357. }).show();
  358. }else{
  359. dialog({
  360. contentType:'tipsbox',
  361. bottom:true,
  362. skin:'bk-popup',
  363. content: "请求失败,请重试"
  364. }).show();
  365. }
  366. }
  367. function notSignFlow(){
  368. dialog({
  369. content: "您当前未签约家庭医生,是否前往签约家庭医生?",
  370. okValue: "签约家庭医生",
  371. ok: function(){
  372. location.href = "../../qygl/html/select-doctor.html";
  373. },
  374. cancelValue: "不了,谢谢",
  375. cancel: function(){}
  376. }).showModal();
  377. }
  378. function preSignedFlow(){
  379. dialog({
  380. content: "您已完成2017~2018年度预签约,不能再次签约",
  381. okValue: "我知道了",
  382. ok:{}
  383. }).showModal();
  384. }