argument.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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. //判断当前时间是否在2017年度
  19. // var date = new Date();
  20. // if(date.getFullYear() != 2017){
  21. // dialog({
  22. // content: "对不起,2017年度续签工作已结束,无法发起续签工作",
  23. // okValue: "我知道了",
  24. // ok: function(){}
  25. // }).showModal();
  26. // return false;
  27. // }else{
  28. // if(referrer.indexOf("xuqian/html/information.html") == -1){
  29. checkRenewEnable();
  30. // }else{
  31. // showDialogInfo(signStatus);
  32. // }
  33. // }
  34. });
  35. $("#changeDoctor").on("click", function(){
  36. window.localStorage.setItem("is_renew", "1");
  37. window.location.href = "../../qygl/html/select-doctor.html?renew=1";
  38. });
  39. });
  40. function checkRenewEnable(){
  41. //判断是否可以续签
  42. var url = "/patient/family_contract/checkCanRenew",
  43. params = {patient: userAgent.represented?userAgent.represented:userAgent.uid};
  44. d.show();
  45. sendPost(url, params, "json", "post", reqFailed , function(res){
  46. if(res.status == 200){
  47. d.close();
  48. var code = res.data.code,
  49. msg = res.data.mes,
  50. enable = true;
  51. switch (parseInt(code)){
  52. case -5:
  53. msg = "医生已同意您的续签,您无需再次签约";
  54. enable = false;
  55. break;
  56. case -4:
  57. msg = "您当前无可续签的家庭医生,可在签约管理页面签约医生";
  58. enable = false;
  59. break;
  60. case -3:
  61. //已经提交续签申请了
  62. msg = "您已提交过申请,无需重复提交";
  63. enable = false;
  64. break;
  65. case -2:
  66. msg = "您已完成2017~2018年度签约,不能再次签约";
  67. enable = false;
  68. break;
  69. case -1:
  70. msg = "当前时间段不允许续签,可前往签约管理页面签约医生";
  71. enable = false;
  72. break;
  73. case 0:
  74. msg = "患者数据有误";
  75. enable = false;
  76. break;
  77. }
  78. if(!enable){
  79. if(code == "-4" || code == "-1"){
  80. dialog({
  81. content: msg,
  82. okValue: "我知道了",
  83. ok: function(){
  84. location.href = "../../qygl/html/signing_management.html";
  85. }
  86. }).showModal();
  87. }else{
  88. dialog({
  89. content: msg,
  90. okValue: "我知道了",
  91. ok: function(){
  92. }
  93. }).showModal();
  94. }
  95. }else{
  96. showDialogInfo(code);
  97. }
  98. }else{
  99. reqFailed(res);
  100. }
  101. });
  102. }
  103. //弹框信息
  104. function showDialogInfo(status){
  105. if(status == 1){
  106. if(parseInt(changeDoctor)){
  107. if(isSignLimit){
  108. dialog({
  109. content: doctors.join("、")+"医生签约人数已达上限,请重新选择签约医生",
  110. okValue: "选择其他医生",
  111. ok: function(){
  112. window.localStorage.setItem("is_renew", "1");
  113. window.location.href = "../../qygl/html/select-doctor.html?renew=1";
  114. },
  115. cancelValue: "我再看看",
  116. cancel: function(){}
  117. }).showModal();
  118. }else{
  119. dialog({
  120. content: "是否向"+doctors.join("、")+"提交续签申请?提交后无法变更",
  121. okValue: "立即提交",
  122. ok: function(){
  123. var renew = window.localStorage.getItem("is_renew");
  124. if(renew){
  125. window.localStorage.setItem("is_renew", "0");
  126. }
  127. renewSign();
  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. var url = "/patient/family_contract/getSignMessageOverdue",
  186. params = {patientCode: patient};
  187. d.show();
  188. sendPost(url, params, "json", "get", reqFailed, function(res){
  189. if(res.status == 200){
  190. d.close();
  191. var len = res.list.length;
  192. for(i=0; i< len; i++){
  193. var item = res.list[i];
  194. if(item.level == 2){
  195. doctor = item.code;
  196. doctorName = item.name;
  197. }
  198. if(item.level == 3){
  199. healthDoctor = item.code;
  200. healthDoctorName = item.name;
  201. }
  202. }
  203. if(doctorName){
  204. doctors.push(doctorName);
  205. }
  206. if(healthDoctorName){
  207. doctors.push(healthDoctorName);
  208. }
  209. getDoctorInfo(function(){
  210. if(parseInt(changeDoctor)){
  211. if(isSignLimit){
  212. dialog({
  213. content: doctors.join("、")+"医生签约人数已达上限,请重新选择签约医生",
  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. }else{
  223. dialog({
  224. content: "是否向"+doctors.join("、")+"提交续签申请?提交后无法变更",
  225. okValue: "立即提交",
  226. ok: function(){
  227. var renew = window.localStorage.getItem("is_renew");
  228. if(renew){
  229. window.localStorage.setItem("is_renew", "0");
  230. }
  231. renewSign();
  232. },
  233. cancelValue: "我再看看",
  234. cancel: function(){}
  235. }).showModal();
  236. }
  237. }else{
  238. var content = "";
  239. if(isSignLimit){
  240. content = doctors.join("、")+"医生签约人数已达上限,请重新选择签约医生";
  241. $("#renewSign").hide();
  242. }else{
  243. content = "是否向"+doctors.join("、")+"提交续签申请?提交后无法变更";
  244. }
  245. $("#remind-msg").text(content);
  246. mui('#sheet1').popover('toggle');
  247. }
  248. });
  249. }else{
  250. reqFailed(res);
  251. }
  252. });
  253. }
  254. //获取医生是否签约达到上限
  255. function getDoctorInfo(cb){
  256. var url = 'family_contract/homepage/homepage',
  257. data = {doctor: doctor};
  258. sendPost(url, data, 'json', 'post', reqFailed, function(res){
  259. if(res.status == 200){
  260. //判断签约人数是否达到上限
  261. if(res.data.signTotal >= res.data.limitTotal){
  262. isSignLimit = true;
  263. }
  264. if(cb && (typeof cb == "function")){
  265. cb();
  266. }
  267. }else{
  268. reqFailed(res);
  269. }
  270. });
  271. }
  272. //续签
  273. function renewSign(){
  274. var url = "/patient/family_contract/signRenew",
  275. params = {
  276. doctor: doctor || "",
  277. healthDoctor: healthDoctor || "",
  278. patient: patient
  279. };
  280. d.show();
  281. sendPost(url, params, "json", "post", reqFailed, function(res){
  282. if(res.status == 200){
  283. d.close();
  284. window.location.href = "../../qygl/html/signing_management.html";
  285. }else{
  286. reqFailed(res);
  287. }
  288. })
  289. }
  290. function reqFailed(res){
  291. d.close();
  292. if(res.msg){
  293. dialog({
  294. contentType:'tipsbox',
  295. bottom:true,
  296. skin:'bk-popup',
  297. content: res.msg
  298. }).show();
  299. }else{
  300. dialog({
  301. contentType:'tipsbox',
  302. bottom:true,
  303. skin:'bk-popup',
  304. content: "请求失败,请重试"
  305. }).show();
  306. }
  307. }
  308. function notSignFlow(){
  309. dialog({
  310. content: "您当前未签约家庭医生,是否前往签约家庭医生?",
  311. okValue: "签约家庭医生",
  312. ok: function(){
  313. location.href = "../../qygl/html/select-doctor.html";
  314. },
  315. cancelValue: "不了,谢谢",
  316. cancel: function(){}
  317. }).showModal();
  318. }
  319. function preSignedFlow(){
  320. dialog({
  321. content: "您已完成2017~2018年度预签约,不能再次签约",
  322. okValue: "我知道了",
  323. ok:{}
  324. }).showModal();
  325. }