_keyword.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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: {},
  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: {}}),
  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 = {}
  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. this.nowPage = 1
  102. if (kindarr.length === 0) {
  103. delete this.filter.goods_kindId
  104. delete this.paramJSON.goods_kindid
  105. this.reloadKind()
  106. this.reloadBrand()
  107. this.reloadList()
  108. this.reloadStoreType()
  109. this.reloadCrname()
  110. } else {
  111. this.filter.goods_kindId = kindarr
  112. this.paramJSON.goods_kindid = kindarr
  113. this.reloadBrand()
  114. this.reloadList()
  115. this.reloadStoreType()
  116. this.reloadCrname()
  117. }
  118. },
  119. listenBrandFilter: function (brandarr) {
  120. this.nowPage = 1
  121. if (brandarr.length === 0) {
  122. delete this.filter.goods_brandId
  123. delete this.paramJSON.goods_brandid
  124. this.reloadKind()
  125. this.reloadBrand()
  126. this.reloadList()
  127. this.reloadStoreType()
  128. this.reloadCrname()
  129. } else {
  130. this.filter.goods_brandId = brandarr
  131. this.paramJSON.goods_brandid = brandarr
  132. this.reloadKind()
  133. this.reloadList()
  134. this.reloadStoreType()
  135. this.reloadCrname()
  136. }
  137. },
  138. listenTypeFilter: function (typearr) {
  139. this.nowPage = 1
  140. if (typearr.length === 0) {
  141. delete this.filter.goods_store_type
  142. delete this.paramJSON.goods_store_type
  143. this.reloadKind()
  144. this.reloadBrand()
  145. this.reloadList()
  146. this.reloadCrname()
  147. } else {
  148. this.filter.goods_store_type = typearr
  149. this.paramJSON.goods_store_type = typearr
  150. this.reloadKind()
  151. this.reloadBrand()
  152. this.reloadList()
  153. this.reloadCrname()
  154. }
  155. },
  156. listenCrnameFilter: function (crnamearr) {
  157. this.nowPage = 1
  158. if (crnamearr.length === 0) {
  159. delete this.filter.goods_crname
  160. delete this.paramJSON.goods_crname
  161. this.reloadKind()
  162. this.reloadBrand()
  163. this.reloadList()
  164. this.reloadStoreType()
  165. } else {
  166. this.filter.goods_crname = crnamearr
  167. this.paramJSON.goods_crname = crnamearr
  168. this.reloadKind()
  169. this.reloadBrand()
  170. this.reloadList()
  171. this.reloadStoreType()
  172. }
  173. },
  174. listenCrnameFlag: function (obj) {
  175. if (obj.rmb_click_flag && obj.usd_click_flag) {
  176. this.crname_click_flag.rmb_click_flag = false
  177. this.crname_click_flag.usd_click_flag = false
  178. } else {
  179. this.crname_click_flag.rmb_click_flag = obj.rmb_click_flag
  180. this.crname_click_flag.usd_click_flag = obj.usd_click_flag
  181. }
  182. }
  183. }
  184. }
  185. </script>