searchZztt.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. $(function () {
  2. var zsIscrollHeight = $(".zzttlistIscroll");
  3. var cententHeight = $(".zzttlistIscroll div:first-child");
  4. heightvs(zsIscrollHeight,cententHeight);
  5. //输入框快速删除初始化
  6. mui(".mui-input-row input").input();
  7. /**
  8. * 初始化滚动条
  9. * */
  10. var iscroll;
  11. iscroll = new IScroll(".zzttlistIscroll",{
  12. scrollbars: true,
  13. fadeScrollbars:true,
  14. scrollbars: 'custom',
  15. shrinkScrollbars:'clip',
  16. probeType: 2,
  17. click:true,
  18. });
  19. setTimeout(function(){
  20. iscroll.refresh();
  21. }, 600);
  22. /**
  23. * 下拉刷新上拉加载数据
  24. **/
  25. var pullUp = $("#pullUp"),
  26. pullUpLabel = $(".pullUpLabel"),
  27. loadingStep = 0;//加载状态0默认,1显示加载状态,2执行加载数据,只有当为0时才能再次加载,这是防止过快拉动刷新
  28. //滚动时触发
  29. iscroll.on("scroll",function(){
  30. if(loadingStep == 0 && !pullUp.attr("class").match('refresh')){
  31. if(this.y < (this.maxScrollY - 14)){//上拉加载更多
  32. pullUp.addClass("refresh").show();
  33. pullUp.css({"background":"","background-size":""});
  34. pullUpLabel.text("松手开始加载...");
  35. loadingStep = 1;
  36. iscroll.refresh();
  37. }
  38. }
  39. });
  40. //滚动结束触发
  41. iscroll.on("scrollEnd",function(){
  42. if(loadingStep == 1){
  43. if( pullUp.attr("class").match("refresh") ){//上拉加载操作
  44. pullUp.removeClass("refresh").addClass("loading");
  45. pullUpLabel.text("");
  46. pullUp.css({"background":"#D7DFEA url(views/haifmv/img/pullUp.gif) no-repeat center","background-size":"12%"});
  47. loadingStep = 2;
  48. pullUpAction();
  49. iscroll.refresh();
  50. }
  51. }
  52. });
  53. /**
  54. * 上拉加载方法
  55. * */
  56. function pullUpAction(){
  57. var page = parseInt($("#page").val())+1;
  58. var maxPages = $("#maxPages").val();
  59. if (page <= maxPages) {
  60. jQuery.ajax({
  61. type : "get",
  62. url : "addSjlrZzttSrarch.htm",
  63. data : {
  64. "mcid" : $("#mcid").val(),
  65. "cxeph": $("#dweb").val(),
  66. "date" : $("#date").val(),
  67. "page" : page
  68. },
  69. dataType : "json",
  70. async : true,
  71. success : function(data) {
  72. setTimeout(function() {
  73. for (var i = 0 ; i < data.length; i++) {
  74. var obj = data[i];
  75. oDiv = $("<div class='rowflex' data-ep="+obj.eph+" class='chooseDweb' data-for="+obj.dweb+">"
  76. + "<div class='column flex-end' style='width: 17%; justify-content: inherit !important;'>"
  77. + "<span class='xzxb'><div><div></div></div></span>"
  78. + "</div>"
  79. + "<div class='column flex-start' style='width: 83%;'>"
  80. + "<ul class='mui-table-view column xxul'>"
  81. + "<li class='mui-table-view-cell'>"
  82. + "<p style='padding: 0;box-shadow: none;' id ='eph'>"+obj.eph+"</p>"
  83. + "</li>"
  84. + "<li class='mui-table-view-cell align-itemscenter' style='padding: 0;width: 100%;'>"
  85. + "<div class='column'>"
  86. + "<div class='align-itemscenter tbbox'>"
  87. + "<span class='pl'></span>"
  88. + "<span style='padding-right:0.05rem ;'>舍栏</span>"
  89. + "</div>"
  90. + "<span class='text'>"+obj.slStr+"</span>"
  91. + "</div>"
  92. + "<div class='column'>"
  93. + "<div class='align-itemscenter tbbox'>"
  94. +"<span class='dqzt'></span>"
  95. + "<span style='padding-right:0.05rem ;'>当前状态</span>"
  96. + "</div>"
  97. + "<span class='text'>"+obj.dqztStr+"</span>"
  98. + "</div>"
  99. + "</li>"
  100. + "</ul>"
  101. + "</div>"
  102. + "</div>"
  103. + "<span class='xian'></span>");
  104. $(".addList").append(oDiv);
  105. pullUp.attr("class","");
  106. pullUpLabel.text("上拉加载更多");
  107. pullUp.css({"background":""});
  108. iscroll.refresh();
  109. loadingStep = 0;
  110. }
  111. },1000);
  112. $("#page").val(page);
  113. }
  114. });
  115. }else {
  116. pullUp.css({"background":"","background-size":""});
  117. pullUpLabel.text("没有数据了");
  118. iscroll.refresh();
  119. }
  120. }
  121. /**
  122. * 点击input获取焦点
  123. * */
  124. $(".mui-input-row.mui-search,.mui-input-row .mui-input-clear~.mui-icon-clear:before").on("touchstart", function (e) {
  125. $("input[type='search']").focus();
  126. });
  127. /**
  128. * 点击input以外失去焦点
  129. * */
  130. var beforeIpt=null;
  131. $("input").on("focus", function (e) {
  132. beforeIpt=this;
  133. });
  134. $(document).on("tap", function (e) {
  135. if(e.target.nodeName.toLowerCase()!="input") {
  136. if(beforeIpt) {
  137. beforeIpt.blur();
  138. beforeIpt=null;
  139. }
  140. }
  141. });
  142. /**
  143. * 添加遮罩层并选中耳标
  144. * */
  145. $(".zzttlistIscroll").on("tap",".rowflex",function(){
  146. var that = $(this);
  147. $(this).children().find(".xzxb>div").addClass("xzxboverlay").parent().parent().parent().siblings().children().find(".xzxb>div").removeClass("xzxboverlay");
  148. var dataEp = this.getAttribute("data-ep");
  149. var btnArray = ['否', '是'];
  150. mui.confirm('是否选择'+ dataEp + "的耳牌编号",'提示', btnArray, function(e) {
  151. if (e.index == 1) {
  152. haifm.loadMobilePage("haifm", "hvSjlrZzttEdit.htm?mcid=" + $("#mcid").val() + "&date=" +$("#date").val() + "&eph=" + dataEp + "&dweb=" + that.data("for"));
  153. } else {
  154. that.children().find(".xzxb>div").removeClass("xzxboverlay");
  155. }
  156. });
  157. });
  158. $("#dweb").bind("blur", function() {
  159. var ids = $("#id").val();
  160. var temp = "";
  161. if (id != "") {
  162. temp = "&id=" + ids;
  163. }
  164. haifm.loadMobilePage("haifm", "getHaifmvZzttSearchDweb.htm?mcid=" + $("#mcid").val() + "&cxeph=" + $("#dweb").val() + temp + "&date=" +$("#date").val());
  165. });
  166. //模糊查询键盘enter键事件
  167. $("input[type='search']").on('keypress',function(e) {
  168. var keycode = e.keyCode;
  169. if(keycode=='13') {
  170. e.preventDefault();
  171. //请求搜索接口
  172. var ids = $("#id").val();
  173. var temp = "";
  174. if (id != "") {
  175. temp = "&id=" + ids;
  176. }
  177. haifm.loadMobilePage("haifm", "getHaifmvZzttSearchDweb.htm?mcid=" + $("#mcid").val() + "&cxeph=" + $("#dweb").val() + temp + "&date=" +$("#date").val());
  178. }
  179. });
  180. });
  181. /**
  182. * 返回
  183. */
  184. function backUrl() {
  185. var ids = $("#id").val();
  186. var temp = "";
  187. if (id != "") {
  188. temp = "&id=" + ids;
  189. }
  190. haifm.loadMobilePage("haifm", "hvSjlrZzttEdit.htm?mcid=" + $("#mcid").val() + "&id=" + $("#id").val() + temp + "&date=" +$("#date").val());
  191. }
  192. //滑动高度和内容高度对比
  193. function heightvs(zsIscrollHeight,cententHeight){
  194. if(zsIscrollHeight.height() > cententHeight.height()){
  195. $("#pullUp").hide();
  196. }else{
  197. $("#pullUp").show();
  198. }
  199. }