var d = dialog({contentType:'load', skin:'bk-popup'}); var request = GetRequest(), doctorCode = request["doctorCode"], doctorName = decodeURI(request["doctorName"]), jobName = decodeURI(request["jobName"]), patientInfo = window.localStorage.getItem(agentName1); var serverId = ""; //微信图片上传获取的图片id $(function(){ if(patientInfo){ patientInfo = JSON.parse(patientInfo); } $("#lbl_patient").text(patientInfo.name); var text = doctorName; if(jobName){ text += "("+jobName+")" } $("#lbl_doctor").text(text); bindEvents(); getWxSign(); }) function bindEvents(){ //提交咨询 $("#commit").click(function() { if($(this).hasClass("active")){ var txtContent = $("#txtContent").val(); if(txtContent){ txtContent = utf16toEntities(txtContent.replace(/\s+/g,"")); } var data = { type: 1, symptoms: txtContent || "", voice: "" }; if (validate(data)) { //验证通过执行 d.showModal(); var images = getImages(); if(images.length == 0){ $("#commit").css("pointer-events","none"); serverId = ''; doSubmit(data); } else{ uploadImage(data); } } } }); } //验证信息 function validate(data) { 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; } 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 = $('