SecondaryHeading.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <div class="sannongzhichuang">
  3. <div class="inner">
  4. <h2>
  5. {{ title }}
  6. <em class="iconfont icon-xingzhuang-zhijiaosanjiaoxing-copy"></em>
  7. </h2>
  8. <div class="introduction">
  9. <strong>频道介绍</strong>
  10. <div v-for="(item,index) in titleData">
  11. <span v-if="index<=7">
  12. <NuxtLink :to="{ path: `/newsList/${item.cid}`,query:{page:1} }">{{item.alias}}</NuxtLink>
  13. </span>
  14. <b v-else></b>
  15. </div>
  16. </div>
  17. </div>
  18. </div>
  19. </template>
  20. <script setup>
  21. //设置组件数据 start---------------------------------------->
  22. //子导航
  23. const props = defineProps({
  24. titleData:Array
  25. });
  26. //设置组件数据 end---------------------------------------->
  27. //1.获得路由id start ---------------------------------------->
  28. const route = useRoute();
  29. //获得当前的完整路径
  30. const fullPath = route.path;
  31. //拆分,取出来中间这一段,然后提取数字部分
  32. const segments = fullPath.split('/');
  33. const targetSegment = segments[2];
  34. const numberPart = targetSegment.match(/\d+$/)?.[0];
  35. //路由id
  36. //let routeId = 11 //排除路径错误可以打开这个
  37. let routeId = numberPart;
  38. //1.获得路由id end ---------------------------------------->
  39. //2.设置组件标题 start ---------------------------------------->
  40. const title = ref("")
  41. async function getPageData() {
  42. const mkdata = await requestDataPromise('/web/getOneWebsiteCategory', {
  43. method: 'GET',
  44. query: {
  45. 'catid': routeId,
  46. },
  47. });
  48. if(mkdata.code == 200){
  49. title.value = mkdata.data.alias;
  50. }else{
  51. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  52. console.log("错误位置:获取二级标题")
  53. console.log("后端错误反馈:",mkdata.message)
  54. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  55. }
  56. }
  57. getPageData();
  58. //2.设置组件标题 end ---------------------------------------->
  59. </script>
  60. <style lang="less" scoped>
  61. // 三农之窗
  62. .sannongzhichuang {
  63. margin: 30px 0 40px;
  64. .inner {
  65. width: 1200px;
  66. height: 67px;
  67. position: relative;
  68. }
  69. h2 {
  70. display: inline-block;
  71. //background-image: url("../../public/image/bg1.png");
  72. background: #139602;
  73. width: 156px;
  74. height: 43px;
  75. padding: 14px 31px 10px 25px;
  76. font-family: STXingkai, STXingkai;
  77. font-weight: 400;
  78. font-size: 39px;
  79. color: #FFFFFF;
  80. line-height: 46px;
  81. text-align: center;
  82. font-style: normal;
  83. text-transform: none;
  84. -webkit-text-stroke: 1px #3C6C47;
  85. position: absolute;
  86. top: 0;
  87. left: 0;
  88. z-index: 99;
  89. em {
  90. position: absolute;
  91. top: -16px;
  92. right: -12px;
  93. color: #185410;
  94. display: inline-block;
  95. width: 13px;
  96. height: 13px;
  97. }
  98. }
  99. div.introduction {
  100. display: inline-block;
  101. width: 1003px;
  102. height: 56px;
  103. line-height: 56px;
  104. background-color: #fafafa;
  105. position: absolute;
  106. bottom: 0;
  107. right: 0;
  108. display: flex;
  109. >strong:first-child {
  110. margin-left: 40px;
  111. display: inline-block;
  112. vertical-align: middle;
  113. width: 32px;
  114. height: 36px;
  115. padding: 3px 7px;
  116. border: 0.5px solid #129502;
  117. font-family: Microsoft YaHei, Microsoft YaHei;
  118. font-weight: bold;
  119. font-size: 14px;
  120. color: #139602;
  121. line-height: 18px;
  122. text-align: center;
  123. font-style: normal;
  124. text-transform: none;
  125. }
  126. div {
  127. overflow: hidden;
  128. text-overflow: ellipsis;
  129. white-space: nowrap;
  130. >span {
  131. width: 64px;
  132. height: 21px;
  133. font-family: Microsoft YaHei, Microsoft YaHei;
  134. font-weight: 400;
  135. font-size: 16px;
  136. color: #000000;
  137. line-height: 21px;
  138. text-align: left;
  139. font-style: normal;
  140. text-transform: none;
  141. margin-top: 17px;
  142. padding: 0 24px;
  143. border-right: 1px solid #ccc;
  144. a {
  145. color: #000;
  146. }
  147. }
  148. >span:hover a {
  149. color: #139602;
  150. }
  151. >span:last-child {
  152. border: none;
  153. }
  154. }
  155. }
  156. }
  157. </style>