Nav.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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/bussiness.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="{active: baseUtils.startWith($route.path, '/eCommerce/home')}" 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. <a class="item" href="https://zb.usoftchina.com/" target="_blank">
  48. <span>闯客网</span>
  49. </a>
  50. <a class="item" href="https://bbs.usoftchina.com/" target="_blank">
  51. <span>U客论坛</span>
  52. </a>
  53. <nuxt-link to="/news" class="item">
  54. <span>优软快讯</span>
  55. </nuxt-link>
  56. </div>
  57. </nav>
  58. </template>
  59. <script>
  60. import { KindCategory } from '~components/home'
  61. export default {
  62. name: 'navView',
  63. data () {
  64. return {
  65. pcbId: process.env.pcbId,
  66. isChange: false
  67. }
  68. },
  69. components: {
  70. KindCategory
  71. },
  72. watch: {
  73. '$route.path': {
  74. handler: function (path) {
  75. if (path !== '/') {
  76. this.isChange = true
  77. // 直接设为false无作用,因此采用定时器
  78. setTimeout(() => {
  79. this.isChange = false
  80. }, 100)
  81. }
  82. }
  83. }
  84. },
  85. // '$route.params': {
  86. // handler: function (path) {
  87. // console.log(123)
  88. // this.isChange = true
  89. // }
  90. // }
  91. // },
  92. methods: {
  93. loadProductKinds (id) {
  94. this.$store.dispatch('loadAllProductKinds', {id})
  95. },
  96. goB2B () {
  97. if (this.user.logged) {
  98. window.location.href = `${process.env.uasUrl}#/index`
  99. } else {
  100. this.login(`${process.env.uasUrl}`)
  101. }
  102. }
  103. },
  104. created () {
  105. this.$store.dispatch('loadProductKinds', { id: 0 })
  106. }
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. @import '~assets/scss/variables';
  111. $nav-height: 40px;
  112. .nav-list a span{
  113. font-size: 14px;
  114. }
  115. .nav-list {
  116. background-color: rgb(244, 248, 255);
  117. height: $nav-height;
  118. .item {
  119. display: inline-block;
  120. height: $nav-height;
  121. line-height: $nav-height;
  122. width: 121px;
  123. text-align: center;
  124. margin: 0;
  125. vertical-align: middle;
  126. color: $black-light;
  127. > span {
  128. padding: 5px 2px;
  129. }
  130. &.nuxt-link-active, &.active, &:not(.expand-item):hover {
  131. > span {
  132. color: #5078cb;
  133. border-bottom: #5078cb 3px solid;
  134. font-weight: bold;
  135. }
  136. }
  137. &.expand-item {
  138. position: relative;
  139. .expand-list {
  140. z-index: 10;
  141. position: absolute;
  142. left: 8px;
  143. top: 40px;
  144. background: #fff;
  145. width: 106px;
  146. border-radius: 2px;
  147. display: none;
  148. -webkit-box-shadow: 0 1px 12px 0 rgba(0,0,0,.2);
  149. -moz-box-shadow: 0 1px 12px 0 rgba(0,0,0,.2);
  150. box-shadow: 0 1px 12px 0 rgba(0,0,0,.2);
  151. li {
  152. height: 34px;
  153. line-height: 34px;
  154. text-align: center;
  155. span {
  156. color: #666;
  157. }
  158. &:hover {
  159. background: #5078cb;
  160. span {
  161. color: #fff;
  162. }
  163. }
  164. }
  165. }
  166. .icon-arrow-up {
  167. display: none;
  168. }
  169. &:hover {
  170. color: #2147f9;
  171. .expand-list {
  172. display: block;
  173. }
  174. .icon-arrow-up {
  175. display: inline-block;
  176. }
  177. .icon-arrow-down {
  178. display: none;
  179. }
  180. }
  181. }
  182. #kindCategory {
  183. display: none;
  184. font-weight: normal;
  185. text-align: left;
  186. z-index: 1001;
  187. top: 40px;
  188. left: 0;
  189. }
  190. &.item-first {
  191. width: 220px;
  192. margin: 0;
  193. background-color: rgb(33, 71, 151);
  194. font-size: 14px;
  195. font-weight: bold;
  196. text-align: center;
  197. color: #fff;
  198. cursor: pointer;
  199. position: relative;
  200. &:hover {
  201. #kindCategory {
  202. display: block;
  203. }
  204. }
  205. }
  206. #kindCategory.change {
  207. display: none !important;
  208. }
  209. }
  210. }
  211. </style>