signing_management.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. var d = dialog({
  2. contentType: 'load',
  3. skin: 'bk-popup'
  4. });
  5. var pagetype = 31;
  6. var isOverdue = false; //判断是否有已经生效的过期的记录
  7. var popoverData;
  8. $(function() {
  9. checkUserAgent();
  10. });
  11. var scroller = new IScrollPullUpDown('wrapper5', {
  12. probeType: 2,
  13. bounceTime: 250,
  14. bounceEasing: 'quadratic',
  15. mouseWheel: false,
  16. scrollbars: true,
  17. click: true,
  18. fadeScrollbars: true,
  19. interactiveScrollbars: false
  20. }, null, null);
  21. function queryInit() {
  22. appendFamilyMember($('#memberContainer'), function() {
  23. $("#signList").empty();
  24. $("#wrapper5").show();
  25. $("#other_view").hide();
  26. $('#require_sign').hide();
  27. getInfo();
  28. }, function() {
  29. //判断有授权家人,修改样式
  30. if($('#memberContainer').is(':hidden')) {
  31. $('#wrapper5').css('top', 80);
  32. $('#other_view').css('padding-top', '150px');
  33. } else {
  34. $('#wrapper5').css('top', $('.mui-content').height() + 90);
  35. $('#other_view').css('padding-top', '90px');
  36. $('#memberContainer').css({
  37. 'margin-top': $('.mui-content').height(),
  38. 'height': '90px',
  39. 'position': 'relative'
  40. });
  41. }
  42. });
  43. getInfo();
  44. bindEvents();
  45. popover()
  46. }
  47. function popover() {
  48. var url = "/patient/prescription/pay/getPopups",
  49. params = {
  50. type: 0
  51. };
  52. sendPost(url, params, 'JSON', 'GET', queryFailed, function(res) {
  53. if(res.status == 200) {
  54. popoverData = res.data;
  55. } else {
  56. queryFailed(res);
  57. }
  58. })
  59. }
  60. function getInfo() {
  61. d.show();
  62. var url = "/patient/sign/signs",
  63. params = {};
  64. sendPost(url, params, "json", "post", queryFailed, querySuccess);
  65. }
  66. function queryFailed(res) {
  67. d.close();
  68. if(res && res.msg) {
  69. dialog({
  70. contentType: 'tipsbox',
  71. skin: 'bk-popup',
  72. content: res.msg
  73. }).show();
  74. } else {
  75. dialog({
  76. contentType: 'tipsbox',
  77. skin: 'bk-popup',
  78. content: '加载失败'
  79. }).show();
  80. }
  81. }
  82. function querySuccess(res) {
  83. d.close();
  84. if(res.status == 200) {
  85. if(res.data.length == 0) {
  86. // $("body").removeClass("bgc-f3f3f3").addClass("bgc-9beaf6");
  87. $("#wrapper5").hide();
  88. $("#other_view").show();
  89. } else {
  90. // $("body").addClass("bgc-f3f3f3").removeClass("bgc-9beaf6");
  91. $("#wrapper5").show();
  92. $("#other_view").hide();
  93. var slider = mui("#slider");
  94. slider.slider({
  95. interval: 2000
  96. });
  97. if($('#memberContainer').is(':hidden')) {
  98. $('#wrapper5').css('top', $('.mui-content').height());
  99. } else {
  100. $('#wrapper5').css('top', $('.mui-content').height() + 90);
  101. }
  102. //签约状态(-1患者已取消,-2已拒绝,-3已解约,-4已到期,0待签约,1已签约,2患者申请取消签约,3医生申请取消签约
  103. var addNew = true;
  104. var userAgent = JSON.parse(window.localStorage.getItem(agentName));
  105. var isMe = false;
  106. if(userAgent.represented == userAgent.uid || userAgent.represented == undefined) {
  107. isMe = true;
  108. }
  109. for(i = 0; i < res.data.length; i++) {
  110. var status = res.data[i].status,
  111. type = res.data[i].type; //type : 1-三师签约,2-家庭签约
  112. if(type == 2 && (status == "0" || status == "1")) {
  113. addNew = false;
  114. }
  115. //判断签约年限
  116. var signYear = parseInt(res.data[i].end.substr(0, 4)) - 1;
  117. //当前年度
  118. var now = new Date(),
  119. nowSignYear;
  120. if(now > new Date(now.getFullYear(), 06, 01)) { //大于6月30号为新年度
  121. nowSignYear = now.getFullYear();
  122. } else {
  123. nowSignYear = now.getFullYear() - 1;
  124. }
  125. if(type == 2 && (status == "-4") && (res.data[i].expensesStatus == "1") && signYear == (nowSignYear - 1)) {
  126. isOverdue = true;
  127. }
  128. }
  129. addNew && $("#require_sign").show();
  130. var list = _.map(res.data, function(o) {
  131. var consultDoctor = o.doctorHealth ? o.doctorHealth : o.doctor;
  132. o.consultDoctor = consultDoctor;
  133. o.jsonStr = JSON.stringify(o);
  134. o.isMe = isMe;
  135. return o;
  136. });
  137. var html = template("list_tmp", {
  138. list: list
  139. });
  140. $("#signList").append(html);
  141. scroller.myScroll.refresh();
  142. }
  143. } else {
  144. dialog({
  145. contentType: 'tipsbox',
  146. skin: 'bk-popup',
  147. content: res.msg
  148. }).show();
  149. }
  150. }
  151. function bindEvents() {
  152. $("body").on('tap', ".view-agreement", function(event) {
  153. event.stopPropagation();
  154. window.location.href = "agreement.html?readonly=1";
  155. })
  156. .on('tap', ".sign-info", function() {
  157. var jsonObj = $(this).attr("data-json");
  158. jsonObj && (jsonObj = JSON.parse(jsonObj));
  159. var code = jsonObj.code,
  160. teamCode = jsonObj.teamCode,
  161. type = jsonObj.type,
  162. doctorHealth = jsonObj.consultDoctor,
  163. status = jsonObj.status,
  164. renew = jsonObj.isRenew;
  165. if(type == 1) {
  166. //三师签约不跳转
  167. } else {
  168. window.location.href = "sign_info.html?code=" + code + "&teamCode=" + teamCode + "&type=" + type + "&doctor=" + doctorHealth + "&status=" + status + "&isRenew=" + renew;
  169. }
  170. })
  171. .on('tap', '.to-pay', function(e) {
  172. var $this = $(this)
  173. e.stopPropagation();
  174. //判断是否可以在线支付
  175. if(!canPayOnline) {
  176. dialog({
  177. content: '缴费功能即将开放,请耐心等待~如需线下缴费,可前往社区卫生服务中心缴费',
  178. okValue: '知道了',
  179. ok: function() {}
  180. }).showModal();
  181. return false;
  182. }
  183. if(popoverData == 1) {
  184. //询问框
  185. layer.open({
  186. area:['auto'],
  187. title: ['温馨提示', 'font-weight:700;font-size:16px;height:40px;line-height:40px;'],
  188. content: '<div id="content_div" class="content_bg c-t-left">\
  189. 签约在线缴费需使用实名且与医保卡同名的微信公众号进行绑卡及缴费,如需为家人代理缴费,需先到市行政服务中心申请家庭共济关系后,才可以绑定家人的医保卡并缴费哟~\
  190. </br>\
  191. <div class="c-t-center mtb10">\
  192. <label class="input-group-checkbox" style="color: #40AFFE">\
  193. <div class="input-group-pack">\
  194. <input id="input_1" type="checkbox">\
  195. <span class="tick"></span>\
  196. </div>\
  197. 下次不再提醒\
  198. </label>\
  199. </div>\
  200. </div>',
  201. btn: ['<div id="jiaofei">开始缴费</div>', '<div id="bujiaofei">暂不缴费</div>'],
  202. shadeClose: false,
  203. yes: function(index) {
  204. var checkedValue = $("#input_1").prop("checked"),
  205. val;
  206. if(checkedValue) {
  207. val = 0;
  208. } else {
  209. val = 1;
  210. }
  211. var url = "/patient/prescription/pay/savePopups",
  212. params = {
  213. type: 0,
  214. status: val
  215. };
  216. sendPost(url, params, 'JSON', 'POST', queryFailed, function(res) {
  217. if(res.status == 200) {
  218. var jsonObj = $this.parent().parent().attr("data-json");
  219. jsonObj && (jsonObj = JSON.parse(jsonObj));
  220. checkBindCard(jsonObj);
  221. } else {
  222. queryFailed(res);
  223. }
  224. });
  225. layer.close(index);
  226. },
  227. no: function(index) {
  228. location.reload();
  229. },
  230. });
  231. } else {
  232. var jsonObj = $this.parent().parent().attr("data-json");
  233. jsonObj && (jsonObj = JSON.parse(jsonObj));
  234. checkBindCard(jsonObj);
  235. }
  236. })
  237. .on('tap', '.pay-record', function(e) {
  238. e.stopPropagation();
  239. //判断是否可以在线支付
  240. if(!canPayOnline) {
  241. dialog({
  242. content: '服务维护中,暂时看不了线上的缴费记录',
  243. okValue: '知道了',
  244. ok: function() {}
  245. }).showModal();
  246. return false;
  247. }
  248. var jsonObj = $(this).parent().parent().attr("data-json");
  249. jsonObj && (jsonObj = JSON.parse(jsonObj));
  250. var payParams = {
  251. code: jsonObj.code,
  252. teamCode: jsonObj.teamCode,
  253. type: jsonObj.type,
  254. doctorHealth: jsonObj.doctor,
  255. status: jsonObj.status,
  256. renew: jsonObj.isRenew,
  257. exstatus: jsonObj.expensesStatus,
  258. payCode: jsonObj.chargeCode,
  259. showResult: true //标记直接根据交易码获取缴费信息,区别在线支付回调
  260. };
  261. payParams = JSON.stringify(payParams);
  262. window.localStorage.setItem("payParams", payParams);
  263. window.location.href = "pay_result.html";
  264. });
  265. $("#require_sign").on('click', function() {
  266. // location.href = "select-doctor.html";
  267. if(isOverdue) {
  268. location.href = "../../xuqian/html/information.html";
  269. } else {
  270. location.href = "select-doctor.html";
  271. }
  272. });
  273. $('#sign_family_doctor_btn').click(function() {
  274. location.href = "select-doctor.html";
  275. });
  276. $("body").on("tap", ".unsign-info", function() {
  277. //审核中的信息跳转去医生主页
  278. var doctor = $(this).attr("data-code"),
  279. isRenew = $(this).attr("data-renew");
  280. location.href = "doctor-index.html?id=" + doctor + "&status=0&renew=" + isRenew;
  281. });
  282. //勾选框
  283. $('.piaochecked').click(function () {
  284. if ($(this).hasClass('on_check')) {
  285. $('.input_checked').prop("checked", false);
  286. $(this).removeClass('on_check');
  287. } else {
  288. $('.input_checked').prop("checked", true);
  289. $(this).addClass('on_check');
  290. }
  291. })
  292. }
  293. function checkBindMobile(cb) {
  294. var url = "patient/prescription/pay/getPatientMobile"
  295. sendPost(url, {}, "json", "get", queryFailed, function(res) {
  296. if(res.status == 200) {
  297. if(res.data == 1) {
  298. cb && cb()
  299. } else {
  300. d.close();
  301. dialog({
  302. content: '您当前暂未绑定手机,无法在线缴费,请点击确认完成手机号码绑定',
  303. cancelValue: '取消',
  304. cancel: function() {},
  305. okValue: '确认',
  306. ok: function() {
  307. window.location.href = "../../home/html/bind-mobile.html"
  308. }
  309. }).showModal();
  310. }
  311. } else {
  312. queryFailed(res);
  313. }
  314. })
  315. }
  316. function checkBindCard(jsonObj){
  317. d.show();
  318. var url = "patient/bindCard",
  319. params = {};
  320. sendPost(url, params, "json", "post", queryFailed, function(res) {
  321. if(res.status == 200) {
  322. if(res.data.bindStatus == '000000') {
  323. checkBindMobile(function() {
  324. //已绑卡,跳转去缴费页面
  325. charge(jsonObj);
  326. })
  327. } else if(res.data.bindStatus == '030007') {
  328. d.close();
  329. dialog({
  330. content: '当前未绑定电子社保卡,无法进行线上缴费,是否立即绑定',
  331. cancelValue: '不了,谢谢',
  332. cancel: function() {},
  333. okValue: '是',
  334. ok: function() {
  335. //需要将签约的code缓存起来用在绑卡成功后的回调页面中
  336. var obj = {
  337. signCode: jsonObj.code
  338. };
  339. window.localStorage.setItem('request_info', JSON.stringify(obj))
  340. window.location.href = res.data.sicardUrl;
  341. }
  342. }).showModal();
  343. }
  344. } else {
  345. queryFailed(res);
  346. }
  347. });
  348. }
  349. //发起缴费申请
  350. function charge(signInfo) {
  351. var url = "/patient/charge",
  352. params = {
  353. orgCode: signInfo.hospital,
  354. chargeType: 1,
  355. chargeRelation: signInfo.code,
  356. totalAmount: 12000
  357. };
  358. sendPost(url, params, 'json', 'post', queryFailed, function(res) {
  359. d.close();
  360. if(res.status == 200) {
  361. //跳转去缴费页面
  362. window.location.href = res.data;
  363. } else {
  364. queryFailed(res);
  365. }
  366. });
  367. }
  368. template.helper("formatDate", function(str) {
  369. if(str) {
  370. return str.substr(0, 10);
  371. } else {
  372. return "";
  373. }
  374. });
  375. function goToWlc() {
  376. window.location.href = "signing-welcome.html?isOverdue=" + isOverdue;
  377. }