hpSjlrMzDaIndex.js 7.3 KB

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