$(function(){ /* 滚轮 */ var myScroll = new IScroll(".iscroll",{ scrollbars: true, fadeScrollbars:true, scrollbars: 'custom', shrinkScrollbars:'clip', }); setTimeout(function () { $("body").height(document.body.scrollHeight); myScroll.refresh(); }, 250); /** * 滚动input以外失去焦点 * */ myScroll.on('scrollStart',function(e){ var el = document.activeElement; if (el.nodeName.toLowerCase() == 'input') { el.blur(); this.disable(); this.enable(); }; return; }); var theme="android-ics"; $("#date").mobiscroll().date({ lang: "zh",//显示中文 theme: theme,//主题 setText: '确定',//确认按钮名称 cancelText: '取消',//取消按钮名称 dateFormat: 'yy-mm-dd',// 日期格式 dateOrder: 'yymmdd',//面板中日期排列格式 display: 'bottom',//显示方式 endYear:2050,//结束年份 }); $("#eph").bind("click", function() { var id = $("#id").val(); if (id == "") { haifmp.loadMobilePage("haifm", "getZzttSearchDweb.htm?mcid=" + $("#mcid").val() +"&date=" + $("#date").val()); } }); //日期不能修改 if ($("#id").val() != "" && $("#id").val() != "0"){ $("#date" ).prop("disabled" , true); } //点击input键盘弹出滚动区域translateY往上滚动; $(document).ready(function () { var clickQian = document.body.clientHeight; var switcha = true; var a = null; $("input[type='text']").on("tap",function(){ a = $(".content")[0].style.transform.split(',')[1].split(' ')[1].match(/\d+(\.\d+)?/)[0]; if($("input[type='text']") && switcha){ setTimeout(function(){ var clickHou = document.body.clientHeight; var zimujpHeight = clickQian - clickHou - a - 270 + "px"; $(".content")[0].style.transform = "translateY(-"+zimujpHeight+")"; myScroll.refresh(); switcha = false; },250); } }); }); //元素失去焦点隐藏软键盘 $("#zzttForm").on("tap",function(e){ if(e.target.nodeName != "INPUT"){ $('input').blur(); }; }); }); /** * 保存 * @param type */ function saveZztt(type) { //选择的日期不能大于当前日期 var tof = EventUtil.dateLimit($("#date").val()); if (!tof) { alert("大于当前日期"); return false; } var dweb = $("#dweb").val(); var eph = $("#eph").val(); if (eph == "") { alert("请输入正确的耳牌号!"); return false; } else { jQuery('#zzttForm').ajaxSubmit({ dataType : 'json', data : {"mcid" : $("#mcid").val(), "dweb" : dweb, "eph" : eph }, beforeSend:function() {//触发ajax请求开始时执行 if(type==1){ $(".sub").text("提交中……"); $('.sub').attr('onclick','javascript:void(0)');//改变提交按钮上的文字并将按钮设置为不可点击 }else{ $(".subAdd").text("提交中……"); $('.subAdd').attr('onclick','javascript:void(0)');//改变提交按钮上的文字并将按钮设置为不可点击 } }, success : function(msg, data) { // 保存成功 if (msg.result=1) { alert("保存成功!"); if (type == "1") { haifmp.loadMobilePage("haifm", "hpSjlrZzttIndex.htm?mcid=" + $("#mcid").val()); } else { haifmp.loadMobilePage("haifm", "hpSjlrZzttEdit.htm?mcid=" + $("#mcid").val()); } }else if (msg.count ==2) { alert("淘汰时间小于种猪入栏日期"); if (type == "1") { $('.sub').text('保存'); $('.sub').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击 } else { $('.subAdd').text('保存并新增'); $('.subAdd').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击 } } }, error : function(data) { if(type=="1") { alert('网络繁忙,请稍后再试...'); $('.sub').text('保存'); $('.sub').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击 }else { alert('网络繁忙,请稍后再试...'); $('.subAdd').text('保存并新增'); $('.subAdd').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击 } }, complete: function(msg, data) { //ajax请求完成时执行 if(msg.result==1) { if(type==1){ $(".sub").text("提交中……"); $('.sub').attr('onclick','javascript:void(0)');//改变提交按钮上的文字并将按钮设置为不可点击 }else{ $(".subAdd").text("提交中……"); $('.subAdd').attr('onclick','javascript:void(0)');//改变提交按钮上的文字并将按钮设置为不可点击 } } } }); } } /** * 返回 */ function backUrl() { haifmp.loadMobilePage("haifm", "hpSjlrZzttIndex.htm?mcid=" + $("#mcid").val()); }