news.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <div>
  3. <ul class="conference-news-list">
  4. <template v-for="(newItem, n) in newsData">
  5. <li :key="n" @click="toView('NewsDetail', newItem.id)" v-if="newItem.languageType == $i18n.locale">
  6. <p>{{lang=='en'? newItem.titleEn: newItem.title}}</p>
  7. <span>{{formatDate(newItem.createDate)}}</span>
  8. </li>
  9. </template>
  10. </ul>
  11. <div class="pagination">
  12. <el-pagination
  13. background
  14. @current-change="handleCurrentChange"
  15. :page-size="pageSize"
  16. layout=" prev, pager, next"
  17. :total="$i18n.locale=='en'? newsNumEn: newsNumZh">
  18. </el-pagination>
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. import { getConfrenceDetail } from "@/api/meeting/meetingOutInfo";
  24. export default {
  25. data(){
  26. return {
  27. newsData: [],
  28. originalData: [],
  29. pageSize: 10,
  30. lang: '',
  31. newsNumEn: 0,
  32. newsNumZh: 0,
  33. }
  34. },
  35. created(){
  36. this.lang = this.$i18n.locale;
  37. },
  38. watch: {
  39. '$i18n.locale'(val){
  40. this.lang = val;
  41. }
  42. },
  43. mounted(){
  44. getConfrenceDetail(this.$route.query.key).then((res) => {
  45. this.originalData = res.data.meetingOutInfo.news;
  46. this.newsData = this.originalData.slice(0, this.pageSize);
  47. this.newsNumEn = 0;
  48. this.newsNumZh = 0;
  49. this.originalData.forEach(item=>{
  50. if(item.languageType=='en'){
  51. this.newsNumEn++
  52. }else if(item.languageType=='zh'){
  53. this.newsNumZh++
  54. }
  55. })
  56. console.log('新闻',this.newsData)
  57. });
  58. },
  59. methods: {
  60. toView(router, json) {
  61. this.$router.push({ path: router, query: { key: json } });
  62. },
  63. handleCurrentChange(p){
  64. this.newsData = this.originalData.slice((p-1)*this.pageSize, p*this.pageSize)
  65. }
  66. }
  67. }
  68. </script>
  69. <style scoped>
  70. .conference-news-list {
  71. padding: 0 20px;
  72. font-size: 16px;
  73. color: #666;
  74. }
  75. .conference-news-list li {
  76. cursor: pointer;
  77. display: flex;
  78. border-bottom: 1px solid #999;
  79. padding: 16px 0;
  80. }
  81. .conference-news-list li p {
  82. line-height: 28px;
  83. margin: 0;
  84. flex: 1;
  85. margin-right: 20px;
  86. }
  87. .conference-news-list li:hover > p{
  88. color: #dd511b;
  89. }
  90. .conference-news-list li span {
  91. color: #666;
  92. font-size: 16px;
  93. display: inline-block;
  94. padding-bottom: 10px;
  95. width: 100px;
  96. text-align: right;
  97. }
  98. .pagination{
  99. text-align: center;
  100. margin-top: 40px;
  101. }
  102. </style>