app-sort-rule.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view>
  3. <view class="search" @click="router">
  4. <view class="f-input dir-left-nowrap main-center cross-center">
  5. <image src="/static/image/icon/search.png"></image>
  6. <text>搜索</text>
  7. </view>
  8. </view>
  9. <form report-submit v-on:submit="getFormId">
  10. <view class="page-width sort-rule dir-left-nowrap">
  11. <button class="box-grow-1 item" v-on:click="setSort(1)" :class="[`${sort === 1 && sign === 'gift' ? theme + `-color` : sort === 1 && sign !== 'gift' ? theme + '-m-text ' + theme : ''}`]" formType="submit">综合</button>
  12. <button class="box-grow-1 item" v-on:click="setSort(2)" :class="[`${sort === 2 && sign === 'gift' ? theme + `-color` : sort === 2 && sign !== 'gift' ? theme + '-m-text ' + theme : ''}`]" formType="submit">最新</button>
  13. <button class="box-grow-1 item dir-left-nowrap main-center cross-center" :class="[`${sort === 3 && sign === 'gift' ? theme + `-color` : sort === 3 && sign !== 'gift' ? theme + '-m-text ' + theme : ''}`]"
  14. v-on:click="setSort(3)" formType="submit">
  15. <text class="price">价格</text>
  16. <image v-show="loading" class="icon" @load="loading=true" :class="sign === 'gift' ? theme + '-background' : theme + '-m-back ' + theme"
  17. :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>
  18. </button>
  19. <button class="box-grow-1 item" :class="[`${sort === 4 && sign === 'gift' ? theme + `-color` : sort === 4 && sign !== 'gift' ? theme + '-m-text ' + theme : ''}`]" v-on:click="setSort(4)" formType="submit">销量</button>
  20. <button @click="setStyle" class="box-grow-1 item dir-top-nowrap main-center cross-center">
  21. <image class="img-icon" :src="listStyle ? '/static/image/icon/square.png' : '/static/image/icon/row.png'" ></image>
  22. </button>
  23. </view>
  24. </form>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. name: 'sort-rule',
  30. props: {
  31. theme: String,
  32. sign: String,
  33. route: {
  34. type: String,
  35. default: `/pages/search/search`
  36. }
  37. },
  38. data() {
  39. return {
  40. sort: 1,
  41. sort_type: -1,
  42. loading: false,
  43. listStyle: false
  44. }
  45. },
  46. computed: {
  47. classObject: function() {
  48. return {
  49. default: this.sort_type === -1,
  50. tall: this.sort_type === 2,
  51. low: this.sort_type === 1,
  52. icon: true,
  53. 'default-background': true
  54. }
  55. }
  56. },
  57. methods: {
  58. getFormId(data) {
  59. },
  60. setSort(data) {
  61. this.sort = data;
  62. if (data !== 3) {
  63. this.sort_type = -1;
  64. } else {
  65. this.loading = true;
  66. switch (this.sort_type) {
  67. case -1:
  68. this.sort_type = 1;
  69. break;
  70. case 1:
  71. this.sort_type = 2;
  72. break;
  73. case 2:
  74. this.sort_type = 1;
  75. }
  76. }
  77. this.$emit('sort', data, this.sort_type);
  78. },
  79. setStyle() {
  80. this.listStyle = !this.listStyle;
  81. this.$emit('setStyle', this.listStyle);
  82. },
  83. router() {
  84. uni.navigateTo({
  85. url: this.route
  86. })
  87. }
  88. },
  89. }
  90. </script>
  91. <style scoped lang="scss">
  92. /*排序*/
  93. .sort-rule {
  94. height: #{96upx};
  95. width: #{750upx};
  96. background-color: #ffffff;
  97. .item {
  98. line-height: #{96upx};
  99. text-align: center;
  100. background-color: #ffffff;
  101. font-size: #{26upx};
  102. border: none;
  103. }
  104. .icon {
  105. width: #{16upx};
  106. height: #{22upx};
  107. margin-left: #{5upx};
  108. background-size: 100% 100%;
  109. background-repeat: no-repeat;
  110. }
  111. .img-icon {
  112. width: 31upx;
  113. height: 31upx;
  114. }
  115. .price {
  116. margin-right: #{5upx};
  117. }
  118. }
  119. .default-color {
  120. color: #ff4544;
  121. }
  122. .default-background {
  123. background-color: #ff4544;
  124. }
  125. .default {
  126. background-image: url('../../../static/image/icon/price-sort-default.png');
  127. }
  128. .tall {
  129. background-image: url('../../../static/image/icon/tall.png');
  130. }
  131. .low {
  132. background-image: url('../../../static/image/icon/low.png');
  133. }
  134. .search {
  135. height: 93upx;
  136. padding: 20upx 24upx 10upx 24upx;
  137. background-color: #ffffff;
  138. .f-input {
  139. width: 702upx;
  140. height: 64upx;
  141. border-radius: 32upx;
  142. background-color: #f7f7f7;
  143. >image {
  144. width: 26upx;
  145. height: 26upx;
  146. margin-right: 5upx;
  147. }
  148. >text {
  149. font-size: 26upx;
  150. color: #999999;
  151. margin-left: 5upx;
  152. }
  153. }
  154. }
  155. </style>