list.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <view>
  3. <view class="search">
  4. <u-search placeholder="搜索资讯" v-model="param.title" bgColor="white" @search="refresh()" :animation="true" actionText="取消" @clear="refresh()"></u-search>
  5. </view>
  6. <view class="list">
  7. <view class="news_item" v-for="(item, index) in list" :key="index" @click="detail(item)">
  8. <image src="../../static/news.jpg" mode="aspectFill" class="img"></image>
  9. <view class="con">
  10. <view class="title ellip">{{ item.title }}</view>
  11. <view class="source omit">{{ item.source }}</view>
  12. <view class="releaseTime">{{ item.releaseTime }}</view>
  13. </view>
  14. </view>
  15. <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  16. <u-empty v-if="!loadMore && list.length == 0"></u-empty>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. data() {
  23. return {
  24. list: [],
  25. param: { pageNo: 1, pageSize: 10 },
  26. loadMore: true
  27. };
  28. },
  29. onLoad(e) {
  30. this.getData();
  31. },
  32. methods: {
  33. getData() {
  34. this.http.request({
  35. url: '/level-one-server/app/TbPortNews/getPortNewsList',
  36. data: this.param,
  37. loading: 'false',
  38. success: res => {
  39. this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
  40. this.list.push(...res.data.data);
  41. }
  42. });
  43. },
  44. detail(item) {
  45. uni.navigateTo({ url: '/pages/news/detail?id=' + item.id });
  46. },
  47. //刷新数据
  48. refresh() {
  49. this.loadMore = true;
  50. this.param.pageNo = 1;
  51. this.list = [];
  52. this.getData();
  53. }
  54. },
  55. //下拉刷新
  56. onPullDownRefresh() {
  57. setTimeout(() => {
  58. this.refresh();
  59. uni.stopPullDownRefresh();
  60. }, 1000);
  61. },
  62. //上拉加载
  63. onReachBottom() {
  64. if (this.loadMore) {
  65. this.param.pageNo++;
  66. this.getData();
  67. }
  68. }
  69. };
  70. </script>
  71. <style lang="scss">
  72. page {
  73. background-color: $pg;
  74. }
  75. .list {
  76. padding: 12px;
  77. }
  78. </style>