NewsList.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <li v-if="newsData" @click.prevent="checkInfo(newsData)">
  3. <div class="newsInfor-img-box" :style="{backgroundImage: `url(${newsData.pic || newsInforImg})`}"></div>
  4. <div class="newsInfor-list-content">
  5. <h5>{{ newsData.title }}</h5>
  6. <div><span class="mta-hidden-sm">{{ changeFullDate(newsData.startTime) }}</span></div>
  7. <div class="mta-hidden-xs"><i></i><span>{{ changeFullDate(newsData.startTime) }}</span><i type="visits"></i><span>{{ newsData.visits }}</span>
  8. </div>
  9. <p>{{ newsData.intro }}</p>
  10. <!-- <a class="mta-hidden-xs" :href="`${baseUrl}/news/${newsData.code}`" >
  11. <span>了解更多</span>
  12. </a>-->
  13. </div>
  14. </li>
  15. </template>
  16. <script>
  17. import {mapGetters} from 'vuex';
  18. export default {
  19. name: 'NewList',
  20. props: {
  21. newsData: {
  22. type: Object,
  23. default: () => {
  24. },
  25. },
  26. },
  27. data() {
  28. return {
  29. newsInforImg: require(`~/static/images/client/newsInfor/newsInfor-list-img.png`),
  30. };
  31. },
  32. computed: {
  33. baseUrl() {
  34. return this.getBaseUrl;
  35. },
  36. ...mapGetters(['getBaseUrl']),
  37. },
  38. methods: {
  39. changeFullDate(myDate) {
  40. const result = new Date(myDate);
  41. const curYear = result.getFullYear().toString();
  42. const curMonth = (result.getMonth() + 1).toString().padStart(2, '0');
  43. const curDay = result.getDate().toString().padStart(2, '0');
  44. return `${curYear}-${curMonth}-${curDay}`
  45. },
  46. checkInfo(data) {
  47. // console.log(window.localtion.href);
  48. // console.log(self.localtion.href);
  49. // console.log(document.URL);
  50. const opt = {
  51. id: data.code,
  52. };
  53. this.$router.push({name: 'news-id', params: opt});
  54. this.$emit('know-more', data);
  55. },
  56. },
  57. };
  58. </script>
  59. <style scoped>
  60. </style>