index.vue 2.2 KB

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