$(function(){ //输入框快速删除初始化 mui(".mui-input-row input").input(); var theme="android-ics"; $("#ksrq").mobiscroll().date({ lang: "zh",//显示中文 theme: theme,//主题 setText: '确定',//确认按钮名称 cancelText: '取消',//取消按钮名称 dateFormat: 'yy-mm-dd',// 日期格式 dateOrder: 'yymmdd',//面板中日期排列格式 display: 'bottom',//显示方式 endYear:2050,//结束年份 }); $("#jsrq").mobiscroll().date({ lang: "zh",//显示中文 theme: theme,//主题 setText: '确定',//确认按钮名称 cancelText: '取消',//取消按钮名称 dateFormat: 'yy-mm-dd',// 日期格式 dateOrder: 'yymmdd',//面板中日期排列格式 display: 'bottom',//显示方式 endYear:2050,//结束年份 }); /* 图标切换*/ var myScroll; var t1 = null;//这个设置为全局 /* 滚轮 */ myScroll = new IScroll(".iscroll",{ scrollbars: true, fadeScrollbars:true, scrollbars: 'custom', shrinkScrollbars:'clip', }); setTimeout(function(){ myScroll.refresh(); }, 100); $(".dropdown_btn").on("click",function(e){ if(e.preventDefault){ e.preventDefault(); }else{ event.returnValue = false; } if(e.stopPropagation){ e.stopPropagation(); }else{ event.cancelBubble = true; } //解决tap两次出发的方法(500是2次点击时间差,单位ms) if (t1 == null){ t1 = new Date().getTime(); }else{ var t2 = new Date().getTime(); if(t2 - t1 < 500){ t1 = t2; return; }else{ t1 = t2; } } $(this).children().toggleClass("dropup"); $(this).parent().next().slideToggle (500,function(){ setTimeout(function(){ myScroll.refresh(); }, 100); }); }); /* 弹出修改删除框*/ $(".group_hiddenMsg").on("tap",function(){ $("#checkid").val($(this).data("id")); $("#dw").val($(this).data("ep")); if ($(this).data("sh") != "已审核") { $(".record_header").css("z-index","1"); $(".record_searchBox").css("z-index","1"); $(".group_iscroll").css("z-index","1"); $(".fenmian_dayNumBox").css("z-index","1"); $("#fenmian_addBtn").css("z-index","1"); $(".xgmsgbox").show(showOverlay()); } }); /* 点击遮罩层隐藏修改删除框*/ $("#overlay").on("click",function(){ $(".record_header").animate({"z-index":"9"},200); $(".record_searchBox").animate({"z-index":"9"},200); $(".group_iscroll").animate({"z-index":"9"},200); $(".fenmian_dayNumBox").animate({"z-index":"9"},200); $("#fenmian_addBtn").animate({"z-index":"9"},200); $(".xgmsgbox").hide(hideOverlay()); }); document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false); $("#ksrq,#jsrq").on("change", function() { haifmp.loadMobilePage("haifm", "hpSjlrZzttIndex.htm?mcid=" + $("#mcid").val() + "&ksrq=" + $("#ksrq").val() + "&jsrq=" + $("#jsrq").val() + "&cxeph=" + $("#dweb").val()); }); $("#dweb").bind("blur", function() { haifmp.loadMobilePage("haifm", "hpSjlrZzttIndex.htm?mcid=" + $("#mcid").val() + "&ksrq=" + $("#ksrq").val() + "&jsrq=" + $("#jsrq").val() + "&cxeph=" + $("#dweb").val()); }); $("#fenmian_addBtn").bind("click", function() { haifmp.loadMobilePage("haifm", "hpSjlrZzttEdit.htm?mcid=" + $("#mcid").val()); }); //确定淘汰 $(".ysbt #ttSure").on("tap", function(event) { if(event.stopPropagation){ event.stopPropagation(); }else{ event.cancelBubble = true; } if(confirm("确认淘汰耳牌为: " + $(this).parent().data("ep") + "?")) { //TODO 确定淘汰 则1:淘汰审核标志改为1 2:档案里修改动物状态为淘汰 makeSureTt($(this).parent().data("id")); } }); //驳回淘汰 $(".ysbt #ttNotSure").on("tap", function(event) { if(event.stopPropagation){ event.stopPropagation(); }else{ event.cancelBubble = true; } if(confirm("确认驳回淘汰耳牌为: " + $(this).parent().data("ep") + "的淘汰申请?")) { rejectedTt($(this).parent().data("id")); } }); $(".cententUl").on("click", "li", function() { var data = $(this).data("for"); if (data == "qx") { $(".xgmsgbox").hide(hideOverlay()); $(".record_header").animate({"z-index":"1"},200); $(".record_searchBox").animate({"z-index":"1"},200); $(".group_iscroll").animate({"z-index":"1"},200); $(".fenmian_dayNumBox").animate({"z-index":"1"},200); $("#fenmian_addBtn").animate({"z-index":"1"},200); } if (data == "edit") { haifmp.loadMobilePage("haifm", "hpSjlrZzttEdit.htm?mcid=" + $("#mcid").val() + "&id=" + $("#checkid").val() + "&eph=" + $("#dw").val()); } if (data == "pigrerecord") { selectPigRerecord($("#checkid").val()); } }); //ios键盘遮挡addBtn var u = navigator.userAgent, app = navigator.appVersion; var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端 if(isiOS){ $("input[type='search']").focus(function(){ setTimeout(function(){ $(".group_iscroll").css("height","2.8rem"); myScroll.refresh(); $("#fenmian_addBtn").animate({bottom: '5.13rem'}, 250); },20); }); }; //模糊查询键盘enter键事件 $("input[type='search']").on('keypress',function(e) { var keycode = e.keyCode; if(keycode=='13') { e.preventDefault(); //请求搜索接口 haifmp.loadMobilePage("haifm", "hpSjlrZzttIndex.htm?mcid=" + $("#mcid").val() + "&ksrq=" + $("#ksrq").val() + "&jsrq=" + $("#jsrq").val() + "&cxeph=" + $("#dweb").val()); } }); }); /* 显示遮罩层 */ function showOverlay(){ $("#overlay").height(pageHeight()); $("#overlay").width(pageWidth()); // fadeTo第一个参数为速度,第二个为透明度 // 多重方式控制透明度,保证兼容性,但也带来修改麻烦的问题 $("#overlay").fadeTo(200, 0.5); }; /* 隐藏覆盖层 */ function hideOverlay(){ $("#overlay").fadeOut(200); }; /* 当前页面高度 */ function pageHeight(){ return document.body.scrollHeight; }; /* 当前页面宽度 */ function pageWidth(){ return document.body.scrollWidth; }; /** * 返回 */ function backUrl() { haifmp.loadMobilePage("haifm", "hpSjlrScIndex.htm?mcid=" + $("#mcid").val()); $("footer.row").css("display","block"); } /** * 根据ID查此猪的生平历史 * @param val */ function selectPigRerecord(id) { jQuery.ajax({ url : 'hpSjlrZzttSelectPigRerecord.htm', dataType : 'json', type : 'post', cache : false, data : { "id" : id, }, success : function(data) { if (data.data == 1) {//公猪 haifmp.loadMobilePage("haifm", "hpSjlrGzxx.htm?mcid=" + $("#mcid").val() + "&id=" + data.id + "&from=" + "zztt"); } else if (data.data == 2){//母猪 haifmp.loadMobilePage("haifm", "hpSjlrMzxx.htm?mcid=" + $("#mcid").val() + "&id=" + data.id + "&from=" + "zztt"); } else { alert("操作失败,请重试"); } }, error : function(data) { alert("系统异常!删除失败!"); } }); } /** * 驳回淘汰 * @param val */ function makeSureTt(id) { jQuery.ajax({ url : 'hpSjlrZzttConfirmTt.htm', dataType : 'json', type : 'post', cache : false, data : { "id" : id, }, success : function(data) { if (data.data == 1) { alert("淘汰成功"); haifmp.loadMobilePage("haifm", "hpSjlrZzttIndex.htm?mcid=" + $("#mcid").val()); } else { alert("淘汰失败,请重试"); } }, error : function(data) { alert("系统异常!删除失败!"); } }); } /** * 确定淘汰 * @param val */ function rejectedTt(id) { jQuery.ajax({ url : 'hpSjlrZzttRejectedTt.htm', dataType : 'json', type : 'post', cache : false, data : { "id" : id, }, success : function(data) { if (data.data == 1) { alert("淘汰驳回成功"); haifmp.loadMobilePage("haifm", "hpSjlrZzttIndex.htm?mcid=" + $("#mcid").val()); } else { alert("淘汰驳回失败,请重试"); } }, error : function(data) { alert("系统异常!删除失败!"); } }); } /** * 删除 * @param val */ function deleteZztt(val) { if(confirm("确定要删除该淘汰记录吗?删除成功后无法进行恢复!")) { jQuery.ajax({ url : 'disableZztt.htm', dataType : 'json', type : 'post', cache : false, data : {"id" : val}, success : function(data) { if (data.count > 0) { alert("删除成功!"); haifmp.loadMobilePage("haifm", "hpSjlrZzttIndex.htm?mcid=" + $("#mcid").val() + "&ksrq=" + $("#ksrq").val() + "&jsrq=" + $("#jsrq").val() + "&dweb=" + $("#dweb").val()); } else { alert("删除失败!"); } }, error : function(data) { alert("系统异常!删除失败!"); } }); } }