NavCatHeader.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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. window.open(val.link_value, "_blank");
  67. } else if (val.link_type == "goods") {
  68. //跳转商品详情页
  69. // let routeUrl = router.resolve({
  70. // path: "/goods/detail",
  71. // query: {
  72. // productId: val.info.defaultProductId,
  73. // },
  74. // });
  75. let href = "/goods/detail/"+ calcProductName(val.info.goodsName) +'_'+ val.info.defaultProductId
  76. window.open(href, "_blank");
  77. } else if (val.link_type == "category") {
  78. // 分类列表
  79. let routeUrl = router.resolve({
  80. // path: "/goods/list",
  81. path:'/goods/list/_v-'+val.info.categoryId + '_gid-1_pid-0',
  82. // query: {
  83. // categoryId: val.info.categoryId,
  84. // },
  85. });
  86. window.open(routeUrl.href, "_blank");
  87. } else if (val.link_type == "keyword") {
  88. // 关键词
  89. let query = {
  90. keyword: val.link_value,
  91. };
  92. if (val.storeId) {
  93. query.storeId = val.storeId;
  94. }
  95. let routeUrl = router.resolve({
  96. path: "/goods/list",
  97. query,
  98. });
  99. window.open(routeUrl.href, "_blank");
  100. } else if (val.link_type == "topic") {
  101. //跳转专题页
  102. let routeUrl = router.resolve({
  103. path: "/home/topic",
  104. query: {
  105. topicId: val.info.decoId,
  106. },
  107. });
  108. window.open(routeUrl.href, "_blank");
  109. } else if (val.link_type == "brand_home") {
  110. //品牌列表
  111. let routeUrl = router.resolve({
  112. path: "/brand",
  113. query: {},
  114. });
  115. window.open(routeUrl.href, "_blank");
  116. } else if (val.link_type == "store_list") {
  117. //店铺列表
  118. let routeUrl = router.resolve({
  119. path: "/store/list/current-1",
  120. });
  121. window.open(routeUrl.href, "_blank");
  122. } else if (val.link_type == "voucher_center") {
  123. //领券中心
  124. let routeUrl = router.resolve({
  125. path: "/coupon",
  126. });
  127. window.open(routeUrl.href, "_blank");
  128. } else if (val.link_type == "point_center") {
  129. let routeUrl = router.resolve({
  130. path: "/point/index",
  131. });
  132. window.open(routeUrl.href, "_blank");
  133. }
  134. };
  135. onMounted(() => {
  136. let path = route.path;
  137. if (path == "/") {
  138. showIndex.value = false;
  139. }
  140. });
  141. </script>
  142. <style lang="scss" scoped>
  143. $colorMain: #e2231a !default; //主色、文字选中、搜索
  144. .header {
  145. width: 100%;
  146. height: 45px;
  147. margin: 0 auto;
  148. display: flex;
  149. justify-content: center;
  150. overflow: visible;
  151. position: relative;
  152. .product_sort {
  153. position: relative;
  154. overflow: visible;
  155. flex:0 0 250px;
  156. height: 100%;
  157. background: #fff;
  158. letter-spacing: 0px;
  159. line-height: 30px;
  160. display: flex;
  161. align-items: center;
  162. flex-wrap: wrap;
  163. justify-content: center;
  164. cursor: pointer;
  165. box-sizing: border-box;
  166. z-index:888;
  167. a{
  168. font-weight: bold;
  169. font-size: 16px;
  170. color: #282E30;
  171. }
  172. .category_sort {
  173. position: absolute;
  174. top: 40px;
  175. display: none;
  176. }
  177. &:hover {
  178. background: #F6F8FA;
  179. .category_sort {
  180. display: block;
  181. }
  182. }
  183. img {
  184. width: 12px;
  185. height: 12px;
  186. margin-right: 7px;
  187. }
  188. }
  189. nav {
  190. width: 1013px;
  191. display: flex;
  192. align-items: center;
  193. line-height: 30px;
  194. overflow: hidden;
  195. flex-wrap: wrap;
  196. a {
  197. height: 45px;
  198. display: inline-block;
  199. -webkit-box-sizing: border-box;
  200. box-sizing: border-box;
  201. font-weight: bold;
  202. font-size: 16px;
  203. color: #282E30;
  204. margin: 0 0 0 10px;
  205. line-height: 45px;
  206. padding: 0 3px;
  207. width: max-content;
  208. }
  209. a:hover {
  210. color: $colorMain;
  211. border-bottom: 3px solid $colorMain;
  212. }
  213. }
  214. }
  215. </style>