hpSjlrDaIndex.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. $(function(){
  2. var t1 = null;//这个设置为全局
  3. var myScroll;
  4. //输入框快速删除初始化
  5. mui(".mui-input-row input").input();
  6. $(".lisBtn").click(function(){
  7. $(".ar_header").css("z-index","1");
  8. $("nav").css("z-index","1");
  9. $(".dangan_iscroll").css("z-index","1");
  10. $(".footerBox").css("z-index","1");
  11. $("#menu").css("z-index","1");
  12. $("#hiddenBox").show(showOverlay());
  13. setTimeout(function () {
  14. myScroll.refresh();
  15. }, 100);
  16. //调用轮播事件
  17. swiper();
  18. });
  19. //点击td选中input
  20. $(".chooseDweb,.checkBox").on("tap",function (e) {
  21. e.stopPropagation();
  22. if ($(this).find("input[type='checkbox']").is(":checked")) {
  23. $(this).find("input[type='checkbox']").removeAttr("checked");
  24. } else {
  25. $(this).find("input[type='checkbox']").prop("checked", true);
  26. }
  27. });
  28. $("#overlay").click(function(){
  29. $(".ar_header").animate({"z-index":"9"},200);
  30. $("nav").animate({"z-index":"9"},200);
  31. $(".dangan_iscroll").animate({"z-index":"9"},200);
  32. $(".footerBox").animate({"z-index":"9"},200);
  33. $("#menu").animate({"z-index":"9"},200);
  34. $("#hiddenBox").hide(hideOverlay());
  35. });
  36. /*滚动区域事件*/
  37. myScroll = new IScroll(".iscroll",{
  38. scrollbars: true,
  39. fadeScrollbars:true,
  40. scrollbars: 'custom',
  41. shrinkScrollbars:'clip',
  42. });
  43. /*滚动区域的刷新事件*/
  44. setTimeout(function () {
  45. $("body").height(document.body.scrollHeight);
  46. myScroll.refresh();
  47. }, 100);
  48. /*公猪母猪舍切换*/
  49. $('footer div').click(function(){
  50. $(this).addClass("active").siblings().removeClass();//removeClass就是删除当前其他类;只有当前对象有addClass("active");siblings()意思就是当前对象的同级元素,removeClass就是删除;
  51. $(".container > section").hide().eq($('footer div').index(this)).show();
  52. var type = $(this).data("for");
  53. if (type == "gz") {
  54. haifmp.loadMobilePage("haifm", "hpSjlrDaIndex.htm?mcid=" + $("#mcid").val());
  55. }
  56. if (type == "mz") {
  57. haifmp.loadMobilePage("haifm", "hpSjlrMzDaIndex.htm?mcid=" + $("#mcid").val());
  58. }
  59. });
  60. //touchmove的阻止浏览器或者屏幕滚动默认事件
  61. document.addEventListener("touchmove", function (e) {
  62. e.preventDefault();
  63. }, false);
  64. /* 列表切换*/
  65. $(".hiddenBoxTop div").click(function(){
  66. $(this).addClass("active").siblings().removeClass();
  67. $(".option").hide().eq($('.hiddenBoxTop div').index(this)).show();
  68. setTimeout(function () {
  69. myScroll.refresh();
  70. }, 100);
  71. });
  72. /* 单选和多选 复选框事件*/
  73. $(".submit").bind("click", function () {
  74. var result1 = new Array();
  75. var resultId1 = new Array();
  76. var result2 = new Array();
  77. var resultId2 = new Array();
  78. resultId1.push(",");
  79. resultId2.push(",");
  80. $("[name = chkItem]:checkbox").each(function () {
  81. if ($(this).is(":checked")) {
  82. result1.push($(this).parent().next().text());
  83. resultId1.push($(this).attr("id"));
  84. }
  85. });
  86. $("[name = chkmsg]:checkbox").each(function () {
  87. if ($(this).is(":checked")) {
  88. result2.push($(this).parent().next().text());
  89. resultId2.push($(this).attr("id"));
  90. }
  91. });
  92. $("nav .zhushe").show();
  93. $(this).parent().hide(hideOverlay());
  94. var rows = $(".rowll");
  95. if (resultId1.length > 0 || resultId2.length > 0 ) {
  96. rows.addClass("hidden");
  97. rows.find(".btn-group").addClass("dropup");
  98. for (var i = 0; i < rows.length; i++) {
  99. for (var j = 0; j < resultId1.length; j++) {
  100. if (rows.eq(i).data("sl") == resultId1[j]) {
  101. rows.eq(i).removeClass("hidden");
  102. }
  103. }
  104. for (var j = 0; j < resultId2.length; j++) {
  105. if (rows.eq(i).data("dqzt") == resultId2[j]) {
  106. if (resultId1.length <= 0) {
  107. rows.eq(i).removeClass("hidden");
  108. }
  109. }
  110. }
  111. }
  112. } else {
  113. rows.removeClass("hidden");
  114. }
  115. $(".ar_header").animate({"z-index":"1"},200);
  116. $("nav").animate({"z-index":"1"},200);
  117. $(".dangan_iscroll").animate({"z-index":"1"},200);
  118. $(".footerBox").animate({"z-index":"1"},200);
  119. var dqzt = "0";
  120. var sl = "0";
  121. if (result1.length > 0) {
  122. sl = "1";
  123. }
  124. if(result2.length > 0) {
  125. dqzt = "1";
  126. }
  127. haifmp.loadMobilePage("haifm", "hpSjlrDaIndex.htm?mcid=" + $("#mcid").val() + "&dqzt=" + dqzt + "&dqztArray="+resultId2 + "&sl=" + sl + "&slArray=" + resultId1);
  128. });
  129. /* 全选复选框事件*/
  130. $("#btnCheckAllLanShe").bind("click", function () {
  131. var isChecked = $(this).prop("checked");
  132. $("input[name='chkItem']").prop("checked", isChecked);
  133. });
  134. $("#btnCheckAllStaus").bind("click", function () {
  135. var isChecked = $(this).prop("checked");
  136. $("input[name='chkmsg']").prop("checked", isChecked);
  137. });
  138. $("#dweb").bind("blur", function() {
  139. haifmp.loadMobilePage("haifm", "hpSjlrDaIndex.htm?mcid=" + $("#mcid").val() + "&cxeph=" + $("#dweb").val());
  140. });
  141. $("#dweb").bind("focus", function() {
  142. $("#ct").val("gzsearch");
  143. });
  144. $("#dweb").bind("change", function() {
  145. if ($("#dweb").val() == "") {
  146. $("#ct").val("gzwd");
  147. }
  148. });
  149. var dweb = $("#dweb").val();
  150. if (dweb != "") {
  151. $("#ct").val("gzsearch");
  152. }
  153. //点击箭头进入信息页
  154. $(".rowll > .dropdownBtn").on("tap", function() {
  155. var id = $(this).data("for");
  156. if (id != "") {
  157. haifmp.loadMobilePage("haifm", "hpSjlrGzxx.htm?mcid=" + $("#mcid").val() + "&id=" + id + "&ztsl=" + $("#ztsl").val());
  158. }
  159. });
  160. //模糊查询键盘enter键事件
  161. $("input[type='search']").on('keypress',function(e) {
  162. var keycode = e.keyCode;
  163. if(keycode=='13') {
  164. e.preventDefault();
  165. //请求搜索接口
  166. haifmp.loadMobilePage("haifm", "hpSjlrDaIndex.htm?mcid=" + $("#mcid").val() + "&cxeph=" + $("#dweb").val());
  167. }
  168. });
  169. });
  170. /* 选项卡*/
  171. function swiper(){
  172. var swiper = new Swiper('.swiper-container',{
  173. pagination:'.swiper-pagination',
  174. prevButton:'.swiper-button-prev',
  175. nextButton:'.swiper-button-next',
  176. direction : 'horizontal',
  177. paginationClickable: true,
  178. touchMoveStopPropagation : false,
  179. followFinger: false,
  180. touchAngle : 60,//允许触发拖动的角度值(60)
  181. speed:300,
  182. touchMoveStopPropagation : false,
  183. //ajax动态循环生成当到第二页的时候始终滑动不起来的方法
  184. //分页器消失解决方法
  185. observer:true,//修改swiper自己或子元素时,自动初始化swiper
  186. observeParents:true,//修改swiper的父元素时,自动初始化swiper
  187. onSlideChangeEnd: function(swiper){
  188. swiper.update(); //swiper滑动的时候滑动到第3屏就滑动不了的解决办法
  189. }
  190. });
  191. }
  192. /* 显示遮罩层 */
  193. function showOverlay(){
  194. $("#overlay").height(pageHeight());
  195. $("#overlay").width(pageWidth());
  196. // fadeTo第一个参数为速度,第二个为透明度
  197. // 多重方式控制透明度,保证兼容性,但也带来修改麻烦的问题
  198. $("#overlay").fadeTo(200, 0.5);
  199. };
  200. /* 隐藏覆盖层 */
  201. function hideOverlay(){
  202. $("#overlay").fadeOut(200);
  203. };
  204. /* 当前页面高度 */
  205. function pageHeight(){
  206. return document.body.scrollHeight;
  207. };
  208. /* 当前页面宽度 */
  209. function pageWidth(){
  210. return document.body.scrollWidth;
  211. };
  212. /**
  213. * 返回
  214. */
  215. function backUrl() {
  216. haifm.loadMobilePage("haifm", "haifmvMain.htm?uuid=" + $("#uuid").val() + "&mcid=" + $("#mcid").val() + "&qyid=" + $("#qyid").val() +"&toList=2");
  217. $("footer.row").css("display","block");
  218. }
  219. /**
  220. * 新增公猪档案
  221. */
  222. function addGzda() {
  223. haifmp.loadMobilePage("haifm", "hpSjlrGzdaAdd.htm?mcid=" + $("#mcid").val()+ "&devType=" + $("#devType").val());
  224. }