index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. },
  39. methods: {
  40. click(e) {
  41. this.current = e.index;
  42. this.param.type = e.dictValue;
  43. this.refresh();
  44. },
  45. getData() {
  46. this.http.request({
  47. url: '/app/follow/list',
  48. data: this.param,
  49. loading: 'false',
  50. success: (res) => {
  51. this.loadMore = res.data.pages > this.param.pageNum ? true : false;
  52. this.list.push(...res.data.rows);
  53. }
  54. });
  55. },
  56. go(url) {
  57. uni.navigateTo({ url: url });
  58. },
  59. //刷新数据
  60. refresh() {
  61. this.loadMore = true;
  62. this.param.pageNum = 1;
  63. this.list = [];
  64. this.getData();
  65. }
  66. },
  67. //下拉刷新
  68. onPullDownRefresh() {
  69. setTimeout(() => {
  70. this.refresh();
  71. uni.stopPullDownRefresh();
  72. }, 1000);
  73. },
  74. //上拉加载
  75. onReachBottom() {
  76. if (this.loadMore) {
  77. this.param.pageNum++;
  78. this.getData();
  79. }
  80. }
  81. };
  82. </script>
  83. <style lang="scss">
  84. .list {
  85. padding: 10px 12px;
  86. .item {
  87. border-radius: 5px;
  88. padding: 13px 12px 13px 12px;
  89. margin-bottom: 10px;
  90. overflow: hidden;
  91. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  92. background-color: white;
  93. .title {
  94. font-size: 15px;
  95. font-weight: bold;
  96. .icon {
  97. color: orangered;
  98. padding-right: 3px;
  99. }
  100. }
  101. .desc {
  102. font-size: 14px;
  103. padding-top: 10px;
  104. text {
  105. padding-right: 30px;
  106. }
  107. }
  108. }
  109. }
  110. </style>