list.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <view class="list">
  3. <view class="item" v-for="(item, index) in list" :key="index" @click="detail(item)">
  4. <view class="address">
  5. <view class="con">
  6. <view class="title omit">{{item.province}} {{item.city}} {{item.area}} {{item.street}}</view>
  7. <view class="desc">
  8. <text>{{item.name}}</text>
  9. <text>{{item.phone}}</text>
  10. </view>
  11. </view>
  12. <view class="icon">&#xe8f2;</view>
  13. <view class="clear"></view>
  14. </view>
  15. </view>
  16. <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  17. <u-empty v-if="!loadMore && list.length == 0"></u-empty>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. data() {
  23. return {
  24. select: false,
  25. list: [],
  26. param: { pageNo: 1, pageSize: 10 },
  27. loadMore: true
  28. };
  29. },
  30. onLoad(e) {
  31. this.select = e.select || false;
  32. this.getData();
  33. uni.$on('address', res => {
  34. this.refresh();
  35. });
  36. },
  37. methods: {
  38. getData() {
  39. this.http.request({
  40. url: '/level-two-server/app/address/getList',
  41. data: this.param,
  42. loading: 'false',
  43. success: res => {
  44. this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
  45. this.list.push(...res.data.data);
  46. }
  47. });
  48. },
  49. detail(item) {
  50. if (this.select) {
  51. uni.$emit('selectAddress', item);
  52. uni.navigateBack();
  53. } else {
  54. uni.navigateTo({ url: '/pages/market/two/purchaser/address/add?id=' + item.id });
  55. }
  56. },
  57. //刷新数据
  58. refresh() {
  59. this.loadMore = true;
  60. this.param.pageNo = 1;
  61. this.list = [];
  62. this.getData();
  63. }
  64. },
  65. //下拉刷新
  66. onPullDownRefresh() {
  67. setTimeout(() => {
  68. this.refresh();
  69. uni.stopPullDownRefresh();
  70. }, 1000);
  71. },
  72. //上拉加载
  73. onReachBottom() {
  74. if (this.loadMore) {
  75. this.param.pageNo++;
  76. this.getData();
  77. }
  78. },
  79. onNavigationBarButtonTap() {
  80. uni.navigateTo({ url: 'add' });
  81. }
  82. };
  83. </script>
  84. <style lang="scss">
  85. page {
  86. background-color: $pg;
  87. }
  88. .list {
  89. padding: 12px;
  90. .item {
  91. padding: 5px;
  92. color: $font-c;
  93. background-color: white;
  94. border-radius: 10px;
  95. margin-bottom: 10px;
  96. }
  97. }
  98. </style>