introduction.vue 2.2 KB

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