Request = GetRequest(); var chooseType = Request["type"];//界面传送的类型 0不定义类型 1.慢病咨询 2.家庭医生咨询 6.名医咨询 var doctorCode = Request["doctorCode"]; var id = Request["id"]; var guidance = ""; var workTime = "";//医生工作时间 var doctorName = "";//医生名称 var patientName = window.localStorage.getItem('nowPatientName'); var fromPage = Request["fromPage"]; // updateTitle(); //修改header 的标题 function updateTitle(title){ //需要jQuery var $body = $('body'); document.title = title; // hack在微信等webview中无法修改document.title的情况 var $iframe = $(''); $iframe.on('load',function() { setTimeout(function() { $iframe.off('load').remove(); }, 0); }).appendTo($body); } $(function(){ if(fromPage && fromPage=="jkzx") { updateTitle("新增医生健康咨询") } else { guidance = window.localStorage.getItem("guidance") } // 指导内容显示 if (guidance) { $("#guidance").html(guidance); } else { $("#guidanceWrap").hide(); } // 咨询类别 if(chooseType==1){ //$(".span-type").html("慢病管理"); querySignType();//填充下拉框 }else if(chooseType==2){ //$(".span-type").html("家庭医生"); querySignType();//填充下拉框 }else if(chooseType==0) { querySignType();//填充下拉框 } /* 复选框兼容 */ $(document).on("click", ".input-group-pack > input[type=checkbox]", function() { var $cpChk = $(this).parent(); if ($(this).attr("checked") == "checked") { $cpChk.removeClass("checked"); $(this).removeAttr("checked"); } else { $cpChk.addClass("checked"); $(this).attr("checked", true); } }); //弹窗 $('.broadcast-icon').on('click',function(){ $('.broadcast-shadow-panel').removeClass('c-hide'); }); $('.win-cancle').on('click',function(){ $('.broadcast-shadow-panel').addClass('c-hide'); }); //从后台那边获取签名等信息 var params = {}; params.pageUrl = window.location.href; $.ajax(server + "weixin/getSign", { data: params, dataType: "json", type: "post", success: function(res){ if (res.status == 200) { var t = res.data.timestamp; var noncestr = res.data.noncestr; var signature = res.data.signature; wx.config({ // debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 appId: appId, // 必填,公众号的唯一标识 timestamp: t, // 必填,生成签名的时间戳 nonceStr: noncestr, // 必填,生成签名的随机串 signature: signature,// 必填,签名,见附录1 jsApiList: [ 'chooseImage', 'uploadImage' ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2 }); } else{ dialog({ title:'提示', skin:"ui-dialog ax-popup pror", content:"获取微信签名失败", ok: function (){} }).showModal(); window.location.href = "doctor-guidance.html"; } } }); function successFun(res){ if(res.status==200){ var dataList = res.data.doctor; doctorName = dataList.name; $("#lbl_doctor").html(dataList.name+"("+dataList.jobName+")"); $("#lbl_patient").html(patientName); }else{ getListFail(res); } } function getListFail(res){ if (res && res.msg) { dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg,bottom:true}).show(); } else { dialog({contentType:'tipsbox', skin:'bk-popup' , content:'加载失败',bottom:true}).show(); } } //提交咨询 $("#commit").click(function() { if($(this).hasClass("active")){ var data = {}; data.type = Number($("#txtTypeCode").val()); if($("#txtContent").val() == null) data.symptoms = ""; else data.symptoms = utf16toEntities($("#txtContent").val().replace(/\s+/g,"")); data.voice = ""; if (validate(data)) { //验证通过执行 dd.showModal(); var images = getImages(); if(images.length == 0){ $("#commit").css("pointer-events","none"); doSubmit(data); } else{ uploadImage(data); } } } }); }); function checkInWork(doctor){ sendPost('/patient/consult/is_doctor_working', {doctor:doctor}, 'json', 'post', queryFailed, function(res){ if(res.status==200){ if(res.data==0){ dialog({ title: '提示', content: '您好,由于您的签约医生工作繁忙,所以设置了每日回复咨询的时间段,所以,在该时间段外的时间,您的咨询将不会马上获得医生的回复', okValue:'我知道了', ok: function (){ return; }, cancelValue: '查看时间', cancel: function () { alert("查看时间") } }).showModal(); } }else{ queryFailed(res); } }); } //查询咨询类型 function querySignType(){ d.show(); sendPost('patient/sign_status', {}, 'json', 'post', querySignTypeFailed, querySignTypeSuccess); } function querySignTypeFailed(res) { d.close(); if (res && res.msg) { dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show(); } else { dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'获取咨询类型失败'}).show(); } } function querySignTypeSuccess(res) { if (res.status == 200) { $('#txtTypeCode').val(chooseType); $('#lbl_doctor').html(getSignDoctor(res,chooseType)); $("#lbl_patient").html(patientName); var arr_key=[]; var arr_value=[]; var sign = Number(res.data); if(sign == 1){ arr_key=[1]; arr_value=['慢病管理']; } else if(sign == 2){ arr_key=[2]; arr_value=['家庭医生']; } else if(sign == 3&&chooseType==0){ arr_key=[1,2,6]; arr_value=['慢病管理', '家庭医生']; }else if(sign == 3&&chooseType==1){ arr_key=[1]; arr_value=['慢病管理']; }else if(sign == 3&&chooseType==2){ arr_key=[2]; arr_value=['家庭医生']; } else{ arr_key=[]; arr_value=[]; } //签约类型 var option1 = { theme: 'ios', lang: 'zh', formatValue: function(d) { return d.join(','); }, customWheels: true, wheels: [ [{ keys: arr_key, values: arr_value }] ], onSelect: function(valueText, inst) { var dd = eval("[" + valueText + "]"); $('#txtTypeCode').val(dd[0].keys); $('#txtTypeName').val(dd[0].values); $('#lbl_doctor').html(getSignDoctor(res,dd[0].keys)); } }; $('#txtTypeName').mobiscroll(option1); $('#txtTypeName').val(option1.wheels[0][0].values[0]); $('#txtTypeCode').val(option1.wheels[0][0].keys[0]); $('#lbl_doctor').html(getSignDoctor(res,option1.wheels[0][0].keys[0])); //选择发病时间 $('li.ill-time').mobiscroll({ theme: 'ios', lang: 'zh', formatValue: function(d) { return d.join(','); }, customWheels: true, wheels: [ [{ keys: ['0', '1', '2', '3', '4', '5'], values: ['最近24小时', '最近一周', '最近三个月', '最近一年', '一年以上', '不清楚'] }] ], onSelect: function(valueText, inst) { var dd = eval("[" + valueText + "]"); $('input[data-time=illTime]').val(dd[0].values); } }); d.close(); } else { querySignTypeFailed(res); } } //获取医生信息 function getSignDoctor(data,type){ var doctor_name = ""; var doctor_type = ""; switch(Number(type)) { case 1: doctor_type = data.teamDoctors; break; case 2: doctor_type = data.familyDoctors; break; default: break; } for(var i=0; i < doctor_type.length; i++){ doctor_name += doctor_type[i] + ","; } if(doctor_name.length > 0){ doctor_name = doctor_name.substring(0, doctor_name.length-1); } return doctor_name; } //验证信息 function validate(data) { // if (data.type == '') { // dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请选择咨询类型'}).show(); // return false; // } // if (data.when == '') { // dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请选择发病时间'}).show(); // return false; // } if (data.symptoms.length < 10) { dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请至少用10个字描述您的症状'}).show(); return false; } if (data.symptoms.length > 500) { dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请在500字以内完成您的症状描述'}).show(); return false; } if(!$(".input-group-pack > input[type=checkbox]").attr("checked")){ dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请勾选"我已阅读咨询说明"'}).show(); return false; } return true; } var serverId = ""; function chooseImage(){ wx.chooseImage({ count: 9-getImages().length, success: function (res) { for (var i in res.localIds) { appendFile(res.localIds[i]); } } }); } function uploadImage(data){ $("#commit").css("pointer-events","none"); var images = getImages(); if (images.length == 0) { return; } var i = 0, length = images.length; serverId = ""; function upload() { wx.uploadImage({ localId: images[i], isShowProgressTips: 0, success: function (res) { i++; if(serverId.length == 0){ serverId = res.serverId; } else{ serverId =serverId + "," + res.serverId; } if (i < length) { upload(); } if(i == images.length){ doSubmit(data); } }, fail: function (res) { $("#commit").css("pointer-events",""); alert(JSON.stringify(res)); } }); } upload(); } // 添加文件 function appendFile(p) { var amount = getImages().length; if (amount >= 8) { $("#add_img_li").hide(); } if(amount < 9){ var $li = $('