Nav.vue 4.2 KB

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