newCenter.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <div class="newCenter pad:w-full">
  3. <big-title>{{lang===langType.cn?"新闻中心":getAbbrText("新闻中心")}}</big-title>
  4. <div class="container mx-auto newView">
  5. <a
  6. v-for="(news,i) in newArr"
  7. :key="news.key"
  8. :href="`/news/${news.key}/${news.id}`"
  9. :class="`newChunk chunk${i}`">
  10. <span class="imgBox" v-if="news.img">
  11. <img :src="imagePathBabel(news.img)" alt=""/>
  12. </span>
  13. <p class="newsContext">
  14. <span class="newsType">
  15. <span>{{news.type_name}}</span>
  16. </span>
  17. <span class="title">
  18. {{lang===langType.cn?news.title:news.title_en||news.title}}
  19. </span>
  20. <span class="description">
  21. {{lang===langType.cn?news.remark:news.remark_en||news.remark}}
  22. </span>
  23. <span class="time">
  24. {{news.time}}
  25. </span>
  26. </p>
  27. </a>
  28. </div>
  29. <div class="container mx-auto">
  30. <a class=" show-more" :href="hrefs.news">查看更多</a>
  31. </div>
  32. </div>
  33. </template>
  34. <script>
  35. import langMap from "@/map/langMap";
  36. import {hrefs} from "@/map/hrefMap";
  37. import {newsType,getNewsTypeStr} from "@/map/newMap";
  38. import BigTitle from "~/components/public/bigTitle.vue";
  39. import {imagePathBabel} from "@/tools/imagePath";
  40. export default {
  41. name: "newCenter",
  42. components: {BigTitle},
  43. props: {
  44. lang:{
  45. default: langMap.lang.cn
  46. },
  47. },
  48. data(){
  49. return {
  50. langType: langMap.lang,
  51. hrefs: hrefs,
  52. newsType: newsType,
  53. }
  54. },
  55. computed: {
  56. newArr(){
  57. let arr = this.$store.getters.platform.news;
  58. console.log(arr)
  59. return arr.map((item,i)=>{
  60. let res = {
  61. ...item
  62. }
  63. if(i === 0){
  64. res.img = res.image;
  65. }
  66. return res
  67. })
  68. }
  69. },
  70. methods:{
  71. imagePathBabel,
  72. getLangText(str) {
  73. return langMap.getText(this.lang, str);
  74. },
  75. getAbbrText(str) {
  76. return langMap.getAbbrText(this.lang, str);
  77. },
  78. getNewsTypeStr(ind){
  79. return langMap.getAbbrText(
  80. this.lang,
  81. getNewsTypeStr(ind)
  82. );
  83. }
  84. }
  85. }
  86. </script>
  87. <style scoped>
  88. .newCenter{
  89. width: calc(100vw - 20px);
  90. margin: 0 auto;
  91. }
  92. .newView{
  93. display: flex;
  94. align-items: center;
  95. flex-direction: column;
  96. }
  97. .newView .newChunk{
  98. box-shadow: 0 0 1px black;
  99. position: relative;
  100. overflow: hidden;
  101. cursor: pointer;
  102. box-sizing: border-box;
  103. padding: 15px 35px;
  104. width: 96%;
  105. }
  106. @media screen and (min-width: 1024px) {
  107. .newView{
  108. display: grid;
  109. grid-template-columns: repeat(3);
  110. grid-template-rows: repeat(2,270px);
  111. grid-template-areas:
  112. 'a b c'
  113. 'a d e';
  114. margin-bottom: 35px;
  115. }
  116. .newView .newChunk{
  117. width: 100%;
  118. }
  119. }
  120. .newView .newChunk:hover{
  121. box-shadow: 2px 2px 6px #484444;
  122. }
  123. .newChunk .imgBox{
  124. width: 100%;
  125. height: 240px;
  126. margin-bottom: 10px;
  127. }
  128. .newView .newChunk:hover .imgBox img{
  129. left: -10px;
  130. top: -10px;
  131. max-width: calc(100% + 20px);
  132. width: calc(100% + 20px);
  133. height: calc(100% + 20px);
  134. }
  135. .newsContext{
  136. display: block;
  137. width: 100%;
  138. height: 240px;
  139. }
  140. .newsContext .newsType{
  141. /*margin: 10px 0;*/
  142. display: flex;
  143. height: 35px;
  144. align-items: center;
  145. }
  146. .newsContext .newsType > span{
  147. color: #ea0000;
  148. background-color: #eecec5;
  149. padding: 1px 15px;
  150. border-radius: 3px;
  151. }
  152. .newsContext .title{
  153. font-size: 1.3em;
  154. display: flex;
  155. height: 55px;
  156. align-items: center;
  157. font-weight: bold;
  158. }
  159. .newsContext .description{
  160. display: block;
  161. width: 100%;
  162. height: calc(100% - 120px);
  163. }
  164. .newsContext .time{
  165. display: flex;
  166. height: 40px;
  167. }
  168. .show-more{
  169. height: 50px;
  170. display: flex;
  171. align-items: center;
  172. justify-content: flex-end;
  173. padding: 0 10px;
  174. box-sizing: border-box;
  175. font-size: 1.4em;
  176. margin-bottom: 35px;
  177. }
  178. .show-more:hover{
  179. color: orangered;
  180. }
  181. .newView .chunk0{
  182. grid-area: a;
  183. height: 100%;
  184. }
  185. /*.newView .chunk2{*/
  186. /* grid-area: b;*/
  187. /*}*/
  188. /*.newView .chunk3{*/
  189. /* grid-area: c;*/
  190. /*}*/
  191. /*.newView .chunk4{*/
  192. /* grid-area: d;*/
  193. /*}*/
  194. /*.newView .chunk5{*/
  195. /* grid-area: e;*/
  196. /*}*/
  197. </style>