Nav.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <nav class="nav-list">
  3. <div class="container">
  4. <nuxt-link to="/product/kind/home" class="item item-first">
  5. <div>器件选型</div>
  6. </nuxt-link>
  7. <nuxt-link :to="'/'" class="item" exact>
  8. <span>首&nbsp;&nbsp;页</span>
  9. </nuxt-link>
  10. <nuxt-link to="/applyPurchase" class="item">
  11. <span>询价求购</span>
  12. <img class="new-animate" src="/images/all/banner-cuxiao03.png" alt="">
  13. </nuxt-link>
  14. <nuxt-link to="/supplier" class="item">
  15. <span>供应商</span>
  16. </nuxt-link>
  17. <a class="item expand-item" :class="{'active': isActive}">
  18. <span>{{name}}
  19. <i class="iconfont icon-arrow-down"></i>
  20. <i class="iconfont icon-arrow-up"></i>
  21. </span>
  22. <ul class="expand-list" v-if="isMounted">
  23. <nuxt-link to="/provider/factories" tag="li" v-show="name !== '原厂专区'">
  24. <!--<nuxt-link to="/provider/factories">原厂专区</nuxt-link>-->
  25. <span>原厂专区</span>
  26. </nuxt-link>
  27. <nuxt-link to="/provider/home" tag="li" v-show="name !== '代理经销'">
  28. <span>代理经销</span>
  29. </nuxt-link>
  30. <li @click="open('/store/33069557578d44e69bd91ad12d28a8d4')">
  31. <span>库存寄售</span>
  32. </li>
  33. </ul>
  34. </a>
  35. <nuxt-link to="/product/brand/brandList/ABC" class="item">
  36. <span>品牌墙</span>
  37. </nuxt-link>
  38. <nuxt-link to="/news" class="item">
  39. <span>优软快讯</span>
  40. </nuxt-link>
  41. </div>
  42. </nav>
  43. </template>
  44. <script>
  45. export default {
  46. name: 'navView',
  47. data () {
  48. return {
  49. isMounted: false
  50. }
  51. },
  52. mounted () {
  53. this.$nextTick(() => {
  54. this.isMounted = true
  55. })
  56. },
  57. computed: {
  58. name () {
  59. let path = this.$route.path
  60. if (path === '/provider/factories') {
  61. return '原厂专区'
  62. } else if (path === '/provider/home') {
  63. return '代理经销'
  64. } else {
  65. return '店 铺'
  66. }
  67. },
  68. isActive () {
  69. return (this.$route.path === '/provider/factories' && this.name === '原厂专区') || (this.$route.path === '/provider/home' && this.name === '代理经销')
  70. }
  71. },
  72. methods: {
  73. open (url) {
  74. window.open(url)
  75. }
  76. }
  77. }
  78. </script>
  79. <style lang="scss" scoped>
  80. @import '~assets/scss/variables';
  81. $nav-height: 40px;
  82. .nav-list a span{
  83. font-size: 14px;
  84. }
  85. .nav-list {
  86. background-color: rgb(244, 248, 255);
  87. height: $nav-height;
  88. .item {
  89. display: inline-block;
  90. height: $nav-height;
  91. line-height: $nav-height;
  92. width: 126px;
  93. text-align: center;
  94. margin: 0;
  95. vertical-align: middle;
  96. color: $black-light;
  97. > span {
  98. padding: 5px 2px;
  99. }
  100. &.nuxt-link-active, &.active, &:not(.expand-item):hover {
  101. > span {
  102. color: #5078cb;
  103. border-bottom: #5078cb 3px solid;
  104. font-weight: bold;
  105. }
  106. }
  107. &.expand-item {
  108. position: relative;
  109. .expand-list {
  110. z-index: 10;
  111. position: absolute;
  112. left: 8px;
  113. top: 40px;
  114. background: #fff;
  115. width: 106px;
  116. border-radius: 2px;
  117. display: none;
  118. -webkit-box-shadow: 0 1px 12px 0 rgba(0,0,0,.2);
  119. -moz-box-shadow: 0 1px 12px 0 rgba(0,0,0,.2);
  120. box-shadow: 0 1px 12px 0 rgba(0,0,0,.2);
  121. li {
  122. height: 34px;
  123. line-height: 34px;
  124. text-align: center;
  125. span {
  126. color: #666;
  127. }
  128. &:hover {
  129. background: #5078cb;
  130. span {
  131. color: #fff;
  132. }
  133. }
  134. }
  135. }
  136. .icon-arrow-up {
  137. display: none;
  138. }
  139. &:hover {
  140. color: #2147f9;
  141. .expand-list {
  142. display: block;
  143. }
  144. .icon-arrow-up {
  145. display: inline-block;
  146. }
  147. .icon-arrow-down {
  148. display: none;
  149. }
  150. }
  151. }
  152. &.item-first {
  153. width: 200px;
  154. margin: 0;
  155. background-color: rgb(33, 71, 151);
  156. font-size: 14px;
  157. font-weight: bold;
  158. text-align: center;
  159. color: #fff;
  160. cursor: pointer;
  161. }
  162. }
  163. }
  164. </style>