Browse Source

器件选型移入

yangc 7 years ago
parent
commit
9423631684
2 changed files with 28 additions and 30 deletions
  1. 1 1
      components/main/Header.vue
  2. 27 29
      components/main/Nav.vue

+ 1 - 1
components/main/Header.vue

@@ -57,7 +57,7 @@
       position: fixed;
       width: 100%;
       background: #fff;
-      z-index: 1001;
+      z-index: 1002;
       top: 0;
       padding-top: 20px;
       -webkit-box-shadow: 0 2px 0 0 #ccc;

+ 27 - 29
components/main/Nav.vue

@@ -1,8 +1,10 @@
 <template>
   <nav class="nav-list">
     <div class="container">
-      <nuxt-link to="/product/kind/home" class="item item-first">
-        <div>器件选型</div>
+      <nuxt-link to="/product/kind/home" class="item item-first" tag="div">
+        <div>器件选型
+          <kind-category v-if="$route.path != '/'" @loadchild="loadProductKinds" id="kindCategory"></kind-category>
+        </div>
       </nuxt-link>
       <nuxt-link :to="'/'" class="item" exact>
         <span>首&nbsp;&nbsp;页</span>
@@ -49,37 +51,15 @@
   </nav>
 </template>
 <script>
+  import { KindCategory } from '~components/home'
   export default {
     name: 'navView',
-    data () {
-      return {
-        isMounted: false
-      }
-    },
-    mounted () {
-      this.$nextTick(() => {
-        this.isMounted = true
-      })
-    },
-    computed: {
-      name () {
-        let path = this.$route.path
-        if (path === '/provider/factories') {
-          return '原厂专区'
-        } else if (path === '/provider/home') {
-          return '代理经销'
-        } else {
-          return '店  铺'
-        }
-      },
-      isActive () {
-        return (this.$route.path === '/provider/factories' && this.name === '原厂专区') || (this.$route.path === '/provider/home' && this.name === '代理经销')
-      }
+    components: {
+      KindCategory
     },
     methods: {
-      open (url) {
-        window.open(url)
-//        this.$router.push(url)
+      loadProductKinds (id) {
+        this.$store.dispatch('loadAllProductKinds', {id})
       },
       goB2B () {
         if (this.user.logged) {
@@ -88,6 +68,9 @@
           this.login(`${process.env.uasUrl}`)
         }
       }
+    },
+    created () {
+      this.$store.dispatch('loadProductKinds', { id: 0 })
     }
   }
 </script>
@@ -169,6 +152,15 @@
         }
       }
 
+      #kindCategory {
+        display: none;
+        font-weight: normal;
+        text-align: left;
+        z-index: 1001;
+        top: 40px;
+        left: 0;
+      }
+
       &.item-first {
         width: 220px;
         margin: 0;
@@ -178,6 +170,12 @@
         text-align: center;
         color: #fff;
         cursor: pointer;
+        position: relative;
+        &:hover {
+          #kindCategory {
+            display: block;
+          }
+        }
       }
     }
   }