NavCatHeader.vue 5.1 KB

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