mui.init(); var initDate, initStatus, initType; mui.plusReady(function(){ var self = plus.webview.currentWebview(); initDate = self.dateVal || ''; initStatus = self.statusVal || ''; initType = self.typeVal || ''; setTagActive(); bindEvents(); }) function setTagActive(){ $(".tag").removeClass("active"); if(initDate){ $(".date-tag[data-val="+initDate+"]").addClass("active"); }else{ $(".date-tag").eq(0).addClass("active"); } if(initStatus){ $(".status-tag[data-val="+initStatus+"]").addClass("active"); }else{ $(".status-tag").eq(0).addClass("active"); } if(initType){ $(".type-tag[data-val="+initType+"]").addClass("active"); }else{ $(".type-tag").eq(0).addClass("active"); } } function bindEvents(){ $(".confirm-btn").on('click', function(){ var self = plus.webview.currentWebview(), opener = self.opener(); var $date = $(".date-tag.active"), $status = $(".status-tag.active"), $type = $(".type-tag.active"); var date = $date.attr("data-val"), dateName = $date.text(), status = $status.attr("data-val"), statusName = $status.text(), type = $type.attr("data-val"), typeName = $type.text(); mui.fire(opener, "setFilterData", { date: date, dateName: dateName, status: status, statusName: statusName, type: type, typeName: typeName }); mui.fire(opener, "hideShaiXuan"); }); $(".cancel-btn").on('click', function(){ var self = plus.webview.currentWebview(), opener = self.opener(); mui.fire(opener, "hideShaiXuan"); }); $(".tag").on('click', function(){ var $this = $(this), value = $this.attr("data-val"), name = $this.attr("data-type"); if($this.hasClass("active")){ return false; } $("."+name+"-tag").removeClass("active"); $this.addClass("active"); }); $(".reset-btn").on('click', function(){ initDate = ''; initStatus = ''; initType = ''; setTagActive(); }); window.addEventListener("setTagActive", function(arg){ initDate = arg.detail.dateVal; initStatus = arg.detail.statusVal; initType = arg.detail.typeVal; setTagActive(); }) }