SecondaryHeading.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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}`}">{{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. let routeId = 0;//路由id
  30. //判断用户是由于别名跳转还是直接访问二级分类,正常来说只会从别名访问
  31. const getRoute = () => {
  32. if(route.meta.isAlias){
  33. //如果用户从别名访问,数据需要从meta中获取
  34. routeId = route.meta.routeId;
  35. }else{
  36. routeId = route.params.id;
  37. }
  38. }
  39. // 监听路由变化
  40. watch(() => route.path, (newPath) => {
  41. //每当路径变化的时候重新获取routeId
  42. getRoute()
  43. }, { immediate: true })
  44. //1.获得路由id end ---------------------------------------->
  45. //2.设置组件标题 start ---------------------------------------->
  46. const title = ref("")
  47. async function getPageData() {
  48. const mkdata = await requestDataPromise('/web/getOneWebsiteCategory', {
  49. method: 'GET',
  50. query: {
  51. 'catid': routeId,
  52. },
  53. });
  54. if(mkdata.code == 200){
  55. title.value = mkdata.data.alias;
  56. }else{
  57. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  58. console.log("错误位置:获取二级标题")
  59. console.log("后端错误反馈:",mkdata.message)
  60. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  61. }
  62. }
  63. getPageData();
  64. //2.设置组件标题 end ---------------------------------------->
  65. </script>
  66. <style lang="less" scoped>
  67. // 三农之窗
  68. .sannongzhichuang {
  69. margin: 30px 0 40px;
  70. .inner {
  71. width: 1200px;
  72. height: 67px;
  73. position: relative;
  74. }
  75. h2 {
  76. display: inline-block;
  77. //background-image: url("../../public/image/bg1.png");
  78. background: #139602;
  79. width: 156px;
  80. height: 43px;
  81. padding: 14px 31px 10px 25px;
  82. font-family: STXingkai, STXingkai;
  83. font-weight: 400;
  84. font-size: 39px;
  85. color: #FFFFFF;
  86. line-height: 46px;
  87. text-align: center;
  88. font-style: normal;
  89. text-transform: none;
  90. -webkit-text-stroke: 1px #3C6C47;
  91. position: absolute;
  92. top: 0;
  93. left: 0;
  94. z-index: 99;
  95. em {
  96. position: absolute;
  97. top: -16px;
  98. right: -12px;
  99. color: #185410;
  100. display: inline-block;
  101. width: 13px;
  102. height: 13px;
  103. }
  104. }
  105. div.introduction {
  106. display: inline-block;
  107. width: 1003px;
  108. height: 56px;
  109. line-height: 56px;
  110. background-color: #fafafa;
  111. position: absolute;
  112. bottom: 0;
  113. right: 0;
  114. display: flex;
  115. >strong:first-child {
  116. margin-left: 40px;
  117. display: inline-block;
  118. vertical-align: middle;
  119. width: 32px;
  120. height: 36px;
  121. padding: 3px 7px;
  122. border: 0.5px solid #129502;
  123. font-family: Microsoft YaHei, Microsoft YaHei;
  124. font-weight: bold;
  125. font-size: 14px;
  126. color: #139602;
  127. line-height: 18px;
  128. text-align: center;
  129. font-style: normal;
  130. text-transform: none;
  131. }
  132. div {
  133. overflow: hidden;
  134. text-overflow: ellipsis;
  135. white-space: nowrap;
  136. >span {
  137. width: 64px;
  138. height: 21px;
  139. font-family: Microsoft YaHei, Microsoft YaHei;
  140. font-weight: 400;
  141. font-size: 16px;
  142. color: #000000;
  143. line-height: 21px;
  144. text-align: left;
  145. font-style: normal;
  146. text-transform: none;
  147. margin-top: 17px;
  148. padding: 0 24px;
  149. border-right: 1px solid #ccc;
  150. a {
  151. color: #000;
  152. }
  153. }
  154. >span:hover a {
  155. color: #139602;
  156. }
  157. >span:last-child {
  158. border: none;
  159. }
  160. }
  161. }
  162. }
  163. </style>