index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <view>
  3. <view class="tab">
  4. <u-tabs :list="tab" @click="click"></u-tabs>
  5. </view>
  6. <view class="list">
  7. <view class="item" v-for="(item, index) in list" :key="index" @click="go('/pages/follow/detail?id=' + item.id)">
  8. <view class="title omit">
  9. <text class="icon" v-if="item.top === 1">&#xe61f;</text>
  10. <text>{{ item.templateName }}</text>
  11. </view>
  12. <view class="desc">
  13. <text>{{ item.state == 0 ? '待回访' : '已回访' }}</text>
  14. <text>{{ item.createTime }}</text>
  15. </view>
  16. </view>
  17. <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  18. <u-empty v-if="!loadMore && list.length == 0"></u-empty>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. tab: [
  27. { name: '全部', state: '' },
  28. { name: '待回访', state: 0 },
  29. { name: '已回访', state: 1 }
  30. ],
  31. list: [],
  32. param: { pageNum: 1, pageSize: 10 },
  33. loadMore: true
  34. };
  35. },
  36. onLoad(e) {
  37. this.getData();
  38. uni.$on('follow', (res) => {
  39. this.refresh();
  40. });
  41. },
  42. methods: {
  43. click(e) {
  44. this.current = e.index;
  45. this.param.type = e.dictValue;
  46. this.refresh();
  47. },
  48. getData() {
  49. this.http.request({
  50. url: '/app/follow/list',
  51. data: this.param,
  52. loading: 'false',
  53. success: (res) => {
  54. this.loadMore = res.data.pages > this.param.pageNum ? true : false;
  55. this.list.push(...res.data.rows);
  56. }
  57. });
  58. },
  59. go(url) {
  60. uni.navigateTo({ url: url });
  61. },
  62. //刷新数据
  63. refresh() {
  64. this.loadMore = true;
  65. this.param.pageNum = 1;
  66. this.list = [];
  67. this.getData();
  68. }
  69. },
  70. //下拉刷新
  71. onPullDownRefresh() {
  72. setTimeout(() => {
  73. this.refresh();
  74. uni.stopPullDownRefresh();
  75. }, 1000);
  76. },
  77. //上拉加载
  78. onReachBottom() {
  79. if (this.loadMore) {
  80. this.param.pageNum++;
  81. this.getData();
  82. }
  83. }
  84. };
  85. </script>
  86. <style lang="scss">
  87. .list {
  88. padding: 10px 12px;
  89. .item {
  90. border-radius: 5px;
  91. padding: 13px 12px 13px 12px;
  92. margin-bottom: 10px;
  93. overflow: hidden;
  94. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  95. background-color: white;
  96. .title {
  97. font-size: 15px;
  98. font-weight: bold;
  99. .icon {
  100. color: orangered;
  101. padding-right: 3px;
  102. }
  103. }
  104. .desc {
  105. font-size: 14px;
  106. padding-top: 10px;
  107. text {
  108. padding-right: 30px;
  109. }
  110. }
  111. }
  112. }
  113. </style>