contacts.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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.address }} </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: '/transport-server/app/TbFavoriteContacts/getAppList',
  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. uni.$emit('one-address', item);
  51. uni.navigateBack();
  52. },
  53. //刷新数据
  54. refresh() {
  55. this.loadMore = true;
  56. this.param.pageNo = 1;
  57. this.list = [];
  58. this.getData();
  59. }
  60. },
  61. //下拉刷新
  62. onPullDownRefresh() {
  63. setTimeout(() => {
  64. this.refresh();
  65. uni.stopPullDownRefresh();
  66. }, 1000);
  67. },
  68. //上拉加载
  69. onReachBottom() {
  70. if (this.loadMore) {
  71. this.param.pageNo++;
  72. this.getData();
  73. }
  74. },
  75. onNavigationBarButtonTap() {
  76. uni.navigateTo({ url: 'add' });
  77. }
  78. };
  79. </script>
  80. <style lang="scss">
  81. page {
  82. background-color: $pg;
  83. }
  84. .list {
  85. padding: 12px;
  86. .item {
  87. padding: 5px;
  88. color: $font-c;
  89. background-color: white;
  90. border-radius: 10px;
  91. margin-bottom: 10px;
  92. }
  93. }
  94. </style>