news.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <view>
  3. <u-navbar :back-text="title" back-icon-size="28" back-icon-color="#ffffff"
  4. :background="{backgroundColor: '#2795FD',}" :back-text-style="{color: '#ffffff'}"></u-navbar>
  5. <view class="main">
  6. <view class="news-item" v-for="(item,i) in list" :key="i"
  7. @click="gotoUrl('pages/packages/news/articleDetail?id='+item.id)">
  8. <view class="content">
  9. <view class="title">
  10. 荆州市发布“招硕引博”公告,高新区招录8人​!
  11. </view>
  12. <view class="tags">
  13. <view class="classify">
  14. 政策发布
  15. </view>
  16. <view class="date">
  17. 2023-06-10
  18. </view>
  19. </view>
  20. </view>
  21. <view class="picture">
  22. <!-- <img src="@/assets/img/newsPicture.png" alt=""> -->
  23. </view>
  24. </view>
  25. </view>
  26. <u-divider v-if="list.length==recordsTotal"
  27. :isnone="list.length==0" nonetext="没有找到相关内容"
  28. bg-color="#fff" margin-top="20" border-color="#CFD2D5">已经到底了</u-divider>
  29. </view>
  30. </template>
  31. <script>
  32. import * as API from '@/apis/pagejs/packages.js'
  33. export default {
  34. data() {
  35. return {
  36. title:"",
  37. type:"",
  38. list:[],
  39. recordsTotal: 0,
  40. listFrom:{
  41. pageIndex: 1,
  42. pageSize: 20,
  43. }
  44. }
  45. },
  46. onLoad(op) {
  47. this.title=op.title
  48. this.type=op.t
  49. this.getList();
  50. },
  51. onReachBottom() {
  52. if (this.list.length < this.recordsTotal) {
  53. this.myLoadmore();
  54. }
  55. },
  56. methods: {
  57. myLoadmore(){
  58. this.listFrom.pageIndex += 1;
  59. this.getList();
  60. },
  61. getList(){
  62. uni.showLoading({
  63. title: "加载中",
  64. mask: true,
  65. })
  66. API.newsList({
  67. category:this.type,
  68. pageSize:this.listFrom.pageSize,
  69. pageIndex:this.listFrom.pageIndex,
  70. }).then((res) => {
  71. uni.hideLoading();
  72. if (this.listFrom.pageIndex == 1) {
  73. this.list = res.data.data;
  74. } else {
  75. this.list = [
  76. ...this.list,
  77. ...res.data.data
  78. ];
  79. }
  80. this.recordsTotal=res.data.recordsTotal;
  81. }).catch(error => {
  82. uni.showToast({icon: 'none',
  83. title: error,
  84. icon: "none"
  85. })
  86. })
  87. }
  88. }
  89. }
  90. </script>
  91. <style lang="scss" scoped>
  92. page{
  93. padding-bottom: 120px;
  94. }
  95. .main{
  96. padding: 24rpx 32rpx;
  97. .news-item{
  98. display: flex;
  99. height: auto;
  100. margin-bottom: 40rpx;
  101. .content{
  102. margin-right: 24rpx;
  103. display: flex;
  104. flex-direction: column;
  105. justify-content: space-between;
  106. .title{
  107. color: rgba(51, 51, 51, 1);
  108. font-size: 16px;
  109. text-align: justify;
  110. line-height: 48rpx;
  111. }
  112. .tags{
  113. display: flex;
  114. justify-content: space-between;
  115. .classify{
  116. color: rgba(39, 149, 253, 1);
  117. }
  118. .date{
  119. color: rgba(153, 153, 153, 1);
  120. font-size: 24rpx;
  121. }
  122. }
  123. }
  124. .picture{
  125. width: 224rpx;
  126. height: 172rpx;
  127. border-radius: 4px;
  128. img{
  129. width: 224rpx;
  130. height: 172rpx;
  131. }
  132. }
  133. }
  134. }
  135. </style>