Nav.vue 6.0 KB

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