NavCatHeader.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <div class="nav_cat">
  3. <div class="header">
  4. <div class="product_sort" >
  5. <!-- <img :src="sortUrl" alt /> -->
  6. <nuxt-link to="/goods/Category" target="_blank" class="sort">
  7. <span >{{L['产品分类']}}</span>
  8. </nuxt-link>
  9. <div class="category_sort">
  10. <CategorySortTop />
  11. </div>
  12. </div>
  13. <nav>
  14. <li v-if="showIndex">
  15. <nuxt-link to="/" target="_blank">{{L['首页']}}</nuxt-link>
  16. </li>
  17. <li v-for="(item, index) in navList.data" :key="index">
  18. <a href="javascript:void(0)" @click="navClick(item)">{{
  19. item.navName
  20. }}</a>
  21. </li>
  22. </nav>
  23. </div>
  24. </div>
  25. </template>
  26. <script setup>
  27. import { getCurLanguage } from '@/composables/common.js';
  28. import { ElPopover,ElButton } from 'element-plus';
  29. // const L = lang_zn;
  30. const L = getCurLanguage();
  31. const router = useRouter();
  32. const route = useRoute();
  33. const showIndex = ref(true);
  34. const navList = reactive({ data: [] });
  35. const sortUrl = ref("/header/sort.png");
  36. const showTopMenu = ref(false)
  37. //展示一级全部菜单
  38. const showMenu = () => {
  39. showTopMenu.value = true
  40. }
  41. const hideMenu = () => {
  42. setTimeout(() => {
  43. showTopMenu.value = false
  44. }, 1000)
  45. }
  46. const toGoodsList = () => {
  47. navigateTo({ path: "/goods/Category" });
  48. };
  49. const getNavData = async () => {
  50. const { data: value } = await useFetchRaw(
  51. apiUrl + "v3/system/front/navigation/list"
  52. );
  53. const res = value._rawValue;
  54. if (res.state == 200) {
  55. navList.data = res.data;
  56. }
  57. };
  58. getNavData();
  59. const navClick = (val) => {
  60. val = JSON.parse(val.data.replace(/&quot;/g, '"'));
  61. if (val.link_type == "url") {
  62. //跳转链接地址
  63. if (val.link_value) {
  64. val.link_value = quillEscapeToHtml(val.link_value);
  65. }
  66. router.push(val.link_value)
  67. // router.resolve({
  68. // path: val.link_value
  69. // })
  70. // window.open(val.link_value, "_blank");
  71. } else if (val.link_type == "goods") {
  72. //跳转商品详情页
  73. // let routeUrl = router.resolve({
  74. // path: "/goods/detail",
  75. // query: {
  76. // productId: val.info.defaultProductId,
  77. // },
  78. // });
  79. let href = "/goods/detail/"+ calcProductName(val.info.goodsName) +'_'+ val.info.defaultProductId
  80. // router.push(href)
  81. window.open(href, "_blank");
  82. } else if (val.link_type == "category") {
  83. // 分类列表
  84. let routeUrl = router.resolve({
  85. // path: "/goods/list",
  86. path:'/goods/list/_v-'+val.info.categoryId + '_gid-1_pid-0',
  87. // query: {
  88. // categoryId: val.info.categoryId,
  89. // },
  90. });
  91. window.open(routeUrl.href, "_blank");
  92. } else if (val.link_type == "keyword") {
  93. // 关键词
  94. let query = {
  95. keyword: val.link_value,
  96. };
  97. if (val.storeId) {
  98. query.storeId = val.storeId;
  99. }
  100. let routeUrl = router.resolve({
  101. path: "/goods/list",
  102. query,
  103. });
  104. window.open(routeUrl.href, "_blank");
  105. } else if (val.link_type == "topic") {
  106. //跳转专题页
  107. let routeUrl = router.resolve({
  108. path: "/home/topic",
  109. query: {
  110. topicId: val.info.decoId,
  111. },
  112. });
  113. window.open(routeUrl.href, "_blank");
  114. } else if (val.link_type == "brand_home") {
  115. //品牌列表
  116. let routeUrl = router.resolve({
  117. path: "/brand",
  118. query: {},
  119. });
  120. window.open(routeUrl.href, "_blank");
  121. } else if (val.link_type == "store_list") {
  122. //店铺列表
  123. let routeUrl = router.resolve({
  124. path: "/store/list/current-1",
  125. });
  126. window.open(routeUrl.href, "_blank");
  127. } else if (val.link_type == "voucher_center") {
  128. //领券中心
  129. let routeUrl = router.resolve({
  130. path: "/coupon",
  131. });
  132. window.open(routeUrl.href, "_blank");
  133. } else if (val.link_type == "point_center") {
  134. let routeUrl = router.resolve({
  135. path: "/point/index",
  136. });
  137. window.open(routeUrl.href, "_blank");
  138. }
  139. };
  140. onMounted(() => {
  141. let path = route.path;
  142. if (path == "/") {
  143. showIndex.value = false;
  144. }
  145. });
  146. </script>
  147. <style lang="scss" scoped>
  148. $colorMain: #e2231a !default; //主色、文字选中、搜索
  149. .header {
  150. width: 100%;
  151. height: 45px;
  152. margin: 0 auto;
  153. display: flex;
  154. justify-content: center;
  155. overflow: visible;
  156. position: relative;
  157. padding-left: 40px;
  158. .product_sort {
  159. position: relative;
  160. overflow: visible;
  161. flex:0 0 250px;
  162. height: 100%;
  163. // background: #fff;
  164. letter-spacing: 0px;
  165. line-height: 30px;
  166. display: flex;
  167. align-items: center;
  168. flex-wrap: wrap;
  169. justify-content: center;
  170. cursor: pointer;
  171. box-sizing: border-box;
  172. z-index:888;
  173. a{
  174. font-weight: bold;
  175. font-size: 14px;
  176. color: #282E30;
  177. }
  178. .category_sort {
  179. position: absolute;
  180. top: 40px;
  181. display: none;
  182. }
  183. &:hover {
  184. background: #F6F8FA;
  185. .category_sort {
  186. display: block;
  187. }
  188. }
  189. img {
  190. width: 12px;
  191. height: 12px;
  192. margin-right: 7px;
  193. }
  194. }
  195. nav {
  196. width: 1013px;
  197. display: flex;
  198. align-items: center;
  199. line-height: 30px;
  200. overflow: hidden;
  201. flex-wrap: wrap;
  202. a {
  203. height: 45px;
  204. display: inline-block;
  205. -webkit-box-sizing: border-box;
  206. box-sizing: border-box;
  207. font-weight: bold;
  208. font-size: 14px;
  209. color: #282E30;
  210. margin: 0 0 0 10px;
  211. line-height: 45px;
  212. padding: 0 3px;
  213. width: max-content;
  214. }
  215. a:hover {
  216. color: $colorMain;
  217. border-bottom: 3px solid $colorMain;
  218. }
  219. }
  220. }
  221. </style>