Forráskód Böngészése

搜索页面跳转功能

yangc 8 éve
szülő
commit
ee170dd41f

+ 2 - 1
components/common/page/pageComponent.vue

@@ -5,7 +5,8 @@
       :page-size="pageSize"
       layout="prev, pager, next, jumper"
       :total="total"
-      @current-change="handleCurrentChange">
+      @current-change="handleCurrentChange"
+      v-if="total/pageSize>=1">
     </el-pagination>
   </div>
 </template>

+ 3 - 1
components/home/floor/FloorBar.vue

@@ -30,8 +30,9 @@
         let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
         let floors = document.querySelectorAll('.floor')
         let barOffset = document.querySelector('.floor-bar').offsetTop
+        let barOffset2 = 0
         this.visible = (barOffset >= floors[0].offsetTop - scrolled &&
-          barOffset <= floors[floors.length - 1].offsetTop - scrolled + floors[floors.length - 1].clientHeight)
+          barOffset2 <= floors[floors.length - 1].offsetTop - scrolled + floors[floors.length - 1].clientHeight)
         if (this.visible) {
           for (let i = 0; i < floors.length; i++) {
             if (barOffset >= floors[i].offsetTop - scrolled + 60) {
@@ -39,6 +40,7 @@
             }
           }
         }
