Nav.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. top: 40px;
  108. background: #fff;
  109. width: 106px;
  110. border-radius: 2px;
  111. display: none;
  112. -webkit-box-shadow: 0 1px 12px 0 rgba(0,0,0,.2);
  113. -moz-box-shadow: 0 1px 12px 0 rgba(0,0,0,.2);
  114. box-shadow: 0 1px 12px 0 rgba(0,0,0,.2);
  115. li {
  116. height: 34px;
  117. line-height: 34px;
  118. text-align: center;
  119. a {
  120. color: #666;
  121. }
  122. &:hover {
  123. background: #5078cb;
  124. a {
  125. color: #fff;
  126. }
  127. }
  128. }
  129. }
  130. .icon-arrow-up {
  131. display: none;
  132. }
  133. &:hover {
  134. color: #2147f9;
  135. .expand-list {
  136. display: block;
  137. }
  138. .icon-arrow-up {
  139. display: inline-block;
  140. }
  141. .icon-arrow-down {
  142. display: none;
  143. }
  144. }
  145. }
  146. &.item-first {
  147. width: 200px;
  148. margin: 0;
  149. background-color: rgb(33, 71, 151);
  150. font-size: 14px;
  151. font-weight: bold;
  152. text-align: center;
  153. color: #fff;
  154. cursor: pointer;
  155. }
  156. }
  157. }
  158. </style>