filter.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. mui.init();
  2. var initDate,
  3. initStatus,
  4. initType;
  5. mui.plusReady(function(){
  6. var self = plus.webview.currentWebview();
  7. initDate = self.dateVal || '';
  8. initStatus = self.statusVal || '';
  9. initType = self.typeVal || '';
  10. setTagActive();
  11. bindEvents();
  12. })
  13. function setTagActive(){
  14. $(".tag").removeClass("active");
  15. if(initDate){
  16. $(".date-tag[data-val="+initDate+"]").addClass("active");
  17. }else{
  18. $(".date-tag").eq(0).addClass("active");
  19. }
  20. if(initStatus){
  21. $(".status-tag[data-val="+initStatus+"]").addClass("active");
  22. }else{
  23. $(".status-tag").eq(0).addClass("active");
  24. }
  25. if(initType){
  26. $(".type-tag[data-val="+initType+"]").addClass("active");
  27. }else{
  28. $(".type-tag").eq(0).addClass("active");
  29. }
  30. }
  31. function bindEvents(){
  32. $(".confirm-btn").on('click', function(){
  33. var self = plus.webview.currentWebview(),
  34. opener = self.opener();
  35. var $date = $(".date-tag.active"),
  36. $status = $(".status-tag.active"),
  37. $type = $(".type-tag.active");
  38. var date = $date.attr("data-val"),
  39. dateName = $date.text(),
  40. status = $status.attr("data-val"),
  41. statusName = $status.text(),
  42. type = $type.attr("data-val"),
  43. typeName = $type.text();
  44. mui.fire(opener, "setFilterData", {
  45. date: date,
  46. dateName: dateName,
  47. status: status,
  48. statusName: statusName,
  49. type: type,
  50. typeName: typeName
  51. });
  52. mui.fire(opener, "hideShaiXuan");
  53. });
  54. $(".cancel-btn").on('click', function(){
  55. var self = plus.webview.currentWebview(),
  56. opener = self.opener();
  57. mui.fire(opener, "hideShaiXuan");
  58. });
  59. $(".tag").on('click', function(){
  60. var $this = $(this),
  61. value = $this.attr("data-val"),
  62. name = $this.attr("data-type");
  63. if($this.hasClass("active")){
  64. return false;
  65. }
  66. $("."+name+"-tag").removeClass("active");
  67. $this.addClass("active");
  68. });
  69. $(".reset-btn").on('click', function(){
  70. initDate = '';
  71. initStatus = '';
  72. initType = '';
  73. setTagActive();
  74. });
  75. window.addEventListener("setTagActive", function(arg){
  76. initDate = arg.detail.dateVal;
  77. initStatus = arg.detail.statusVal;
  78. initType = arg.detail.typeVal;
  79. setTagActive();
  80. })
  81. }