Nav.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <nav class="nav-list">
  3. <div class="container">
  4. <nuxt-link to="/product/kind/home" class="item item-first" tag="div">
  5. <div>器件选型
  6. <kind-category v-if="$route.path != '/'" :class="{'change': isChange}" @loadchild="loadProductKinds" id="kindCategory"></kind-category>
  7. </div>
  8. </nuxt-link>
  9. <nuxt-link :to="'/'" class="item" exact>
  10. <span>首&nbsp;&nbsp;页</span>
  11. </nuxt-link>
  12. <nuxt-link to="/applyPurchase" class="item">
  13. <span>询价求购</span>
  14. <img class="new-animate" src="/images/all/banner-cuxiao03.png" alt="">
  15. </nuxt-link>
  16. <!--<nuxt-link to="/supplier" class="item" v-if="!isInFrame">-->
  17. <!--<span>供应商</span>-->
  18. <!--</nuxt-link>-->
  19. <a class="item" @click="goB2B">
  20. <span>B2B商务</span>
  21. <img class="new-animate" src="/images/all/hot.png" alt="">
  22. </a>
  23. <nuxt-link to="/eCommerce/home/factory" class="item">
  24. <span>电商
  25. <!--<i class="iconfont icon-arrow-down"></i>-->
  26. <!--<i class="iconfont icon-arrow-up"></i>-->
  27. </span>
  28. <!--<ul class="expand-list" v-if="isMounted">-->
  29. <!--<nuxt-link to="/provider/factories" tag="li" v-show="name !== '原厂专区'">-->
  30. <!--&lt;!&ndash;<nuxt-link to="/provider/factories">原厂专区</nuxt-link>&ndash;&gt;-->
  31. <!--<span>原厂专区</span>-->
  32. <!--</nuxt-link>-->
  33. <!--<nuxt-link to="/provider/home" tag="li" v-show="name !== '代理经销'">-->
  34. <!--<span>代理经销</span>-->
  35. <!--</nuxt-link>-->
  36. <!--<li @click="open('/store/33069557578d44e69bd91ad12d28a8d4')">-->
  37. <!--<span>优软寄售</span>-->
  38. <!--</li>-->
  39. <!--</ul>-->
  40. </nuxt-link>
  41. <!--<nuxt-link to="/product/brand/brandList/A" class="item">-->
  42. <!--<span>品牌墙</span>-->
  43. <!--</nuxt-link>-->
  44. <nuxt-link to="/pcb" class="item">
  45. <span>PCB专区</span>
  46. </nuxt-link>
  47. <nuxt-link to="/news" class="item">
  48. <span>优软快讯</span>
  49. </nuxt-link>
  50. </div>
  51. </nav>
  52. </template>
  53. <script>
  54. import { KindCategory } from '~components/home'
  55. export default {
  56. name: 'navView',
  57. data () {
  58. return {
  59. pcbId: process.env.pcbId,
  60. isChange: false
  61. }
  62. },
  63. components: {
  64. KindCategory
  65. },
  66. watch: {
  67. '$route.path': {
  68. handler: function (path) {
  69. if (path !== '/') {
  70. this.isChange = true
  71. // 直接设为false无作用,因此采用定时器
  72. setTimeout(() => {
  73. this.isChange = false
  74. }, 100)
  75. }
  76. }
  77. }
  78. },
  79. // '$route.params': {
  80. // handler: function (path) {
  81. // console.log(123)
  82. // this.isChange = true
  83. // }
  84. // }
  85. // },
  86. methods: {
  87. loadProductKinds (id) {
  88. this.$store.dispatch('loadAllProductKinds', {id})
  89. },
  90. goB2B () {
  91. if (this.user.logged) {
  92. window.location.href = `${process.env.uasUrl}#/index`
  93. } else {
  94. this.login(`${process.env.uasUrl}`)
  95. }
  96. }
  97. },
  98. created () {
  99. this.$store.dispatch('loadProductKinds', { id: 0 })
  100. }
  101. }
  102. </script>
  103. <style lang="scss" scoped>
  104. @import '~assets/scss/variables';
  105. $nav-height: 40px;
  106. .nav-list a span{
  107. font-size: 14px;
  108. }
  109. .nav-list {
  110. background-color: rgb(244, 248, 255);
  111. height: $nav-height;
  112. .item {
  113. display: inline-block;
  114. height: $nav-height;
  115. line-height: $nav-height;
  116. width: 121px;
  117. text-align: center;
  118. margin: 0;
  119. vertical-align: middle;
  120. color: $black-light;
  121. > span {
  122. padding: 5px 2px;
  123. }
  124. &.nuxt-link-active, &.active, &:not(.expand-item):hover {
  125. > span {
  126. color: #5078cb;
  127. border-bottom: #5078cb 3px solid;
  128. font-weight: bold;
  129. }
  130. }
  131. &.expand-item {
  132. position: relative;
  133. .expand-list {
  134. z-index: 10;
  135. position: absolute;
  136. left: 8px;
  137. top: 40px;
  138. background: #fff;
  139. width: 106px;
  140. border-radius: 2px;
  141. display: none;
  142. -webkit-box-shadow: 0 1px 12px 0 rgba(0,0,0,.2);
  143. -moz-box-shadow: 0 1px 12px 0 rgba(0,0,0,.2);
  144. box-shadow: 0 1px 12px 0 rgba(0,0,0,.2);
  145. li {
  146. height: 34px;
  147. line-height: 34px;
  148. text-align: center;
  149. span {
  150. color: #666;
  151. }
  152. &:hover {
  153. background: #5078cb;
  154. span {
  155. color: #fff;
  156. }
  157. }
  158. }
  159. }
  160. .icon-arrow-up {
  161. display: none;
  162. }
  163. &:hover {
  164. color: #2147f9;
  165. .expand-list {
  166. display: block;
  167. }
  168. .icon-arrow-up {
  169. display: inline-block;
  170. }
  171. .icon-arrow-down {
  172. display: none;
  173. }
  174. }
  175. }
  176. #kindCategory {
  177. display: none;
  178. font-weight: normal;
  179. text-align: left;
  180. z-index: 1001;
  181. top: 40px;
  182. left: 0;
  183. }
  184. &.item-first {
  185. width: 220px;
  186. margin: 0;
  187. background-color: rgb(33, 71, 151);
  188. font-size: 14px;
  189. font-weight: bold;
  190. text-align: center;
  191. color: #fff;
  192. cursor: pointer;
  193. position: relative;
  194. &:hover {
  195. #kindCategory {
  196. display: block;
  197. }
  198. }
  199. }
  200. #kindCategory.change {
  201. display: none !important;
  202. }
  203. }
  204. }
  205. </style>