index.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view class="list">
  3. <view class="msearch" style="margin-bottom: 15px;">
  4. <u-search v-model="param.title" :animation="true" action-text="取消" placeholder="输入搜索内容" shape="round" @search="search" @clear="clear"></u-search>
  5. </view>
  6. <u-time-line>
  7. <u-time-line-item class="hot_item" nodeTop="2" v-for="(item, index) in list" :key="index">
  8. <template v-slot:node>
  9. <view class="u-node" style="background: #fde4e8;"><text class="icon" style="color: #48a5ff;">&#xe649;</text></view>
  10. </template>
  11. <template v-slot:content>
  12. <view class="content" @click="detail(item)">
  13. <view class="title">{{ item.title }}</view>
  14. <view class="ck">点击查看内容</view>
  15. <view class="time">{{ item.createTime }}</view>
  16. </view>
  17. </template>
  18. </u-time-line-item>
  19. </u-time-line>
  20. <view class="loading"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. data() {
  26. return {
  27. list: [],
  28. param: { pageNum: 1, pageSize: 10, serviceInfo: 1,title:'',orderByColumn: 'createTime', isAsc: 'desc' },
  29. loadMore: true
  30. };
  31. },
  32. onLoad() {
  33. this.getData();
  34. },
  35. methods: {
  36. //获取数据
  37. getData() {
  38. this.$http.request({
  39. url: this.$http.urls.getPageContent,
  40. data: this.param,
  41. loading: 'false',
  42. success: res => {
  43. this.loadMore = res.data.pages > this.param.pageNum ? true : false;
  44. res.data.rows.forEach(item => {
  45. this.list.push(item);
  46. });
  47. }
  48. });
  49. },
  50. //详情
  51. detail(item) {
  52. uni.navigateTo({ url: '/pages/travel/detail?id=' + item.contentId });
  53. },
  54. //点击键盘搜索按钮触发
  55. search() {
  56. this.refresh();
  57. },
  58. //清空搜索内容
  59. clear() {
  60. this.refresh();
  61. },
  62. //刷新数据
  63. refresh() {
  64. this.loadMore = true;
  65. this.param.pageNum = 1;
  66. this.list = [];
  67. this.getData();
  68. }
  69. },
  70. //下拉刷新
  71. onPullDownRefresh() {
  72. setTimeout(() => {
  73. uni.stopPullDownRefresh();
  74. this.refresh();
  75. }, 1000);
  76. },
  77. //上拉加载
  78. onReachBottom() {
  79. if (this.loadMore) {
  80. this.param.pageNum++;
  81. this.getData();
  82. }
  83. }
  84. };
  85. </script>
  86. <style lang="scss">
  87. .list {
  88. padding: 15px 20px 30px 20px;
  89. }
  90. </style>