area.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <view>
  3. <view class="list">
  4. <view class="search">
  5. <u-search placeholder="搜索互市" v-model="param.name" bgColor="white" @search="refresh()" :animation="true" actionText="取消" @clear="refresh()"></u-search>
  6. </view>
  7. <view class="item" v-for="(item, index) in list" :key="index" @click="detail(item)">
  8. <view class="title omit">{{ item.name }}</view>
  9. <view class="desc">{{ item.address }}</view>
  10. </view>
  11. <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  12. <u-empty v-if="!loadMore && list.length == 0"></u-empty>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. export default {
  18. data() {
  19. return {
  20. param: { pageNo: 1, pageSize: 20 },
  21. list: [],
  22. loadMore: true
  23. };
  24. },
  25. onLoad(e) {
  26. this.getData();
  27. },
  28. methods: {
  29. getData() {
  30. this.http.request({
  31. url: '/level-one-server/app/TbTradeArea/getList',
  32. loading: 'false',
  33. data: this.param,
  34. success: res => {
  35. this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
  36. this.list.push(...res.data.data);
  37. uni.setNavigationBarTitle({ title: '互市选择(' + res.data.dataCount + ')' });
  38. }
  39. });
  40. },
  41. detail(item) {
  42. uni.$emit('area', item);
  43. uni.navigateBack();
  44. },
  45. //刷新数据
  46. refresh() {
  47. this.loadMore = true;
  48. this.param.pageNo = 1;
  49. this.list = [];
  50. this.getData();
  51. }
  52. },
  53. //下拉刷新
  54. onPullDownRefresh() {
  55. setTimeout(() => {
  56. this.refresh();
  57. uni.stopPullDownRefresh();
  58. }, 1000);
  59. },
  60. //上拉加载
  61. onReachBottom() {
  62. if (this.loadMore) {
  63. this.param.pageNo++;
  64. this.getData();
  65. }
  66. }
  67. };
  68. </script>
  69. <style lang="scss">
  70. page {
  71. background-color: $pg;
  72. }
  73. .list {
  74. padding: 12px;
  75. .search {
  76. padding-top: 0px;
  77. }
  78. .item {
  79. padding: 13px;
  80. background-color: white;
  81. margin-bottom: 10px;
  82. border-radius: 5px;
  83. .title {
  84. font-weight: bold;
  85. }
  86. .desc {
  87. padding-top: 5px;
  88. font-size: 14px;
  89. color: #7a7a7a;
  90. }
  91. }
  92. }
  93. </style>