team.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <div class="team-x">
  3. <van-nav-bar
  4. class="left-text-bold"
  5. :title="title"
  6. left-text="返回"
  7. left-arrow
  8. @click-left="onClickLeft"
  9. ></van-nav-bar>
  10. <div class="teamContent">
  11. <scroller
  12. :isInitRefresh="false"
  13. ref="recordScroller"
  14. :list="teamList"
  15. noDataText="没有更多..."
  16. :on-infinite="getMoreList">
  17. <Team
  18. :teamType="type"
  19. :teamList="teamList"
  20. :count="page.total"
  21. @search="search"
  22. ></Team>
  23. </scroller>
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. import { getDealerTeam, getDealerPerson } from "../api";
  29. import Team from "../components/CourseTeam";
  30. import {setWxConfig} from '../utils'
  31. import {setDocumentTitle} from '../../../components/vueHashCalendar/utils/util'
  32. export default {
  33. name: "courseTeam",
  34. components: { Team },
  35. data() {
  36. return {
  37. canReq: true,
  38. noDate: false,
  39. type: this.$route.params.id,//1 or 2
  40. page: {
  41. cur: 1,
  42. size: 10,
  43. total: 0
  44. },
  45. teamList: [],
  46. keyword: ""
  47. };
  48. },
  49. computed: {
  50. title() {
  51. return this.type == 1 ? "我的团队" : "近30天交易";
  52. }
  53. },
  54. created() {
  55. this.init();
  56. if(this.$isWx){
  57. setWxConfig();
  58. }
  59. },
  60. methods: {
  61. debouce(callback,time){
  62. let timer;
  63. return ()=>{
  64. clearTimeout(timer)
  65. timer = setTimeout(()=>{
  66. callback()
  67. },time)
  68. }
  69. },
  70. // 触底加载
  71. getMoreList(done) {
  72. console.log("到底了");
  73. if (!this.noDate) {
  74. setTimeout(() => {
  75. this.getList(done);
  76. }, 300);
  77. } else {
  78. this.$refs.recordScroller.finishInfinite(true);
  79. }
  80. },
  81. // 初始化
  82. init() {
  83. this.type = this.$route.params.id;
  84. if(this.type == 1){
  85. setDocumentTitle('我的团队')
  86. }else if(this.type == 2){
  87. setDocumentTitle('近30天交易')
  88. }
  89. this.getList();
  90. },
  91. //导航左侧返回
  92. onClickLeft() {
  93. if(window.history.length>1){
  94. this.$router.go(-1);
  95. }else{
  96. this.$router.replace('/courseHome')
  97. }
  98. },
  99. // 获取团队列表
  100. getList(done) {
  101. let data = {
  102. page: this.page.cur,
  103. pageSize: this.page.size,
  104. keyword: this.keyword
  105. };
  106. if (this.type==1) {
  107. getDealerTeam(data).then(res => {
  108. this.teamList = this.teamList.concat(res.list);
  109. this.page.total = res.total;
  110. this.page.cur = res.current;
  111. if (res.pages == res.current || res.pages == 0) {
  112. console.log("已无更多");
  113. if (done) done(true);
  114. this.noDate = true;
  115. } else {
  116. console.log("更多...");
  117. if (done) done();
  118. this.page.cur++; //下拉一次页数+1
  119. this.noDate = false;
  120. }
  121. });
  122. } else if(this.type==2) {
  123. getDealerPerson(data).then(res => {
  124. this.teamList = res.list;
  125. this.page.total = res.total;
  126. this.page.cur = res.current;
  127. if (res.pages == res.current || res.pages == 0) {
  128. if (done) done(true);
  129. this.noDate = true;
  130. } else {
  131. if (done) done();
  132. this.page.cur++; //下拉一次页数+1
  133. this.noDate = false;
  134. }
  135. });
  136. }
  137. },
  138. // 搜索
  139. search(val) {
  140. this.keyword = val;
  141. this.page.cur = 1;
  142. this.teamList = []
  143. this.getList();
  144. }
  145. }
  146. };
  147. </script>
  148. <style scoped lang="scss">
  149. @import url('../utils/navBar.scss');
  150. .team-x {
  151. .teamContent {
  152. height: calc(100vh - 0.92rem);
  153. position: relative;
  154. }
  155. }
  156. </style>