activity.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <view>
  3. <view class="list">
  4. <view class="item" v-for="(item, index) in list" :key="index" @click="detail(item)">
  5. <view class="r65">
  6. <view class="title">{{ item.title }}</view>
  7. </view>
  8. <view class="r35 day">{{ item.createTime.substring(0, 11) }}</view>
  9. <view class="clear"></view>
  10. </view>
  11. <view class="loading"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. data() {
  18. return {
  19. list: [],
  20. param: { pageNum: 1, pageSize: 10, type: 4 },
  21. loadMore: true
  22. };
  23. },
  24. onLoad() {
  25. this.getData();
  26. },
  27. methods: {
  28. //获取数据
  29. getData() {
  30. this.$http.request({
  31. url: this.$http.urls.getPageContent,
  32. data: this.param,
  33. loading: 'false',
  34. success: res => {
  35. console.log(JSON.stringify(res));
  36. this.loadMore = res.data.pages > this.param.pageNum ? true : false;
  37. res.data.rows.forEach(item => {
  38. this.list.push(item);
  39. });
  40. }
  41. });
  42. },
  43. //详情
  44. detail(item) {
  45. uni.navigateTo({ url: '/pages/government/detail?id=' + item.contentId });
  46. },
  47. //刷新数据
  48. refresh() {
  49. this.loadMore = true;
  50. this.param.pageNum = 1;
  51. this.list = [];
  52. this.getData();
  53. }
  54. },
  55. //下拉刷新
  56. onPullDownRefresh() {
  57. setTimeout(() => {
  58. uni.stopPullDownRefresh();
  59. this.refresh();
  60. }, 1000);
  61. },
  62. //上拉加载
  63. onReachBottom() {
  64. if (this.loadMore) {
  65. this.param.pageNum++;
  66. this.getData();
  67. }
  68. }
  69. };
  70. </script>
  71. <style lang="scss">
  72. .list {
  73. padding: 0px 10px 70px 10px;
  74. .item {
  75. background-color: white;
  76. padding: 18px;
  77. border-bottom: 1px solid #e5e5e5;
  78. border-radius: 5px;
  79. margin-top: 10px;
  80. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.2);
  81. .title {
  82. font-size: 15px;
  83. text-align: left;
  84. color: #252525;
  85. font-weight: bold;
  86. }
  87. .desc {
  88. color: #969799;
  89. font-size: 13px;
  90. padding-top: 10px;
  91. }
  92. .day {
  93. color: #969799;
  94. font-size: 13px;
  95. padding-top: 15px;
  96. padding-left: 20px;
  97. }
  98. }
  99. }
  100. </style>