123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- $(function () {
- var zsIscrollHeight = $(".fmlistIscroll");
- var cententHeight = $(".fmlistIscroll div:first-child");
- heightvs(zsIscrollHeight,cententHeight);
- //输入框快速删除初始化
- mui(".mui-input-row input").input();
- /**
- * 初始化滚动条
- * */
- var iscroll;
- iscroll = new IScroll(".fmlistIscroll",{
- scrollbars: true,
- fadeScrollbars:true,
- scrollbars: 'custom',
- shrinkScrollbars:'clip',
- probeType: 2,
- click:true,
- });
- setTimeout(function(){
- iscroll.refresh();
- }, 600);
- /**
- * 下拉刷新上拉加载数据
- **/
- var pullUp = $("#pullUp"),
- pullUpLabel = $(".pullUpLabel"),
- loadingStep = 0;//加载状态0默认,1显示加载状态,2执行加载数据,只有当为0时才能再次加载,这是防止过快拉动刷新
- //滚动时触发
- iscroll.on("scroll",function(){
- if(loadingStep == 0 && !pullUp.attr("class").match('refresh')){
- if(this.y < (this.maxScrollY - 14)){//上拉加载更多
- pullUp.addClass("refresh").show();
- pullUp.css({"background":"","background-size":""});
- pullUpLabel.text("松手开始加载...");
- loadingStep = 1;
- iscroll.refresh();
- }
- }
- });
- //滚动结束触发
- iscroll.on("scrollEnd",function(){
- if(loadingStep == 1){
- if( pullUp.attr("class").match("refresh") ){//上拉加载操作
- pullUp.removeClass("refresh").addClass("loading");
- pullUpLabel.text("");
- pullUp.css({"background":"#D7DFEA url(views/haifmv/img/pullUp.gif) no-repeat center","background-size":"12%"});
- loadingStep = 2;
- pullUpAction();
- iscroll.refresh();
- }
- }
- });
- /**
- * 上拉加载方法
- * */
- function pullUpAction(){
- var page = parseInt($("#page").val())+1;
- var maxPages = $("#maxPages").val();
- if (page <= maxPages) {
- jQuery.ajax({
- type : "get",
- url : "addSjlrFmjlSrarch.htm",
- data : {
- "mcid" : $("#mcid").val(),
- "cxeph": $("#dweb").val(),
- "date" : $("#date").val(),
- "page" : page
- },
- dataType : "json",
- async : true,
- success : function(data) {
- setTimeout(function() {
- for (var i = 0 ; i < data.length; i++) {
- var obj = data[i];
- oDiv = $("<div class='rowflex' data-ep="+obj.eph+" class='chooseDweb' data-for="+obj.dweb+">"
- + "<div class='column flex-end' style='width: 17%; justify-content: inherit !important;'>"
- + "<span class='xzxb'><div><div></div></div></span>"
- + "</div>"
- + "<div class='column flex-start' style='width: 83%;'>"
- + "<ul class='mui-table-view column xxul'>"
- + "<li class='mui-table-view-cell'>"
- + "<p style='padding: 0;box-shadow: none;' id ='eph'>"+obj.eph+"</p>"
- + "</li>"
- + "<li class='mui-table-view-cell align-itemscenter' style='padding: 0;width: 100%;'>"
- + "<div class='column'>"
- + "<div class='align-itemscenter tbbox'>"
- + "<span class='pl'></span>"
- + "<span style='padding-right:0.05rem ;'>品类</span>"
- + "</div>"
- + "<span class='text'>"+obj.pzStr+"</span>"
- + "</div>"
- + "<div class='column'>"
- + "<div class='align-itemscenter tbbox'>"
- +"<span class='dqzt'></span>"
- + "<span style='padding-right:0.05rem ;'>当前状态</span>"
- + "</div>"
- + "<span class='text'>"+obj.dqztStr+"</span>"
- + "</div>"
- + "<div class='column'>"
- + "<div class='align-itemscenter tbbox'>"
- + "<span class='spts'></span>"
- + "<span style='padding-right:0.05rem ;'>怀孕天数</span>"
- + "</div>"
- + "<span class='text'>"+obj.hyts +"天</span>"
- + "</div>"
- + "</li>"
- + "</ul>"
- + "</div>"
- + "</div>"
- + "<span class='xian'></span>");
- $(".addList").append(oDiv);
- pullUp.attr("class","");
- pullUpLabel.text("上拉加载更多");
- pullUp.css({"background":""});
- iscroll.refresh();
- loadingStep = 0;
- }
- },1000);
- $("#page").val(page);
- }
- });
- }else {
- pullUp.css({"background":"","background-size":""});
- pullUpLabel.text("没有数据了");
- iscroll.refresh();
- }
- }
- /**
- * 点击input获取焦点
- * */
- $(".mui-input-row.mui-search,.mui-input-row .mui-input-clear~.mui-icon-clear:before").on("touchstart", function (e) {
- $("input[type='search']").focus();
- });
- /**
- * 点击input以外失去焦点
- * */
- var beforeIpt=null;
- $("input").on("focus", function (e) {
- beforeIpt=this;
- });
- $(document).on("tap", function (e) {
- if(e.target.nodeName.toLowerCase()!="input") {
- if(beforeIpt) {
- beforeIpt.blur();
- beforeIpt=null;
- }
- }
- });
- /**
- * 添加遮罩层并选中耳标
- * */
- $(".fmlistIscroll").on("tap",".rowflex",function(){
- var that = $(this);
- $(this).children().find(".xzxb>div").addClass("xzxboverlay").parent().parent().parent().siblings().children().find(".xzxb>div").removeClass("xzxboverlay");
- var dataEp = this.getAttribute("data-ep");
- var btnArray = ['否', '是'];
- mui.confirm('是否选择'+ dataEp + "的耳牌编号",'提示', btnArray, function(e) {
- if (e.index == 1) {
- haifm.loadMobilePage("haifm", "hvSjlrFmAdd.htm?mcid=" + $("#mcid").val() + "&dweb=" + that.data("for") +"&rsid="+$("#rsid").val() + "&date=" + $("#date").val() +"&eph=" + dataEp);
- } else {
- that.children().find(".xzxb>div").removeClass("xzxboverlay");
- }
- });
- });
- $("#dweb").bind("blur", function() {
- haifm.loadMobilePage("haifm", "getHaifmvFmjlSearchDweb.htm?mcid=" + $("#mcid").val() + "&cxeph=" + $("#dweb").val() + "&date=" + $("#date").val());
- });
- //模糊查询键盘enter键事件
- $("input[type='search']").on('keypress',function(e) {
- var keycode = e.keyCode;
- if(keycode=='13') {
- e.preventDefault();
- //请求搜索接口
- haifm.loadMobilePage("haifm", "getHaifmvFmjlSearchDweb.htm?mcid=" + $("#mcid").val() + "&cxeph=" + $("#dweb").val() + "&date=" + $("#date").val());
- }
- });
- });
- /**
- * 返回
- */
- function backUrl() {
- haifm.loadMobilePage("haifm", "hvSjlrFmAdd.htm?mcid=" + $("#mcid").val());
- }
- //滑动高度和内容高度对比
- function heightvs(zsIscrollHeight,cententHeight){
- if(zsIscrollHeight.height() > cententHeight.height()){
- $("#pullUp").hide();
- }else{
- $("#pullUp").show();
- }
- }
|