Browse Source

精简搜索逻辑,接口数据调整

wangdy 8 years ago
parent
commit
d22240e2c5
2 changed files with 17 additions and 10 deletions
  1. 14 7
      components/search/GoodList.vue
  2. 3 3
      pages/search/_keyword.vue

+ 14 - 7
components/search/GoodList.vue

@@ -5,8 +5,8 @@
         <div class="fl">&nbsp;&nbsp;| 产品信息(<span class="text-num"></span><span class="text-num" v-text="good_list.total"></span>)</div>
         <div class="fr">
           <div @click="sortBy('normal1')" :class="activeTag==='normal1'?'active':''"><a >综合排序</a></div>
-          <div @click="sortBy('normal2')" :class="activeTag==='normal2'?'active':''"><a >现货优选</a></div>
-          <div @click="sortBy('type')" :class="activeTag==='type'?'active':''"><a >型号精确</a></div>
+          <div @click="sortBy('normal2')" :class="activeTag==='normal2'?'active':''"><a >现货优选<i class="fa fa-long-arrow-down" v-show="reserve_asc"></i><i class="fa fa-long-arrow-up" v-show="!reserve_asc"></i></a></div>
+          <!--<div @click="sortBy('type')" :class="activeTag==='type'?'active':''"><a >型号精确</a></div>-->
           <div style="display:none"><a href="">销量</a></div>
           <div style="display:none"><a href="">人气</a></div>
           <div style="display:none"><a href="">信用</a></div>
@@ -169,6 +169,7 @@
         pageSize: 15,
         sorting: {},
         price_asc: true,
+        reserve_asc: true,
         min_price: '',
         max_price: '',
         filter: {},
@@ -230,24 +231,30 @@
       },
       sortBy: function (param) {
         if (param === 'normal1') {
-          this.sorting = {'GO_SEARCH': 'DESC', 'GO_RESERVE': 'DESC'}
+          this.sorting = {}
           this.activeTag = 'normal1'
         } else if (param === 'normal2') {
-          this.sorting = {'GO_RESERVE': 'DESC', 'GO_SEARCH': 'DESC'}
+          if (this.reserve_asc) {
+            this.sorting = {'RESERVE': 'ASC'}
+          } else {
+            this.sorting = {'RESERVE': 'DESC'}
+          }
           this.activeTag = 'normal2'
+          this.reserve_asc = !this.reserve_asc
         } else if (param === 'type') {
-          this.sorting = {'GO_SEARCH': 'DESC', 'GO_RESERVE': 'DESC'}
+          this.sorting = {'RESERVE': 'DESC'}
           this.activeTag = 'type'
         } else if (param === 'price') {
           if (this.price_asc) {
-            this.sorting = {'GO_MINPRICERMB': 'ASC', 'GO_RESERVE': 'DESC', 'GO_SEARCH': 'DESC'}
+            this.sorting = {'PRICE': 'ASC'}
           } else {
-            this.sorting = {'GO_MINPRICERMB': 'DESC', 'GO_RESERVE': 'DESC', 'GO_SEARCH': 'DESC'}
+            this.sorting = {'PRICE': 'DESC'}
           }
           this.activeTag = 'price'
           this.price_asc = !this.price_asc
         }
         this.$emit('sortEvent', this.sorting)
+        this.nowPage = 1
       },
       filter_price: function () {
         if (this.min_price === '' && this.max_price !== '') {

+ 3 - 3
pages/search/_keyword.vue

@@ -25,7 +25,7 @@
         key: this.$route.query.w,
         pageSize: 15,
         nowPage: 1,
-        sorting: {'GO_RESERVE': 'DESC', 'GO_SEARCH': 'DESC'},
+        sorting: {},
         filter: {},
         paramJSON: {},
         crname_click_flag: {
@@ -38,7 +38,7 @@
       return Promise.all([
         store.dispatch('searchData/searchForKinds', {collectList: 'goods_kind', keyword: route.query.w, paramJSON: {}}),
         store.dispatch('searchData/searchForBrands', {collectList: 'goods_brand', keyword: route.query.w, paramJSON: {}}),
-        store.dispatch('searchData/searchForList', {count: 15, filter: {}, keyword: route.query.w, page: 1, sorting: {'GO_RESERVE': 'DESC', 'GO_SEARCH': 'DESC'}}),
+        store.dispatch('searchData/searchForList', {count: 15, filter: {}, keyword: route.query.w, page: 1, sorting: {}}),
         store.dispatch('searchData/searchForStoreType', {collectList: 'goods_store_type', keyword: route.query.w, paramJSON: {}}),
         store.dispatch('searchData/searchForCrname', {collectList: 'goods_crname', keyword: route.query.w, paramJSON: {}})
       ])
@@ -52,7 +52,7 @@
     methods: {
       reloadList: function () {
         if (this.sorting === {}) {
-          this.sorting = {'GO_RESERVE': 'DESC', 'GO_SEARCH': 'DESC'}
+          this.sorting = {}
         }
         this.$store.dispatch('searchData/searchForList', {count: this.pageSize, filter: this.filter, keyword: this.$route.query.w, page: this.nowPage, sorting: this.sorting})
       },