notice.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <view>
  3. <view class="wrap">
  4. <view v-for="(item,index) in workList" :key="index" hover-class="hoverClass" @tap="clickContent(item)">
  5. <view style="margin-top: 20rpx;">
  6. <u-lazy-load :image="item.faceUrl" height="400" img-mode="aspectFill"></u-lazy-load>
  7. <view class="title">{{ item.title }}</view>
  8. </view>
  9. <view class="foot">
  10. <view>{{ item.source }}</view>
  11. <view>{{ item.createTime }}</view>
  12. </view>
  13. </view>
  14. </view>
  15. <u-loadmore :status="status" class="footer" @loadmore="loadWorkList"/>
  16. </view>
  17. </template>
  18. <script>
  19. import config from "common/config.js" // 全局配置文件
  20. export default {
  21. data() {
  22. return {
  23. title: '新闻资讯',
  24. logoUrl: '../../static/img/index/logo.jpg',
  25. workList: [],
  26. status: 'loadmore',
  27. pageNum: 1,
  28. pageSize: 10,
  29. loadNum: 10
  30. };
  31. },
  32. onLoad() {
  33. this.getWorkList();
  34. },
  35. methods: {
  36. clickContent(item) {
  37. if (item.id) {
  38. this.$u.route('/pages/content/content', {
  39. id: item.id
  40. });
  41. } else {
  42. this.$mytip.toast('待完善')
  43. }
  44. },
  45. getWorkList() {
  46. this.status = 'loadmore';
  47. let url = "/api/cmsApi/findArticleList";
  48. this.$u.get(url, {
  49. type: 1,
  50. pageNum: this.pageNum,
  51. pageSize: this.pageSize,
  52. orderByColumn: 'create_time',
  53. isAsc: 'desc'
  54. }).then(obj => {
  55. let data = obj.rows
  56. if (data.length > 0) {
  57. data.filter(item => {
  58. this.workList.push({
  59. id: item.id,
  60. source: item.articleSource,
  61. title: item.smallTitle,
  62. createTime: item.createTime,
  63. faceUrl: config.baseUrl + item.faceUrl
  64. })
  65. })
  66. if (this.loadNum >= obj.total) {
  67. this.status = 'nomore';
  68. }
  69. } else {
  70. this.status = 'nomore';
  71. }
  72. });
  73. },
  74. loadWorkList() {
  75. if (this.status == 'nomore') return;
  76. this.status = 'loading';
  77. this.pageNum = ++this.pageNum;
  78. this.loadNum = this.loadNum + this.pageSize
  79. this.getWorkList()
  80. }
  81. }
  82. };
  83. </script>
  84. <style lang="scss" scoped>
  85. page {
  86. background: #fff;
  87. }
  88. .wrap {
  89. margin: 0 20 rpx 20 rpx 20 rpx;
  90. display: flex;
  91. flex-direction: column;
  92. .title {
  93. padding: 30 rpx 0 0 0;
  94. font-size: 35 rpx;
  95. color: $u-main-color;
  96. font-weight: bold;
  97. }
  98. .foot {
  99. display: flex;
  100. justify-content: space-between;
  101. font-weight: normal;
  102. font-size: 26 rpx;
  103. color: $u-tips-color;
  104. padding: 30 rpx 0;
  105. border-radius: 6 rpx;
  106. border-bottom: 5px solid #ededed;
  107. }
  108. }
  109. .footer {
  110. height: 120 rpx;
  111. line-height: 120 rpx;
  112. overflow: hidden;
  113. text-align: center;
  114. color: #999;
  115. }
  116. </style>