app-sort-rule.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <form report-submit v-on:submit="getFormId">
  3. <view class="page-width sort-rule dir-left-nowrap">
  4. <button class="box-grow-1 item" v-on:click="setSort(1)" :class="[`${sort === 1 ? theme + `-color` : ``}`]" formType="submit">综合</button>
  5. <button class="box-grow-1 item" v-on:click="setSort(2)" :class="[`${sort === 2 ? theme + `-color` : ``}`]" formType="submit">最新</button>
  6. <button class="box-grow-1 item dir-left-nowrap main-center cross-center" :class="[`${sort === 3 ? theme + `-color` : ``}`]"
  7. v-on:click="setSort(3)" formType="submit">
  8. <text class="price">价格</text>
  9. <image v-show="loading" @load="loading=true" :class="[`${theme}-background`, `icon`]"
  10. :src="sort_type === -1 ? `/static/image/icon/price-sort-default.png` : sort_type === 2 ? `/static/image/icon/tall.png` : sort_type === 1 ? `/static/image/icon/low.png` : ``"></image>
  11. </button>
  12. <button class="box-grow-1 item" :class="[`${sort === 4 ? theme + `-color` : ``}`]" v-on:click="setSort(4)" formType="submit">销量</button>
  13. </view>
  14. </form>
  15. </template>
  16. <script>
  17. export default {
  18. name: 'sort-rule',
  19. props: {
  20. theme: String,
  21. },
  22. data() {
  23. return {
  24. sort: 1,
  25. sort_type: -1,
  26. loading: false,
  27. }
  28. },
  29. computed: {
  30. classObject: function() {
  31. return {
  32. default: this.sort_type === -1,
  33. tall: this.sort_type === 2,
  34. low: this.sort_type === 1,
  35. icon: true,
  36. 'default-background': true
  37. }
  38. }
  39. },
  40. methods: {
  41. getFormId(data) {
  42. console.log(data);
  43. },
  44. setSort(data) {
  45. this.sort = data;
  46. if (data !== 3) {
  47. this.sort_type = -1;
  48. } else {
  49. this.loading = true;
  50. switch (this.sort_type) {
  51. case -1:
  52. this.sort_type = 1;
  53. break;
  54. case 1:
  55. this.sort_type = 2;
  56. break;
  57. case 2:
  58. this.sort_type = 1;
  59. }
  60. }
  61. this.$emit('sort', data, this.sort_type);
  62. }
  63. },
  64. }
  65. </script>
  66. <style scoped lang="scss">
  67. /*排序*/
  68. .sort-rule {
  69. height: #{96upx};
  70. width: #{750upx};
  71. background-color: #ffffff;
  72. .item {
  73. line-height: #{96upx};
  74. text-align: center;
  75. background-color: #ffffff;
  76. font-size: #{26upx};
  77. border: none;
  78. }
  79. .icon {
  80. width: #{16upx};
  81. height: #{22upx};
  82. margin-left: #{5upx};
  83. background-size: 100% 100%;
  84. background-repeat: no-repeat;
  85. }
  86. .price {
  87. margin-right: #{5upx};
  88. }
  89. }
  90. .default-color {
  91. color: #ff4544;
  92. }
  93. .default-background {
  94. background-color: #ff4544;
  95. }
  96. .default {
  97. background-image: url('../../../static/image/icon/price-sort-default.png');
  98. }
  99. .tall {
  100. background-image: url('../../../static/image/icon/tall.png');
  101. }
  102. .low {
  103. background-image: url('../../../static/image/icon/low.png');
  104. }
  105. </style>