var postUrl = "doctor/sign/sign_info"; var docType; var curType; var curTypeGroup2 = 3; //记录当前续签管理下选中的tab值 var yqy_iscroll, dqy_iscroll, djf_iscroll; var xq_dcl_iscroll, xq_djf_iscroll, xq_yxq_iscroll; //续签相关tab页面的iscroll var date = new Date(), dateStr = date.format("yyyy-MM-dd"); mui.plusReady(function() { docType = plus.storage.getItem("docType"); $('.qy-barner').removeClass('c-hide'); var self = plus.webview.currentWebview(); var type = curType || self.type || 0; $(".sign-comonhd").find(".sanp-flex").eq(self.type).click(); // 初始化签约管理增加签约统计功能,分别统计待审核、待缴费、已签约数量。在三个页切按钮下方增加统计数字 getSignCount(handleSucc9); yqy_iscroll = $('#yqy_list').lscroll({id: "yqy_iscroll", top: 67, pullUpAction: function(g){ loadMore("#yqy_list", 3, g.options.page); }, pullDownAction: function(g){ g.options.page = 1; getData(3, 0, handleSucc3); }}); djf_iscroll = $('#djf_list').lscroll({id: "djf_iscroll", top: 67, pullUpAction: function(g){ loadMore("#djf_list", 5, g.options.page); }, pullDownAction: function(g){ g.options.page = 1; getData(5, 0, handleSucc5); }}); dqy_iscroll = $('#dqy_list').lscroll({id: "dqy_iscroll", top: 67, pullUpAction: function(g){ loadMore("#dqy_list", 1, g.options.page); }, pullDownAction: function(g){ g.options.page = 1; getData(1, 0, handleSucc1); }}); //初始化续签管理页面的iscroll xq_dcl_iscroll = $("#xq_dcl_list").lscroll({ id: "xq_dcl_iscroll", top: 67, pullUpAction: function(g){ loadMore("#xq_dcl_list", 6, g.options.page); }, pullDownAction: function(g){ g.options.page = 1; getXqData(1, handleSucc6); } }); xq_djf_iscroll = $("#xq_djf_list").lscroll({ id: "xq_djf_iscroll", top: 67, pullUpAction: function(g){ loadMore("#xq_djf_list", 7, g.options.page); }, pullDownAction: function(g){ g.options.page = 1; getXqData(2, handleSucc7); } }); xq_yxq_iscroll = $("#xq_yxq_list").lscroll({ id: "xq_yxq_iscroll", top: 67, pullUpAction: function(g){ loadMore("#xq_yxq_list", 8, g.options.page); }, pullDownAction: function(g){ g.options.page = 1; getXqData(3, handleSucc8); } }); //添加初始化续签中待处理的数据,有数据时,续签管理添加小红点 // getXqData(1, handleSucc6); back2home(); }); function getData(type, id, handelSucc, page) { sendPost(postUrl, { doctorType: docType, status: type, page: page || 1, pageSize: 10 }, null, handelSucc); }; function getXqData(status, handelSucc, page) { //status 1-待签约, 2-代缴费, 3-已签约 var url = "/doctor/sign/sign_info_renew"; sendPost(url, { status: status, page: page || 1, pageSize: 10 }, null, handelSucc); }; //签约管理增加签约统计功能,分别统计待审核、待缴费、已签约数量。在三个页切按钮下方增加统计数字 function getSignCount(handelSucc) { var url = "/doctor/sign/sign_info_count"; sendPost(url, {}, null, handelSucc); }; /* * 待签约 */ var dqyObj; function handleSucc1(res) { plus.nativeUI.closeWaiting(); if (res.status == 200) { if (res.data.list.length == 0) { $('#dqy_iscroll').hide().prev().show(); return; } $('#dqy_iscroll').prev().hide(); dqyObjList = _.map(res.data.list, function(o){ o.jsonStr = JSON.stringify(o); return o; }); dqyObj = {list: dqyObjList} ; dealTmpl(dqyObj, "dqy_tmpl", "dqy_list"); $('#dqy_iscroll').show(); isShowMore(res, dqy_iscroll); } else { mui.toast(res.msg); } } /* * 已签约 */ var yqyObj; function handleSucc3(res) { plus.nativeUI.closeWaiting(); if (res.status == 200) { if (res.data.list.length == 0) { $('#yqy_iscroll').hide().prev().show(); return; } $('#yqy_iscroll').prev().hide(); res.docType = docType; yqyObj = res.data; dealTmpl(yqyObj, "yqy_tmpl", "yqy_list"); $('#yqy_iscroll').show(); isShowMore(res, yqy_iscroll); } else { mui.toast(res.msg); } } /* * 待缴费 */ var djfObj; function handleSucc5(res) { plus.nativeUI.closeWaiting(); if (res.status == 200) { if (res.data.list.length == 0) { $('#djf_iscroll').hide().prev().show(); return; } $('#djf_iscroll').prev().hide(); res.docType = docType; djfObj = res.data; dealTmpl(djfObj, "djf_tmpl", "djf_list"); $('#djf_iscroll').show(); isShowMore(res, djf_iscroll); hasDtx(); } else { mui.toast(res.msg); } } /* * 续签管理 - 待处理 */ var xq_dclObj; function handleSucc6(res){ plus.nativeUI.closeWaiting(); if (res.status == 200) { if (res.data.list.length == 0) { $('#xq_dcl_iscroll').hide().prev().show(); return; } //给“续签管理”添加小红点 $("#sign2").next().addClass("red-dot"); $('#xq_dcl_iscroll').prev().hide(); res.docType = docType; var xq_dclObjList = _.map(res.data.list,function(o){ o.jsonStr = JSON.stringify(o); return o; }); xq_dclObj = {list: xq_dclObjList}; dealTmpl(xq_dclObj, "dqy_tmpl", "xq_dcl_list"); $('#xq_dcl_iscroll').show(); isShowMore(res, xq_dcl_iscroll); } else { mui.toast(res.msg); } } /* * 续签管理 - 待缴费 */ var xq_djfObj; function handleSucc7(res){ plus.nativeUI.closeWaiting(); if (res.status == 200) { if (res.data.list.length == 0) { $('#xq_djf_iscroll').hide().prev().show(); return; } $('#xq_djf_iscroll').prev().hide(); res.docType = docType; xq_djfObj = res.data; dealTmpl(xq_djfObj, "xq_yxq_tmpl", "xq_djf_list"); $('#xq_djf_iscroll').show(); isShowMore(res, xq_djf_iscroll); } else { mui.toast(res.msg); } } /* * 续签管理 - 待处理 */ var xq_yxqObj; function handleSucc8(res){ plus.nativeUI.closeWaiting(); if (res.status == 200) { if (res.data.list.length == 0) { $('#xq_yxq_iscroll').hide().prev().show(); return; } $('#xq_yxq_iscroll').prev().hide(); res.docType = docType; xq_yxqObj = res.data; dealTmpl(xq_yxqObj, "xq_yxq_tmpl", "xq_yxq_list"); $('#xq_yxq_iscroll').show(); isShowMore(res, xq_yxq_iscroll); } else { mui.toast(res.msg); } } //签约管理增加签约统计功能,分别统计待审核、待缴费、已签约数量。在三个页切按钮下方增加统计数字 (处理函数)) function handleSucc9(res){ plus.nativeUI.closeWaiting(); if (res.status == 200) { var _signdata = res.data; $('#Pending_contract').html(_signdata.waitSignCount); $('#Pending_payment').html(_signdata.waitPayCount); $('#Signed').html(_signdata.signCount); } } function hasDtx(){ sendPost("doctor/sign/is_remind_expenses_all", { }, null, function(res) { var $jfRemindAllBtn = $('#jf_all_tx'); if (res.status == 200) { if(res.data == "1") { // 已经全部提醒缴费 $jfRemindAllBtn.hide(); } else { $jfRemindAllBtn.show(); } } else { mui.toast(res.msg); } }) } //判断要不要显示加载更多 function isShowMore(res, curScroll){//res 数据moreObj 要显示或隐藏的加载更多按钮 // var pageNow=res.data.page;//当前第几页 // var pageAll=res.data.totalPage; //总共几页 curScroll.refresh(res.data.list.length < 10); } /* * 拼接模板数据 */ function dealTmpl(res, tmplId, ulId) { document.getElementById(ulId).innerHTML = template(tmplId, res); } function isShowRemindAllBtn() { sendPost("doctor/sign/is_remind_focus_all", { }, null, function(res) { var $remindAllBtn = $('#weixin_all_tx'); if (res.status == 200) { if(res.data == "1") { // 已经全部提醒关注 $remindAllBtn.hide(); } else { $remindAllBtn.show(); } } else { mui.toast(res.msg); } }) } $(function() { $(".sign-comonhd").find(".sanp-flex").click(function() { $(".sign-comonhd").find(".sanp-flex").removeClass("curr"); $(this).addClass("curr"); var type = $(this).index(); if(type < 3){ curType = type; }else{ curTypeGroup2 = type; } plus.nativeUI.showWaiting("加载中,请稍候..."); $(".posater-oper").hide().eq(type).show(); switch (type) { case 0: if (dqyObj) { plus.nativeUI.closeWaiting(); } else { getData(1, 0, handleSucc1); } break; case 1: if (djfObj) { plus.nativeUI.closeWaiting(); } else { getData(5, 0, handleSucc5); } break; case 2: if (yqyObj) { plus.nativeUI.closeWaiting(); } else { getData(3, 0, handleSucc3); isShowRemindAllBtn(); } break; case 3: if (xq_dclObj){ plus.nativeUI.closeWaiting(); } else { getXqData(1, handleSucc6); } break; case 4: if (xq_djfObj){ plus.nativeUI.closeWaiting(); } else { getXqData(2, handleSucc7); } break; case 5: if (xq_yxqObj){ plus.nativeUI.closeWaiting(); }else{ getXqData(3, handleSucc8); } break; } }); }); function toXiaoxiChuli(signStatus, jsonData){ plus.nativeUI.showWaiting(); var signStatus2 = 1; if(jsonData.renewFlag == "2"){ signStatus2 = "9"; }else if(jsonData.renewFlag == "1"){ signStatus2 = "8"; } sendPost("doctor/message/find", { sender: jsonData.patientCode, signStatus: signStatus2 }, null, function(res) { plus.nativeUI.closeWaiting(); if (res.status == 200) { if (res.data) { if(jsonData.renewFlag){ openWebview("xuqian_management.html", { patient: jsonData.patientCode, signCode: jsonData.code, renewFlag: jsonData.renewFlag, msgId: res.data.id, applyDate: jsonData.applyDate }); return ; } if(docType==3){ openWebviewExtras("xiaoxichuli_jg.html", { type: res.data.type, msgId: res.data.id, patiCode: res.data.sender, status: res.data.status, reason: res.data.reason, signStatus: res.data.signStatus, renewFlag: jsonData.renewFlag }) }else{ mui.openWindow('../html/xiaoxichuli.html', 'xiaoxichuli', { extras: { type: res.data.type, msgId: res.data.id, patiCode: res.data.sender, status: res.data.status, reason: res.data.reason, signStatus: res.data.signStatus, renewFlag: jsonData.renewFlag } }); } } else { // mui.toast("未找到相关申请信息!"); //屏蔽线上出现的消息已读的bug 17年6月和7月均出现过一次 console.log("未找到相关的申请信息!"); if(jsonData.renewFlag){ openWebview("xuqian_management.html", { patient: jsonData.patientCode, signCode: jsonData.code, renewFlag: jsonData.renewFlag, msgId: '', applyDate: jsonData.applyDate }); return ; } if(docType==3){ openWebviewExtras("xiaoxichuli_jg.html", { type: '', msgId: '', patiCode: jsonData.patientCode, reason: '', signStatus: jsonData.status, renewFlag: jsonData.renewFlag }) }else{ mui.openWindow('../html/xiaoxichuli.html', 'xiaoxichuli', { extras: { type: '', msgId: '', patiCode: jsonData.patientCode, reason: '', signStatus: jsonData.status, renewFlag: jsonData.renewFlag } }); } } } else { mui.toast(res.msg); } }) } /* * 待缴费查看基本信息 */ mui("#djf_list").on("tap", ".c-list-info", function() { var patient = $(this).parent().attr("data-patient"); plus.nativeUI.showWaiting(); sendPost("/doctor/patient_label_info/patient", {patient: patient}, null, function(res){ if(res.status==200){ sendGet("/doctor/admin-teams/team/members/"+ patient, {}, null, function(res1){ plus.nativeUI.closeWaiting(); if(res1.status==200){ openWebview("../../huanzhe/html/huanzhexinxi.html",{teamCode: res1.data.teamId, patiInfo: JSON.stringify(res.data), patiCode: res.data.code}); } else mui.toast(res1.msg) }) } else { plus.nativeUI.closeWaiting(); mui.toast(res.msg); } }) return false; }); /* * 提醒 */ mui("#djf_list").on("tap", ".c-dtx-action", function() { var $li = $(this).parent(); txjf($li.attr("data-patient"), $li.attr("data-name"), $(this)); return false; }); mui('#yqy_list').on("tap", ".c-to-remind-action", function() { var $li = $(this).parent(); txWeixin($li.attr("data-patient"), $li.attr("data-name"), $(this)); return false; }); mui("#djf_list").on("tap", ".c-ytx-action", function() { return false; }); /** * 全部提醒(缴费) */ $('#jf_all_tx').on("tap", function(){ mui.confirm("是否向所有未提醒过的未缴费居民发出缴费提醒?(如绑定手机号则短信提醒,如绑定微信则微信提醒)", "提示", ["立即提醒", "不了,谢谢"], function(e){ if(e.index == 0){ txjf("", "", "", 1); } }) }) $('#weixin_all_tx').on('tap',function() { mui.confirm("是否提醒所有未关注公众号的居民关注公众号?(居民如未绑定手机则无法提醒)", "提示", ["立即提醒", "不了,谢谢"], function(e){ if(e.index == 0){ txWeixin("", "", "", 1); } }) }) function txjf(patient, patientName, $dom, isAll){ plus.nativeUI.showWaiting(); sendPost("/doctor/family_contract/expenses_remind", {patient: patient || "", isAll: isAll || 0}, null, function(res){ plus.nativeUI.closeWaiting(); var $jfAllBtn = $('#jf_all_tx'); if(res.status == 200){ if(isAll==1){ mui.toast("已向所有未缴费居民发出缴费提醒"); $('.c-dtx-action').addClass("c-ytx-action").html("已提醒").removeClass("c-dtx-action"); $jfAllBtn.hide(); } else { $dom.removeClass("c-dtx-action").addClass("c-ytx-action"); mui.toast(res.msg); } } else { mui.toast(res.msg); } }) } function txWeixin(patient, patientName, $dom, isAll){ plus.nativeUI.showWaiting(); sendPost("doctor/family_contract/wechat_focus_remind", {patient: patient || "", isAll: isAll || 0}, null, function(res){ plus.nativeUI.closeWaiting(); var $wxAllBtn = $('#weixin_all_tx'); if(res.status == 200){ if(isAll==1){ mui.toast("已向所有未关注公众号居民发出关注提醒"); $('.c-to-remind-action').addClass("c-reminded-action").html("已提醒").removeClass("c-to-remind-action"); $wxAllBtn.hide(); } else { $dom.removeClass("c-to-remind-action").addClass("c-reminded-action"); mui.toast(res.msg); isShowRemindAllBtn(); } } else { $dom.removeClass("c-to-remind-action").addClass("c-reminded-action"); mui.toast(res.msg); } }) } ///doctor/family_contract/expenses_remind /* * 查看签约状态 */ mui("#yqy_list").on("tap", "li", function() { var patient = $(this).attr("data-patient"); mui.openWindow({ url: "patient-manage.html", id: "patient-manage.html", extras: { patientCode: patient, signStatus: "yqy" } }) return false; }); /* * 修改签约状态 */ mui("#dqy_list").on("tap", ".c-dqy-action", function() { var jsonStr = $(this).parent().attr("data-json"); jsonStr = jsonStr && JSON.parse(jsonStr); toXiaoxiChuli(1, jsonStr); return false; }); /*续签-待处理*/ mui("#xq_dcl_list").on("tap", ".c-dqy-action", function(){ var jsonStr = $(this).parent().attr("data-json"); jsonStr = jsonStr && JSON.parse(jsonStr); var signStatus = (jsonStr.renewFlag == 1)?8:9; plus.nativeUI.showWaiting(); sendPost("doctor/message/find", { sender: jsonStr.patientCode, signStatus: signStatus }, null, function(res){ if(res.status == 200){ if(res.data){ openWebview("xuqian_management.html", { patient: jsonStr.patientCode, signCode: jsonStr.code, renewFlag: jsonStr.renewFlag, msgId: res.data.id, applyDate: jsonStr.applyDate }); }else{ mui.toast("未找到相关消息"); } }else{ mui.toast(res.msg); } plus.nativeUI.closeWaiting(); }); return false; }); /*续签-待缴费*/ mui("#xq_djf_list").on("tap", ".c-dqy-action", function(){ var patient = $(this).parent().attr("data-patient"); openWebview("../../huanzhe/html/huanzhexinxi.html", {patiCode: patient}); return false; }); /*续签-已续签*/ mui("#xq_yxq_list").on("tap", ".c-dqy-action", function(){ var patient = $(this).parent().attr("data-patient"); openWebview("../../huanzhe/html/huanzhexinxi.html", {patiCode: patient}); return false; }); /* * 切换头部管理类型 */ /*关闭续签管理入口 $(".header-select").on("tap", function(){ $(".lin-mask").show(); $(".lin-sel-group").show(); }); $(".lin-mask").on("click",function(){ $(".lin-mask").hide(); $(".lin-sel-group").hide(); }); */ $(".icon-checkbox").on("change",function(e){ e.preventDefault(); var value = this.value; console.log(value); if(value == "2"){ if(date.getFullYear() != 2017){ $(".header-link").hide(); //2017年度后的提醒续签的按钮不显示 }else{ $(".header-link").show(); } //添加小红点 if($(this).next().hasClass("red-dot")){ $(".header-select").find("span:eq(0)").addClass("red-dot"); } $(".tab-group1").hide(); $(".tab-group2").show(); $(".sign-comonhd").find(".sanp-flex").eq(curTypeGroup2).click(); }else{ $(".header-link").hide(); $(".tab-group2").hide(); $(".tab-group1").show(); $(".sign-comonhd").find(".sanp-flex").eq(curType).click(); } $(".lin-mask").trigger("click"); $("#Dtitle").html($(this).parent().find("label").html()); //重新加载数据 }); /*提醒续签*/ $(".header-link").on("tap", function(){ var remindInfo = window.localStorage.getItem("remindXQ"); //remindInfo = {date: '2017-05-07', remind: 1} var info = remindInfo && JSON.parse(remindInfo); if(remindInfo && (info.date == dateStr) && (info.remind == 1)){ mui.toast("对不起,您今天已经全部提醒过,无法再次全部提醒"); return; } var url = "/doctor/sign/sendRenewToPatients"; dialog({ content: "是否向所有未提醒过的待续签居民发出续签提醒?(如绑定手机号则短信提醒,如绑定微信则微信提醒)", okValue: "立即提醒", ok: function(){ plus.nativeUI.showWaiting(); sendPost(url, {}, null, function(res){ if(res.status == 200){ if(res.data == 0){ mui.toast(res.msg); }else{ mui.toast("已向所有待续签居民发出续签提醒"); } var obj = {date: dateStr, remind: 1}; localStorage.setItem("remindXQ", JSON.stringify(obj)); // $(".header-link").hide(); }else{ mui.toast(res.msg); } plus.nativeUI.closeWaiting(); }, "post", "", true); }, cancelValue: "不了,谢谢", cancel: function(){} }).showModal(); }); /* * 加载更多 */ function loadMore(ulId, type, page) { plus.nativeUI.showWaiting("加载中,请稍候..."); var id = $(ulId).children().last().attr("data-id"); if(type == 1 || type == 3 || type == 5){ getData(type, id, function(res) { if (res.status == 200) { var tmplId, domUl, curScroll; switch (type) { case 1: tmplId = "dqy_tmpl"; domUl = $("#dqy_list"); curScroll = dqy_iscroll; break; case 3: tmplId = "yqy_tmpl"; domUl = $("#yqy_list"); curScroll = yqy_iscroll; isShowRemindAllBtn(); break; case 5: tmplId = "djf_tmpl"; domUl = $("#djf_list"); curScroll = djf_iscroll; break; } if (res.data.list.length == 0) { curScroll.refresh(true); plus.nativeUI.closeWaiting(); return } if(type == 5){ hasDtx(); } var list = _.map(res.data.list, function(o){ o.jsonStr = JSON.stringify(o); return o; }) var obj = {list: list}; domUl.append(template(tmplId, obj)); isShowMore(res, curScroll); plus.nativeUI.closeWaiting(); } }, page); }else{ //续签的流程 var tmplId, domUl, curScroll, status; switch (type) { case 6: tmplId = "dqy_tmpl"; domUl = $("#xq_dcl_list"); curScroll = xq_dcl_iscroll; status = 1; break; case 7: tmplId = "xq_yxq_tmpl"; domUl = $("#xq_djf_list"); curScroll = xq_djf_iscroll; isShowRemindAllBtn(); status = 2; break; case 8: tmplId = "xq_yxq_tmpl"; domUl = $("#xq_yxq_list"); curScroll = xq_yxq_iscroll; status = 3; break; } getXqData(status, function(res){ var list = _.map(res.data.list, function(o){ o.jsonStr = JSON.stringify(o); return o; }) var obj = {list: list}; domUl.append(template(tmplId, obj)); isShowMore(res, curScroll); plus.nativeUI.closeWaiting(); }, page); } } window.addEventListener("updata", function() { plus.webview.currentWebview().reload(false); }); window.addEventListener('reloadTab', function(e){ var index = e.detail.tab; if(index > 2){ curTypeGroup2 = index; xq_dclObj = null; xq_djfObj = null; }else{ curType = index; } if(curType == 0 && dqyObj) { //需要重新刷新页面 dqyObj = ""; }else if(curType == 1 && djfObj){ djfObj = ""; }else if(curType == 2 && yqyObj){ yqyObj = ""; } $(".sign-comonhd").find(".sanp-flex:eq("+index+")").trigger("click") }); template.helper("formatShowTime",function(str){ if(str){ return str.substr(0,16); }else{ return ""; } }); template.helper("setPhoto", function(p) { return getImgUrl(p); });