+        console.log(barOffset)
       },
       jumpFloor (index) {
         if (this.visible) {

+ 4 - 4
components/product/brand/BrandComponent.vue

@@ -59,17 +59,17 @@
     },
     computed: {
       lists () {
-        let components = this.$store.state.brandComponent.component
-        console.log(components)
         return this.$store.state.brandComponent.component
       },
       list () {
-        console.log(this.lists.data)
         return this.lists.data
+      },
+      totalCount () {
+        return this.list.totalElements
       }
     },
     methods: {
-      listenChild: function (parm) {
+      listenPage: function (parm) {
         this.$emit('childEvent', parm)
       }
     }

+ 29 - 17
components/search/GoodList.vue

@@ -46,8 +46,8 @@
             <th width="100">封装/生产日期</th>
             <th width="110">库存</th>
             <th width="90">阶梯</th>
-            <th width="90">香港交货</th>
-            <th width="110">大陆交货<span style="font-size: 12px;">(含税)</span></th>
+            <th width="90" v-if="!crname_click_flag.rmb_click_flag">香港交货</th>
+            <th width="110" v-if="!crname_click_flag.usd_click_flag">大陆交货<span style="font-size: 12px;">(含税)</span></th>
             <th width="110">货期<span style="font-size: 12px;">(工作日)</span></th>
             <th width="100">操作</th>
           </tr>
@@ -55,17 +55,18 @@
           <tbody id="productList-content">
           <tr v-for="item in good_list.components">
             <td>
-              <a href="">
-                <img width="80px" height="80px" :src="item.brand.logoUrl?item.brand.logoUrl:'http://static.usoftmall.com/img/all/default.png?_v=1499336134257'"></a>
+              <nuxt-link :to="`/product/component/${item.uuid}`">
+                <img width="80px" height="80px" :src="item.img?item.img:'http://static.usoftmall.com/img/all/default.png?_v=1499336134257'">
+              </nuxt-link>
             </td>
             <td class="brand-code">
-              <div class="brand"><a class="text-num" v-text="item.brand.nameEn"></a></div>
-              <div class="code"><a class="f16 text-bold text-num" v-text="item.code"></a></div>
+              <div class="brand"><nuxt-link :to="`/product/brand/${item.brand.uuid}`" class="text-num" v-text="item.brand.nameEn"></nuxt-link></div>
+              <div class="code"><nuxt-link :to="`/product/component/${item.uuid}`" class="f16 text-bold text-num" v-text="item.code"></nuxt-link></div>
             </td>
             <td>
               <div><i class="fa fa-th-large f14" aria-hidden="true"></i>&nbsp;&nbsp;
-                <a v-text="item.kind.nameCn">
-                </a>
+                <nuxt-link :to="`/product/kind/${item.kindid}`" v-text="item.kind.nameCn">
+                </nuxt-link>
               </div>
             </td>
             <td>
@@ -91,20 +92,20 @@
                 <span v-text="price.start"></span> +
               </div>
             </td>
-            <td >
-              <div >
+            <td v-if="!crname_click_flag.usd_click_flag">
+              <div v-show="!(item.currencyName == 'USD') || !item.prices">
                 <span>—</span>
               </div>
-              <div >
-                <span ></span>
+              <div v-for="price in item.prices">
+                <span>{{price.uSDPrice | currency}}</span>
               </div>
             </td>
-            <td >
-              <div >
+            <td v-if="!crname_click_flag.rmb_click_flag">
+              <div v-show="!(item.currencyName == 'RMB') || !item.prices">
                 <span>—</span>
               </div>
-              <div >
-                <span ></span>
+              <div v-for="price in item.prices">
+                <span>{{price.rMBPrice | currency}}</span>
               </div>
             </td>
             <td>
@@ -134,7 +135,7 @@
         </table>
       </div>
       <page :total="total_count" :page-size="pageSize"
-      :current="nowPage" v-on:childEvent="listenPage" v-show="good_list.components.length>0"></page>
+      :current="nowPage" v-on:childEvent="listenPage"></page>
     </div>
   </div>
 </template>
@@ -158,6 +159,17 @@
     components: {
       Page
     },
+    props: ['crname_click_flag'],
+    filters: {
+      currency: function (input) {
+        if (typeof input === 'number') {
+          if (input.toString().indexOf('.') === -1) {
+            input = input + '.00'
+          }
+        }
+        return input
+      }
+    },
     computed: {
       good_lists () {
         return this.$store.state.searchData.searchList.lists

+ 46 - 15
components/search/Kind.vue

@@ -10,7 +10,7 @@
           </div>
         </span>
         <ul :class="show_kind">
-          <li><a class="f14" >全部</a></li>
+          <li><a class="f14" @click="restore('kind')">全部</a></li>
           <li v-for="(item, index) in list_kind">
             <a v-text="item.ki_name_cn" class="f14" @click="click_kind(item.ki_id, index)"></a>
           </li>
@@ -35,7 +35,7 @@
           </div>
         </span>
         <ul :class="show_brand">
-          <li><a class="f14" >全部</a></li>
+          <li><a class="f14" @click="restore('brand')">全部</a></li>
           <li v-for="(item, index) in list_brand">
             <a v-text="item.br_name_cn" class="f14" @click="click_brand(item.br_id, index)"></a>
           </li>
@@ -54,7 +54,7 @@
       <div class="sl-key f14">货源:</div>
       <div class="sl-value">
         <ul class="list-inline" >
-          <li><a class="f14" >全部</a></li>
+          <li><a class="f14" @click="restore('store')">全部</a></li>
           <li>
             <div class="f14" style="color: #999;" v-if="!getType(list_store_type,store_type_co)&&!co_click_flag">寄售</div>
             <a class="f14" v-if="getType(list_store_type,store_type_co)&&!co_click_flag" @click="click_store_type('CONSIGNMENT')">寄售</a>
@@ -103,10 +103,10 @@
       <div class="sl-key f14">仓库:</div>
       <div class="sl-value">
         <ul class="list-inline"  >
-          <li><a class="f14">全部</a></li>
+          <li><a class="f14" @click="restore('crname')">全部</a></li>
           <li v-for="cr in list_crname_temp">
-            <a v-if="cr.cr_name=='RMB'?!rmb_click_flag:!usd_click_flag" v-text="cr.cr_name=='RMB'?'大陆':'香港'" class="f14" @click="click_crname(cr.cr_name)"></a>
-            <span v-if="cr.cr_name=='RMB'?rmb_click_flag:usd_click_flag" @click="cancel_crname(cr.cr_name)">
+            <a v-if="cr.cr_name=='RMB'?!crname_click_flag.rmb_click_flag:!crname_click_flag.usd_click_flag" v-text="cr.cr_name=='RMB'?'大陆':'香港'" class="f14" @click="click_crname(cr.cr_name)"></a>
+            <span v-if="cr.cr_name=='RMB'?crname_click_flag.rmb_click_flag:crname_click_flag.usd_click_flag" @click="cancel_crname(cr.cr_name)">
               <div class="sl-filter">
                 <a class="text-num" v-text="cr.cr_name=='RMB'?'大陆':'香港'"></a>
                 <span><i class="fa fa-close"></i></span>
@@ -120,10 +120,10 @@
       <div class="sl-key f14">货币:</div>
       <div class="sl-value">
         <ul class="list-inline"  >
-          <li><a class="f14">全部</a></li>
+          <li><a class="f14" @click="restore('crname')">全部</a></li>
           <li v-for="cr in list_crname_temp">
-            <a v-if="cr.cr_name=='RMB'?!rmb_click_flag:!usd_click_flag" v-text="cr.cr_name=='RMB'?'人民币':'美元'" class="f14" @click="click_crname(cr.cr_name)"></a>
-            <span v-if="cr.cr_name=='RMB'?rmb_click_flag:usd_click_flag" @click="cancel_crname(cr.cr_name)">
+            <a v-if="cr.cr_name=='RMB'?!crname_click_flag.rmb_click_flag:!crname_click_flag.usd_click_flag" v-text="cr.cr_name=='RMB'?'人民币':'美元'" class="f14" @click="click_crname(cr.cr_name)"></a>
+            <span v-if="cr.cr_name=='RMB'?crname_click_flag.rmb_click_flag:crname_click_flag.usd_click_flag" @click="cancel_crname(cr.cr_name)">
               <div class="sl-filter">
                 <a class="text-num" v-text="cr.cr_name=='RMB'?'人民币':'美元'"></a>
                 <span><i class="fa fa-close"></i></span>
@@ -159,8 +159,10 @@
         ag_click_flag: false,
         di_click_flag: false,
         or_click_flag: false,
-        rmb_click_flag: false,
-        usd_click_flag: false
+        crname_click_flag: {
+          rmb_click_flag: false,
+          usd_click_flag: false
+        }
       }
     },
     computed: {
@@ -268,11 +270,12 @@
           this.crname_arr.push('RMB-USD')
         }
         if (name === 'RMB') {
-          this.rmb_click_flag = true
+          this.crname_click_flag.rmb_click_flag = true
         } else if (name === 'USD') {
-          this.usd_click_flag = true
+          this.crname_click_flag.usd_click_flag = true
         }
         this.$emit('crnameFilterEvent', this.crname_arr)
+        this.$emit('crnameFlagEvent', this.crname_click_flag)
       },
       cancel_crname: function (name) {
         let idx = this.getIndex(this.crname_arr, name)
@@ -281,11 +284,12 @@
           this.crname_arr = []
         }
         if (name === 'RMB') {
-          this.rmb_click_flag = false
+          this.crname_click_flag.rmb_click_flag = false
         } else if (name === 'USD') {
-          this.usd_click_flag = false
+          this.crname_click_flag.usd_click_flag = false
         }
         this.$emit('crnameFilterEvent', this.crname_arr)
+        this.$emit('crnameFlagEvent', this.crname_click_flag)
       },
       click_kind_exp: function (id, index) {
         let idx = this.getIndex(this.kind_arr, id)
@@ -299,6 +303,33 @@
         this.$emit('brandFilterEvent', this.brand_arr)
         this.brand_exp_arr.splice(index, index + 1)
       },
