activity.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <view>
  3. <view class="list">
  4. <u-time-line>
  5. <u-time-line-item nodeTop="2" v-for="(item, index) in list" :key="index">
  6. <template v-slot:node>
  7. <view class="u-node" style="background: #19be6b;"><u-icon name="volume-up" color="#fff" :size="30"></u-icon></view>
  8. </template>
  9. <template v-slot:content>
  10. <view class="content" @click="detail(item)">
  11. <view class="title">{{ item.title }}</view>
  12. <view class="ck">点击查看活动内容</view>
  13. <view class="time">{{ item.createTime }}</view>
  14. </view>
  15. </template>
  16. </u-time-line-item>
  17. </u-time-line>
  18. <view class="loading"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. list: [],
  27. param: { pageNum: 1, pageSize: 10, type: 4 },
  28. loadMore: true
  29. };
  30. },
  31. onLoad() {
  32. this.getData();
  33. },
  34. methods: {
  35. //获取数据
  36. getData() {
  37. this.$http.request({
  38. url: this.$http.urls.getPageContent,
  39. data: this.param,
  40. loading: 'false',
  41. success: res => {
  42. this.loadMore = res.data.pages > this.param.pageNum ? true : false;
  43. res.data.rows.forEach(item => {
  44. this.list.push(item);
  45. });
  46. }
  47. });
  48. },
  49. //详情
  50. detail(item) {
  51. uni.navigateTo({ url: '/pages/government/detail?id=' + item.contentId });
  52. },
  53. //刷新数据
  54. refresh() {
  55. this.loadMore = true;
  56. this.param.pageNum = 1;
  57. this.list = [];
  58. this.getData();
  59. }
  60. },
  61. //下拉刷新
  62. onPullDownRefresh() {
  63. setTimeout(() => {
  64. uni.stopPullDownRefresh();
  65. this.refresh();
  66. }, 1000);
  67. },
  68. //上拉加载
  69. onReachBottom() {
  70. if (this.loadMore) {
  71. this.param.pageNum++;
  72. this.getData();
  73. }
  74. }
  75. };
  76. </script>
  77. <style lang="scss">
  78. .list {
  79. padding: 15px 20px 30px 20px;
  80. .u-node {
  81. width: 44rpx;
  82. height: 44rpx;
  83. border-radius: 100rpx;
  84. display: flex;
  85. justify-content: center;
  86. align-items: center;
  87. }
  88. .content {
  89. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  90. padding: 13px;
  91. border-radius: 5px;
  92. }
  93. .title {
  94. color: #333333;
  95. font-weight: bold;
  96. font-size: 17px;
  97. }
  98. .ck {
  99. color: $dar2;
  100. font-size: 13px;
  101. padding-top: 5px;
  102. }
  103. .time {
  104. font-size: 13px;
  105. padding-top: 5px;
  106. color: $dar2;
  107. }
  108. }
  109. </style>