searchRsep.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. $(function () {
  2. var zsIscrollHeight = $(".rslistIscroll");
  3. var cententHeight = $(".rslistIscroll 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(".rslistIscroll",{
  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 : "addSjlrRsjlSrarch.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.pzStr+"</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. $("#dweb").bind("blur", function() {
  122. haifm.loadMobilePage("haifm", "getHaifmvRsjlSearchDweb.htm?mcid=" + $("#mcid").val() + "&cxeph=" + $("#dweb").val() + "&date=" + $("#date").val());
  123. });
  124. /**
  125. * 点击input获取焦点
  126. * */
  127. $(".mui-input-row.mui-search,.mui-input-row .mui-input-clear~.mui-icon-clear:before").on("touchstart", function (e) {
  128. $("input[type='search']").focus();
  129. });
  130. /**
  131. * 点击input以外失去焦点
  132. * */
  133. var beforeIpt=null;
  134. $("input").on("focus", function (e) {
  135. beforeIpt=this;
  136. });
  137. $(document).on("tap", function (e) {
  138. if(e.target.nodeName.toLowerCase()!="input") {
  139. if(beforeIpt) {
  140. beforeIpt.blur();
  141. beforeIpt=null;
  142. }
  143. }
  144. });
  145. /**
  146. * 添加遮罩层并选中耳标
  147. * */
  148. $(".rslistIscroll").on("tap",".rowflex",function(){
  149. var that = $(this);
  150. $(this).children().find(".xzxb>div").addClass("xzxboverlay").parent().parent().parent().siblings().children().find(".xzxb>div").removeClass("xzxboverlay");
  151. var dataEp = this.getAttribute("data-ep");
  152. var btnArray = ['否', '是'];
  153. mui.confirm('是否选择'+ dataEp + "的耳牌编号",'提示', btnArray, function(e) {
  154. if (e.index == 1) {
  155. haifm.loadMobilePage("haifm", "hvSjlrRsAdd.htm?mcid=" + $("#mcid").val() + "&dweb=" + that.data("for") +"&rsid="+$("#rsid").val() + "&date=" + $("#date").val()+"&eph=" + dataEp);
  156. } else {
  157. that.children().find(".xzxb>div").removeClass("xzxboverlay");
  158. }
  159. });
  160. });
  161. //模糊查询键盘enter键事件
  162. $("input[type='search']").on('keypress',function(e) {
  163. var keycode = e.keyCode;
  164. if(keycode=='13') {
  165. e.preventDefault();
  166. //请求搜索接口
  167. haifm.loadMobilePage("haifm", "getHaifmvRsjlSearchDweb.htm?mcid=" + $("#mcid").val() + "&cxeph=" + $("#dweb").val() + "&date=" + $("#date").val());
  168. }
  169. });
  170. });
  171. /**
  172. * 返回
  173. */
  174. function backUrl() {
  175. haifm.loadMobilePage("haifm", "hvSjlrRsAdd.htm?mcid=" + $("#mcid").val());
  176. }
  177. //滑动高度和内容高度对比
  178. function heightvs(zsIscrollHeight,cententHeight){
  179. if(zsIscrollHeight.height() > cententHeight.height()){
  180. $("#pullUp").hide();
  181. }else{
  182. $("#pullUp").show();
  183. }
  184. }