1.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <div>
  3. <div class="channelMenuTitle" v-if="componentStyle == 1 || componentStyle == 2 || componentStyle == 3">
  4. {{title}}
  5. </div>
  6. <!--样式1-->
  7. <div class="channelMenuList" v-if="componentStyle==1">
  8. <div v-for="item in navigateData">
  9. <NuxtLink :to="{path:`/${targetSegment}/${item.aLIas_pinyin}/list-1.html`}" :class="{active:targetSegment2 == item.aLIas_pinyin}">{{item.alias}}</NuxtLink>
  10. </div>
  11. </div>
  12. <!--样式2-->
  13. <div class="channelMenuList menuListStyle2" v-if="componentStyle==2">
  14. <div v-for="item in navigateData">
  15. <NuxtLink :to="{path:`/${targetSegment}/${item.aLIas_pinyin}/list-1.html`}" :class="{active:targetSegment2 == item.aLIas_pinyin}">{{item.alias}}</NuxtLink>
  16. </div>
  17. </div>
  18. <!-- 样式3 -->
  19. <div class="channelMenuList menuListStyle3" v-if="componentStyle == 3">
  20. <div v-for="item in navigateData">
  21. <NuxtLink :to="{path:`/${targetSegment}/${item.aLIas_pinyin}/list-1.html`}" :class="{active:targetSegment2 == item.aLIas_pinyin}">{{item.alias}}</NuxtLink>
  22. </div>
  23. </div>
  24. <!-- 样式4 -->
  25. <div class="channelMenuList menuListStyle4" v-if="componentStyle == 4">
  26. <div class="menuTitle">{{ title }}</div>
  27. <div class="menulist" v-for="item in navigateData">
  28. <NuxtLink :to="{path:`/${targetSegment}/${item.aLIas_pinyin}/list-1.html`}" :class="{active:targetSegment2 == item.aLIas_pinyin}">
  29. <span class="title">{{item.alias}}</span>
  30. <span class="line" v-if="item.alias != navigateData[navigateData.length - 1].alias">/</span>
  31. </NuxtLink>
  32. </div>
  33. </div>
  34. <!-- 样式5 -->
  35. <div class="channelMenuList menuListStyle4 menuListStyle5" v-if="componentStyle == 5">
  36. <div class="menuTitle">{{ title }}</div>
  37. <div class="menulist" v-for="item in navigateData">
  38. <NuxtLink :to="{path:`/${targetSegment}/${item.aLIas_pinyin}/list-1.html`}" :class="{active:targetSegment2 == item.aLIas_pinyin}">
  39. <span class="title">{{item.alias}}</span>
  40. <span class="line" v-if="item.alias != navigateData[navigateData.length - 1].alias">/</span>
  41. </NuxtLink>
  42. </div>
  43. </div>
  44. <!-- 样式6 -->
  45. <div class="channelMenuList menuListStyle4 menuListStyle6" v-if="componentStyle == 6">
  46. <div class="menuTitle">{{ title }}</div>
  47. <div class="menulist" v-for="item in navigateData">
  48. <NuxtLink :to="{path:`/${targetSegment}/${item.aLIas_pinyin}/list-1.html`}" :class="{active:targetSegment2 == item.aLIas_pinyin}">
  49. <span class="title">{{item.alias}}</span>
  50. <span class="line" v-if="item.alias != navigateData[navigateData.length - 1].alias">/</span>
  51. </NuxtLink>
  52. </div>
  53. </div>
  54. </div>
  55. </template>
  56. <script setup>
  57. //引入vue
  58. import {ref} from 'vue';
  59. //获得新闻数据
  60. const props = defineProps({
  61. componentStyle:Number,//样式编号
  62. navigateData:Array,//子导航数据
  63. routeId:Number//导航对应的cid
  64. });
  65. //获得导航名称
  66. const title = ref("")
  67. const mkdata = await requestDataPromise('/web/getOneWebsiteCategory', {
  68. method: 'GET',
  69. query: {
  70. 'catid': props.routeId,
  71. },
  72. });
  73. if (mkdata.code == 200) {
  74. title.value = mkdata.data.parent_name;
  75. }
  76. //获取当前url路径
  77. const route = useRoute();
  78. //获得当前的完整路径
  79. const fullPath = route.path;
  80. const segments = fullPath.split('/');
  81. const targetSegment = segments[1];
  82. const targetSegment2 = segments[2];
  83. //判断当前为第几层的列表页
  84. // const routeLevel = ref(0);
  85. // if(route.name == "dir-list-id"){
  86. // routeLevel.value = 1;
  87. // console.log("当前的路由层级为:" + routeLevel.value);
  88. // }
  89. // if(route.name == "dir-dir-list-id"){
  90. // routeLevel.value = 2;
  91. // console.log("当前的路由层级为:" + routeLevel.value);
  92. // }
  93. </script>
  94. <style lang="less" scoped>
  95. //基本样式 start ---------------------------------------->
  96. .channelMenuTitle {
  97. width: 1200px;
  98. height: 32px;
  99. line-height: 32px;
  100. font-size: 24px;
  101. color:#1C5468;
  102. font-weight: bold;
  103. text-align: center;
  104. background: url('http://img.bjzxtw.org.cn/pre/image/jpeg/20250620/1750381219965589.jpg') no-repeat center center;
  105. margin-bottom: 25px;
  106. }
  107. .channelMenuList {
  108. display: flex;
  109. justify-content: flex-start;
  110. align-items: center;
  111. color: #333;
  112. border-bottom: 2px solid #004564;
  113. padding-bottom: 15px;
  114. div {
  115. font-size: 16px;
  116. font-weight: bold;
  117. width: 150px;
  118. height: 22px;
  119. line-height: 22px;
  120. a {
  121. color: #333;
  122. display: block;
  123. text-align: center;
  124. &:hover {
  125. color: #004564;
  126. }
  127. }
  128. a.active {
  129. color: #004564;
  130. }
  131. &:first-child {
  132. color: #004564;
  133. }
  134. }
  135. }
  136. //基本样式 end ---------------------------------------->
  137. //样式2 start ---------------------------------------->
  138. .menuListStyle2 {
  139. border-bottom: 0;
  140. }
  141. //样式2 end ---------------------------------------->
  142. //样式3
  143. .menuListStyle3 {
  144. border-bottom: 0;
  145. div{
  146. text-align: center;
  147. height: 36px;
  148. &:hover {
  149. color: #1c5468;
  150. padding-bottom: 15px;
  151. border-bottom: 2px solid #004564;
  152. box-sizing: border-box;
  153. }
  154. }
  155. }
  156. //样式4
  157. .menuListStyle4 {
  158. height: 54px;
  159. padding-top: 23px;
  160. padding-bottom: 0px;
  161. .menuTitle {
  162. width: 140px;
  163. font-size: 26px;
  164. font-weight: bold;
  165. color: #1c5468;
  166. margin-right: 80px;
  167. }
  168. .menulist {
  169. display: flex;
  170. justify-content: flex-start;
  171. align-items: center;
  172. font-size: 16px;
  173. font-weight: bold;
  174. color: #333;
  175. padding: 15px 0;
  176. a{
  177. display: flex;
  178. justify-content: flex-start;
  179. align-items: center;
  180. .title{
  181. width: 120px;
  182. height: 16px;
  183. text-align: center;
  184. &:hover{
  185. color: #1c5468;
  186. }
  187. }
  188. .line{
  189. color: #1c5468;
  190. padding-top: 5px;
  191. }
  192. }
  193. }
  194. }
  195. //样式5
  196. .menuListStyle5 {
  197. border-bottom: none;
  198. }
  199. //样式6
  200. .menuListStyle6 {
  201. border-bottom: none;
  202. position: relative;
  203. }
  204. .menuListStyle6::after {
  205. content: '';
  206. position: absolute;
  207. bottom: -2px;
  208. left: 0;
  209. width: 8%;
  210. height: 2px;
  211. background-color: #004564;
  212. }
  213. </style>