app-sort-rule.vue 4.8 KB

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