// 基本信息(包括userAgent) var baseInfo = null, // 基础环境信息(包括当前webview、encry相关) baseEnv = null, docInfo = null, fv_id = null, followupClass = null, //记录随访类型 高血压或糖尿病 noFillItem = 0, patientCode = null, //记录患者code otherPeople = '', fv_status = null, //记录随访状态 prescriptionStatus, prescriptionCode ="";//续方 var reference = ""; //记录前一个页面的id var $proList = $("#project_list"); // 获取登录相关信息 var getBaseInfo = function() { docInfo = JSON.parse(plus.storage.getItem("docInfo")); prescriptionCode = baseEnv.webview.prescriptionCode; fv_id = baseEnv.webview.followup_id; fv_status = baseEnv.webview.status; reference = baseEnv.webview.reference; otherPeople = baseEnv.webview.otherPeople; //获取续方状态 if(prescriptionCode){ sendGet('doctor/prescriptionInfo/getContinuedPrescriptionAsDoctor',{code: prescriptionCode,type:1}, null, function(res){ if(res.status == 200) { prescriptionStatus = res.data.prescription.status; isShowBtn() }else{ mui.toast('获取续方状态失败') isShowBtn() } }) }else{ isShowBtn() } // 登录的相关信息 var userAgent = JSON.parse(plus.storage.getItem("userAgent")); return { userAgent: userAgent } }, // 获取基础环境信息 getBaseEnvPromise = function () { var env = { webview: plus.webview.currentWebview() }; mui.back = function(){ backAction(); } // 因为有异步请求,需要等待数据返回之后进行处理,所以返回Promise return Promise.resolve().then(function(res) { return env; }); }, isShowBtn = function(){ //非操作人员 if(otherPeople || (prescriptionStatus>=0 && prescriptionStatus < 40)){ $('#completeSec').hide(); }else{ setTimeout(function(){ $('#completeSec').show(); },1000) } }, initPage = function(){ noFillItem = 0; if(fv_status == 1){ $("#complete").text("保存修改"); } //获取随访计划详情 plus.nativeUI.showWaiting(); var url = "doctor/followup/getFollowup"; sendPost(url,{id: fv_id}, null, function(res){ if(res.status == 200) { patientCode = res.data.patientCode; $(".docInfo").text(res.data.doctorName+" "+res.data.orgName); $(".patientName").text(res.data.patientName); if(res.data.followupNo){ $(".planNo").text(res.data.followupNo); $(".planNo").closest("li").removeClass("c-hide"); } $(".fvType").text(res.data.followupTypeName); $(".fvClass").text(res.data.followupClassName); $(".fvDate").text(res.data.followupDate); if(res.data.mobile && res.data.followupType == 3){ //电话随访方式才可以打电话 $(".div-phone").show(); $(".div-phone").attr("data-phone", res.data.mobile); } followupClass = res.data.followupClass; getFollowupProject(); }else{ plus.nativeUI.closeWaiting(); mui.toast('数据加载失败') } }, "GET"); }, getFollowupProject = function(){ //获取随访项目列表 var url = "doctor/followup/getFollowupProject"; sendPost(url,{id: fv_id}, null, function(res){ if(res.status == 200) { var html = template("pro_list_temp", res); $proList.empty().append(html); for(i=0; isuifang_detail->choose_suifang->follow_way->fvDetail mui.fire(indexWv,'refresh'); openWebview("index.html"); mui.later(function(){ pre_pre_opener.close('none'); pre_opener.close('none'); opener.close('none'); self.close('none'); },300); }else{ //IM/juminxinxi->choose_suifang->follow_way->fvDetail var fuwujilu = plus.webview.getWebviewById("fuwujilu"); if(fuwujilu){ mui.fire(fuwujilu, "newPage", {type: 'sf', patientCode: patientCode}); } openWebview("../../huanzhe/html/fuwujilu.html", {type: 'sf', patientCode: patientCode}); mui.later(function(){ pre_opener.close('none'); opener.close('none'); self.close('none'); }, 1000); } }else{ if(indexWv){ mui.fire(indexWv,'refresh'); openWebview("index.html"); } mui.later(function(){ var pre_pre_opener = pre_opener.opener(); if(opener.id == "start_plan" || opener.id == "follow_way" || opener.id == "suifang_detail"){ opener.close('none'); } if(pre_opener && (pre_opener.id == "sousuojumin_one" || pre_opener.id == "xuanzejumin_one")){ pre_opener.close('none'); } if(pre_opener && pre_opener.id == "suifang_detail"){ pre_opener.close('none'); } if(pre_pre_opener && pre_pre_opener.id == "xuanzejumin_one"){ pre_pre_opener.close('none'); } self.close('none'); }, 300); } } bindEvents = function(){ $proList.on("tap","li", function(){ if(!otherPeople || $(this).find('.c-list-key span').text()=='已登记'){ var project_id = $(this).attr("data-id"), title = $(this).attr("data-label"), url = (project_id == "6")? "drugs.html":"questionaires.html"; openWebview(url,{ followup_id: fv_id, project_id: project_id, title: title, followupClass:followupClass, patientCode: patientCode, otherPeople:otherPeople }); } }); $("#complete").on('click',function(){ var $ul = $('#project_list').find('li'); if( !($ul.eq(1).attr('data-fill')*1 && $ul.eq(4).attr('data-fill')*1) ){ mui.toast('请完善体征和评价') return false } if(noFillItem > 0){ dialog({ content: "当前还有"+noFillItem+"项未提交,您确定要上传吗?", okValue:'继续上传', ok: function (){ plus.nativeUI.showWaiting(); var url = "doctor/followup/finishFollowup", params = {id: fv_id}; sendPost(url, params, null, function(res){ if(res.status == 200){ mui.toast("完成本次随访"); backAction(); } plus.nativeUI.closeWaiting(); },'POST'); }, cancelValue: '返回补充', cancel: function () { return; } }).showModal(); }else{ plus.nativeUI.showWaiting(); var url = "doctor/followup/finishFollowup", params = {id: fv_id}; sendPost(url, params, null, function(res){ if(res.status == 200){ mui.toast("完成本次随访"); backAction(); } plus.nativeUI.closeWaiting(); },'POST'); } }); $(".div-phone").on('click', function(){ var mobile = $(this).attr("data-phone"); dialog({ content: mobile, okValue:'立即拨号', ok: function (){ window.location.href = "tel:"+mobile; }, cancelValue: '不了,谢谢', cancel: function () { return; } }).showModal(); }); }; // 页面业务处理流程开始 new Promise(function(resolve, reject) { // TODO 临时放开 //resolve(true); mui.plusReady(function() { // plus已经准备好,可以往下执行 resolve(true); }); }).then(function() { // 获取基础环境信息 return getBaseEnvPromise().then(function(env) { baseEnv = env; }).then(function() { // 获取登录医生信息 baseInfo = getBaseInfo(); //初始化页面内容 initPage(); // 绑定页面事件 bindEvents(); }) }).catch(function(e) { plus.nativeUI.closeWaiting(); console && console.error(e); }); window.addEventListener('refresh',function(){ initPage(); })