_keyword.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <div class="container" id="searchResult">
  3. <detail-brand></detail-brand>
  4. <result-title :keyword="key" :page="nowPage"></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. if (!this.filter.goods_kindId) {
  61. this.$store.dispatch('searchData/searchForKinds', {collectList: 'goods_kind', keyword: this.$route.query.w, paramJSON: this.paramJSON})
  62. }
  63. },
  64. reloadBrand: function () {
  65. if (!this.filter.goods_brandId) {
  66. this.$store.dispatch('searchData/searchForBrands', {collectList: 'goods_brand', keyword: this.$route.query.w, paramJSON: this.paramJSON})
  67. }
  68. },
  69. reloadStoreType: function () {
  70. if (!this.filter.goods_store_type) {
  71. this.$store.dispatch('searchData/searchForStoreType', {collectList: 'goods_store_type', keyword: this.$route.query.w, paramJSON: this.paramJSON})
  72. }
  73. },
  74. reloadCrname: function () {
  75. if (!this.filter.goods_crname) {
  76. this.$store.dispatch('searchData/searchForCrname', {collectList: 'goods_crname', keyword: this.$route.query.w, paramJSON: this.paramJSON})
  77. }
  78. },
  79. listenPage: function (nPage) {
  80. this.nowPage = nPage
  81. this.reloadList()
  82. },
  83. listenSort: function (sortType) {
  84. this.sorting = sortType
  85. this.reloadList()
  86. },
  87. listenPriceFilter: function (filterType) {
  88. if (filterType.goods_minpricermb) {
  89. this.filter.goods_minpricermb = filterType.goods_minpricermb
  90. } else {
  91. delete this.filter.goods_minpricermb
  92. }
  93. if (filterType.goods_maxpricermb) {
  94. this.filter.goods_maxpricermb = filterType.goods_maxpricermb
  95. } else {
  96. delete this.filter.goods_maxpricermb
  97. }
  98. this.reloadList()
  99. },
  100. listenKindFilter: function (kindarr) {
  101. if (kindarr.length === 0) {
  102. delete this.filter.goods_kindId
  103. delete this.paramJSON.goods_kindid
  104. this.reloadKind()
  105. this.reloadBrand()
  106. this.reloadList()
  107. this.reloadStoreType()
  108. this.reloadCrname()
  109. } else {
  110. this.filter.goods_kindId = kindarr
  111. this.paramJSON.goods_kindid = kindarr
  112. this.reloadBrand()
  113. this.reloadList()
  114. this.reloadStoreType()
  115. this.reloadCrname()
  116. }
  117. },
  118. listenBrandFilter: function (brandarr) {
  119. if (brandarr.length === 0) {
  120. delete this.filter.goods_brandId
  121. delete this.paramJSON.goods_brandid
  122. this.reloadKind()
  123. this.reloadBrand()
  124. this.reloadList()
  125. this.reloadStoreType()
  126. this.reloadCrname()
  127. } else {
  128. this.filter.goods_brandId = brandarr
  129. this.paramJSON.goods_brandid = brandarr
  130. this.reloadKind()
  131. this.reloadList()
  132. this.reloadStoreType()
  133. this.reloadCrname()
  134. }
  135. },
  136. listenTypeFilter: function (typearr) {
  137. if (typearr.length === 0) {
  138. delete this.filter.goods_store_type
  139. delete this.paramJSON.goods_store_type
  140. this.reloadKind()
  141. this.reloadBrand()
  142. this.reloadList()
  143. this.reloadCrname()
  144. } else {
  145. this.filter.goods_store_type = typearr
  146. this.paramJSON.goods_store_type = typearr
  147. this.reloadKind()
  148. this.reloadBrand()
  149. this.reloadList()
  150. this.reloadCrname()
  151. }
  152. },
  153. listenCrnameFilter: function (crnamearr) {
  154. if (crnamearr.length === 0) {
  155. delete this.filter.goods_crname
  156. delete this.paramJSON.goods_crname
  157. this.reloadKind()
  158. this.reloadBrand()
  159. this.reloadList()
  160. this.reloadStoreType()
  161. } else {
  162. this.filter.goods_crname = crnamearr
  163. this.paramJSON.goods_crname = crnamearr
  164. this.reloadKind()
  165. this.reloadBrand()
  166. this.reloadList()
  167. this.reloadStoreType()
  168. }
  169. },
  170. listenCrnameFlag: function (obj) {
  171. if (obj.rmb_click_flag && obj.usd_click_flag) {
  172. this.crname_click_flag.rmb_click_flag = false
  173. this.crname_click_flag.usd_click_flag = false
  174. } else {
  175. this.crname_click_flag.rmb_click_flag = obj.rmb_click_flag
  176. this.crname_click_flag.usd_click_flag = obj.usd_click_flag
  177. }
  178. }
  179. }
  180. }
  181. </script>