NewsDetail.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <script setup>
  2. import { reactive } from "vue";
  3. import { useRoute } from "vue-router";
  4. import axios from "axios";
  5. import moment from "moment";
  6. import Navbar from "@/components/Navbar.vue";
  7. const route = useRoute();
  8. const newsId = route.params.id; // 網址參數
  9. const news = reactive({
  10. data: [],
  11. });
  12. (async function getData() {
  13. try {
  14. const response = await axios.get(
  15. `https://cmm.ai:8088/api/get_news?news_id=${newsId}`
  16. );
  17. news.data = response.data.news[0];
  18. console.log("news.data", news.data);
  19. } catch (error) {
  20. console.error(error);
  21. }
  22. })();
  23. </script>
  24. <template>
  25. <Navbar />
  26. <div class="position-relative">
  27. <img src="@/assets/img/news/news-01.png" alt="" class="material-img" />
  28. <v-container class="pa-0 pt-16 position-relative">
  29. <!-- <img
  30. src="@/assets/img/news/news-detail-banner.png"
  31. alt=""
  32. class="bg-img"
  33. /> -->
  34. <div class="content">
  35. <div class="article">
  36. <v-row>
  37. <v-col cols="12">
  38. <div class="d-flex align-center mb-5">
  39. <v-chip size="large" variant="elevated" class="px-8 me-3">
  40. {{ news.data.category }}
  41. </v-chip>
  42. <p>
  43. {{ moment(`${news.data.create_time}`).format("YYYY.MM.DD") }}
  44. </p>
  45. </div>
  46. <h2>【{{ news.data.title }}】</h2>
  47. <img src="@/assets/img/img-04.jpg" alt="" class="cover-img" />
  48. <!-- <img :src="`https://cmm.ai/ntcri/${news.data.cover_img}`" alt="" /> -->
  49. </v-col>
  50. <v-col cols="12">
  51. <section class="d-flex flex-column pa-0">
  52. <p v-html="news.data.content"></p>
  53. <div class="btn-block mt-10">
  54. <v-btn rounded="xl" color="grey-darken-2" class="px-7">
  55. 檔案下載
  56. </v-btn>
  57. <v-btn rounded="xl" color="grey-darken-2" class="px-7 ms-3">
  58. 前往連結
  59. </v-btn>
  60. </div>
  61. </section>
  62. </v-col>
  63. </v-row>
  64. </div>
  65. </div>
  66. </v-container>
  67. <router-link to="/news" class="mt-16 back-link"
  68. >< 返回重要訊息</router-link
  69. >
  70. <img src="@/assets/img/news/news-01.png" alt="" class="material-img" />
  71. </div>
  72. </template>
  73. <style lang="scss" scoped>
  74. .btn-block {
  75. display: flex;
  76. justify-content: end;
  77. }
  78. .content {
  79. padding: 20px;
  80. background-image: url("@/assets/img/news/news-02.png");
  81. background-position: center;
  82. background-size: cover;
  83. border-radius: 50px;
  84. @media (max-width: 960px) {
  85. width: 90%;
  86. margin: auto;
  87. }
  88. }
  89. .article {
  90. margin: auto;
  91. padding: 80px 50px;
  92. display: flex;
  93. justify-content: center;
  94. border: 1px solid #d4d6d8;
  95. border-radius: 50px;
  96. // @media (max-width: 960px) {
  97. // width: 80%;
  98. // }
  99. @media (max-width: 600px) {
  100. padding-top: 50px;
  101. border: none;
  102. }
  103. h2 {
  104. margin: 40px auto;
  105. font-size: 28px;
  106. font-weight: 500;
  107. line-height: 38px;
  108. letter-spacing: 2px;
  109. }
  110. section {
  111. height: 100%;
  112. padding: 30px;
  113. p {
  114. font-size: 18px;
  115. font-weight: 400;
  116. line-height: 32px;
  117. letter-spacing: 1px;
  118. }
  119. }
  120. .cover-img {
  121. width: 100%;
  122. height: 500px;
  123. object-fit: cover;
  124. @media (max-width: 600px) {
  125. height: auto;
  126. }
  127. }
  128. }
  129. .bg-img {
  130. height: 1000px;
  131. position: relative;
  132. z-index: -1;
  133. @media (max-width: 600px) {
  134. height: 650px;
  135. }
  136. }
  137. .back-link {
  138. display: block;
  139. text-align: center;
  140. transition: all 0.3s;
  141. letter-spacing: 1px;
  142. &:hover {
  143. opacity: 0.8;
  144. }
  145. }
  146. .material-img {
  147. position: absolute;
  148. &:first-child {
  149. top: -15vw;
  150. }
  151. &:last-child {
  152. bottom: -150px;
  153. z-index: -5;
  154. transform: scaleX(-1);
  155. @media (max-width: 600px) {
  156. bottom: -50px;
  157. }
  158. }
  159. }
  160. </style>