_keyword.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <div class="container" id="searchResult">
  3. <result-title :keyword="key"></result-title>
  4. <kind @kindFilterEvent="listenKindFilter"
  5. @brandFilterEvent="listenBrandFilter"
  6. @typeFilterEvent="listenTypeFilter"
  7. @crnameFilterEvent="listenCrnameFilter"
  8. @crnameFlagEvent="listenCrnameFlag"
  9. ></kind>
  10. <good-list @pageEvent="listenPage"
  11. @sortEvent="listenSort"
  12. @filterPriceEvent="listenPriceFilter"
  13. :crname_click_flag="crname_click_flag"
  14. ></good-list>
  15. </div>
  16. </template>
  17. <script>
  18. import { GoodList, Kind, ResultTitle } from '~components/search'
  19. export default{
  20. layout: 'main',
  21. data () {
  22. return {
  23. key: this.$route.query.w,
  24. pageSize: 15,
  25. nowPage: 1,
  26. sorting: {'GO_RESERVE': 'DESC', 'GO_SEARCH': 'DESC'},
  27. filter: {},
  28. paramJSON: {},
  29. crname_click_flag: {
  30. rmb_click_flag: false,
  31. usd_click_flag: false
  32. }
  33. }
  34. },
  35. fetch ({store, route}) {
  36. return Promise.all([
  37. store.dispatch('searchData/searchForKinds', {collectList: 'goods_kind', keyword: route.query.w, paramJSON: {}}),
  38. store.dispatch('searchData/searchForBrands', {collectList: 'goods_brand', keyword: route.query.w, paramJSON: {}}),
  39. store.dispatch('searchData/searchForList', {count: 15, filter: {}, keyword: route.query.w, page: 1, sorting: {'GO_RESERVE': 'DESC', 'GO_SEARCH': 'DESC'}}),
  40. store.dispatch('searchData/searchForStoreType', {collectList: 'goods_store_type', keyword: route.query.w, paramJSON: {}}),
  41. store.dispatch('searchData/searchForCrname', {collectList: 'goods_crname', keyword: route.query.w, paramJSON: {}})
  42. ])
  43. },
  44. components: {
  45. ResultTitle,
  46. Kind,
  47. GoodList
  48. },
  49. methods: {
  50. reloadList: function () {
  51. if (this.sorting === {}) {
  52. this.sorting = {'GO_RESERVE': 'DESC', 'GO_SEARCH': 'DESC'}
  53. }
  54. this.$store.dispatch('searchData/searchForList', {count: this.pageSize, filter: this.filter, keyword: this.$route.query.w, page: this.nowPage, sorting: this.sorting})
  55. },
  56. reloadKind: function () {
  57. this.$store.dispatch('searchData/searchForKinds', {collectList: 'goods_kind', keyword: this.$route.query.w, paramJSON: this.paramJSON})
  58. },
  59. reloadBrand: function () {
  60. this.$store.dispatch('searchData/searchForBrands', {collectList: 'goods_brand', keyword: this.$route.query.w, paramJSON: this.paramJSON})
  61. },
  62. reloadStoreType: function () {
  63. this.$store.dispatch('searchData/searchForStoreType', {collectList: 'goods_store_type', keyword: this.$route.query.w, paramJSON: this.paramJSON})
  64. },
  65. reloadCrname: function () {
  66. this.$store.dispatch('searchData/searchForCrname', {collectList: 'goods_crname', keyword: this.$route.query.w, paramJSON: this.paramJSON})
  67. },
  68. listenPage: function (nPage) {
  69. this.nowPage = nPage
  70. this.reloadList()
  71. },
  72. listenSort: function (sortType) {
  73. this.sorting = sortType
  74. this.reloadList()
  75. },
  76. listenPriceFilter: function (filterType) {
  77. if (filterType.goods_minpricermb) {
  78. this.filter.goods_minpricermb = filterType.goods_minpricermb
  79. } else {
  80. delete this.filter.goods_minpricermb
  81. }
  82. if (filterType.goods_maxpricermb) {
  83. this.filter.goods_maxpricermb = filterType.goods_maxpricermb
  84. } else {
  85. delete this.filter.goods_maxpricermb
  86. }
  87. this.reloadList()
  88. },
  89. listenKindFilter: function (kindarr) {
  90. console.log(kindarr.length)
  91. if (kindarr.length === 0) {
  92. delete this.filter.goods_kindId
  93. delete this.paramJSON.goods_kindid
  94. this.reloadBrand()
  95. this.reloadList()
  96. this.reloadStoreType()
  97. this.reloadCrname()
  98. } else {
  99. this.filter.goods_kindId = kindarr
  100. this.paramJSON.goods_kindid = kindarr
  101. this.reloadBrand()
  102. this.reloadList()
  103. this.reloadStoreType()
  104. this.reloadCrname()
  105. }
  106. },
  107. listenBrandFilter: function (brandarr) {
  108. if (brandarr.length === 0) {
  109. delete this.filter.goods_brandId
  110. delete this.paramJSON.goods_brandid
  111. this.reloadKind()
  112. this.reloadList()
  113. this.reloadStoreType()
  114. this.reloadCrname()
  115. } else {
  116. this.filter.goods_brandId = brandarr
  117. this.paramJSON.goods_brandid = brandarr
  118. this.reloadKind()
  119. this.reloadList()
  120. this.reloadStoreType()
  121. this.reloadCrname()
  122. }
  123. },
  124. listenTypeFilter: function (typearr) {
  125. if (typearr.length === 0) {
  126. delete this.filter.goods_store_type
  127. delete this.paramJSON.goods_store_type
  128. this.reloadKind()
  129. this.reloadBrand()
  130. this.reloadList()
  131. this.reloadCrname()
  132. } else {
  133. this.filter.goods_store_type = typearr
  134. this.paramJSON.goods_store_type = typearr
  135. this.reloadKind()
  136. this.reloadBrand()
  137. this.reloadList()
  138. this.reloadCrname()
  139. }
  140. },
  141. listenCrnameFilter: function (crnamearr) {
  142. if (crnamearr.length === 0) {
  143. delete this.filter.goods_crname
  144. delete this.paramJSON.goods_crname
  145. this.reloadKind()
  146. this.reloadBrand()
  147. this.reloadList()
  148. this.reloadStoreType()
  149. } else {
  150. this.filter.goods_crname = crnamearr
  151. this.paramJSON.goods_crname = crnamearr
  152. this.reloadKind()
  153. this.reloadBrand()
  154. this.reloadList()
  155. this.reloadStoreType()
  156. }
  157. },
  158. listenCrnameFlag: function (obj) {
  159. this.crname_click_flag.rmb_click_flag = obj.rmb_click_flag
  160. this.crname_click_flag.usd_click_flag = obj.usd_click_flag
  161. }
  162. }
  163. }
  164. </script>