newsList.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view class="main">
  3. <view class="list_item flex justify-between align-center" @click="toNewsInfo(item.id)"
  4. v-for="(item,index) in list" :key="index">
  5. <view class="">
  6. <view class="news_title">
  7. {{item.title}}
  8. </view>
  9. <view class="news_time">
  10. 丹棱检察·{{$u.timeFrom(parseInt(item.created_at), 'yyyy年mm月dd日')}}
  11. </view>
  12. </view>
  13. <view class="" v-if="item.show_img!=''">
  14. <u-image width="224rpx" height="168rpx" :src="item.show_img"></u-image>
  15. </view>
  16. </view>
  17. <uni-load-more :loadingType="loadingType" :contentText="contentText" />
  18. <!-- <view class="cu-tabbar-height"></view> -->
  19. </view>
  20. </template>
  21. <script>
  22. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  23. export default {
  24. components: {
  25. uniLoadMore
  26. },
  27. data() {
  28. return {
  29. callUrl: '',
  30. loadingType: 0,
  31. contentText: {
  32. contentdown: '上拉显示更多',
  33. contentrefresh: '正在加载...',
  34. contentnomore: '没有更多数据了'
  35. },
  36. indexPage: 1,
  37. list: [],
  38. type: null
  39. }
  40. },
  41. onLoad(op) {
  42. this.type = op.type
  43. if (op.title !== undefined) {
  44. uni.setNavigationBarTitle({
  45. title: op.title
  46. })
  47. }
  48. if (this.type != 4) {
  49. this.callUrl = '/home/news_list'
  50. this.getNewsList()
  51. }
  52. },
  53. methods: {
  54. toNewsInfo(id) {
  55. uni.navigateTo({
  56. url: "./newsInfo?id=" + id + '&type=' + this.type
  57. })
  58. },
  59. async getNewsList() {
  60. let res = await this.$u.get(this.callUrl, {
  61. page: this.indexPage,
  62. type: this.type
  63. })
  64. this.list = this.list.concat(res.data)
  65. this.indexPage++
  66. if (res.current_page == res.last_page) {
  67. this.loadingType = 2;
  68. } else {
  69. this.loadingType = 0;
  70. }
  71. }
  72. }
  73. }
  74. </script>
  75. <style>
  76. .list_item {
  77. padding: 30rpx 28rpx;
  78. background: #fff;
  79. margin: 20rpx 0;
  80. }
  81. .news_time {
  82. font-size: 22rpx;
  83. font-family: PingFang-SC-Medium, PingFang-SC;
  84. font-weight: 500;
  85. color: #999999;
  86. margin-top: 46rpx;
  87. }
  88. .news_title {
  89. font-size: 28rpx;
  90. font-family: PingFang-SC-Medium, PingFang-SC;
  91. font-weight: bold;
  92. color: #333;
  93. width: 100%;
  94. display: -webkit-box;
  95. -webkit-box-orient: vertical;
  96. -webkit-line-clamp: 2;
  97. overflow: hidden;
  98. }
  99. </style>