_keyword.vue 6.0 KB

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