+      restore: function (name) {
+        if (name === 'kind') {
+          this.list_kind.concat(this.kind_exp_arr)
+          this.kind_exp_arr = []
+          this.kind_arr = []
+          this.$emit('kindFilterEvent', this.kind_arr)
+        } else if (name === 'brand') {
+          this.list_brand.concat(this.brand_exp_arr)
+          this.brand_exp_arr = []
+          this.brand_arr = []
+          this.$emit('brandFilterEvent', this.brand_arr)
+        } else if (name === 'store') {
+          this.list_store_type.concat(this.type_arr)
+          this.type_arr = []
+          this.$emit('typeFilterEvent', this.type_arr)
+          this.co_click_flag = false
+          this.ag_click_flag = false
+          this.di_click_flag = false
+          this.or_click_flag = false
+        } else if (name === 'crname') {
+          this.list_crname.concat(this.crname_arr)
+          this.crname_arr = []
+          this.$emit('crnameFilterEvent', this.crname_arr)
+          this.rmb_click_flag = false
+          this.usd_click_flag = false
+        }
+      },
       getIndex: function (arr, obj) {
         for (let i = 0; i < arr.length; i++) {
           if (arr[i] === obj) {

+ 16 - 3
pages/search/_keyword.vue

@@ -5,8 +5,13 @@
           @brandFilterEvent="listenBrandFilter"
           @typeFilterEvent="listenTypeFilter"
           @crnameFilterEvent="listenCrnameFilter"
+          @crnameFlagEvent="listenCrnameFlag"
     ></kind>
-  <good-list @pageEvent="listenPage" @sortEvent="listenSort" @filterPriceEvent="listenPriceFilter"></good-list>
+  <good-list @pageEvent="listenPage"
+             @sortEvent="listenSort"
+             @filterPriceEvent="listenPriceFilter"
+             :crname_click_flag="crname_click_flag"
+  ></good-list>
 </div>
 </template>
 <script>
@@ -20,14 +25,18 @@
         nowPage: 1,
         sorting: {'GO_RESERVE': 'DESC', 'GO_SEARCH': 'DESC'},
         filter: {},
-        paramJSON: {}
+        paramJSON: {},
+        crname_click_flag: {
+          rmb_click_flag: false,
+          usd_click_flag: false
+        }
       }
     },
     fetch ({store, route}) {
       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: this.pageSize, filter: this.filter, keyword: route.query.w, page: this.nowPage, sorting: this.sorting}),
+        store.dispatch('searchData/searchForList', {count: 15, filter: {}, keyword: route.query.w, page: 1, sorting: {'GO_RESERVE': 'DESC', 'GO_SEARCH': 'DESC'}}),
         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: {}})
       ])
@@ -145,6 +154,10 @@
           this.reloadList()
           this.reloadStoreType()
         }
+      },
+      listenCrnameFlag: function (obj) {
+        this.crname_click_flag.rmb_click_flag = obj.rmb_click_flag
+        this.crname_click_flag.usd_click_flag = obj.usd_click_flag
       }
     }
   }

+ 1 - 1
store/index.js

@@ -217,7 +217,7 @@ export const actions = {
         commit('brandDetail/GET_DETAIL_SUCCESS', response.data)
         return Promise.all([
           loadBrandCategories({ commit }, {id: brand.id}),
-          loadBrandComponent({ commit }, {count: 10, filter: { brandid: brand.id }, page: 1})
+          loadBrandComponent({ commit }, {count: 10, filter: { brandid: brand.id }})
         ])
       }, err => {
         commit('brandDetail/GET_DETAIL_FAILURE', err)