123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- <template>
- <div class="team-x">
- <van-nav-bar
- class="left-text-bold"
- :title="title"
- left-text="返回"
- left-arrow
- @click-left="onClickLeft"
- ></van-nav-bar>
- <div class="teamContent">
- <scroller
- :isInitRefresh="false"
- ref="recordScroller"
- :list="teamList"
- noDataText="没有更多..."
- :on-infinite="getMoreList">
- <Team
- :teamType="type"
- :teamList="teamList"
- :count="page.total"
- @search="search"
- ></Team>
- </scroller>
- </div>
- </div>
- </template>
- <script>
- import { getDealerTeam, getDealerPerson } from "../api";
- import Team from "../components/CourseTeam";
- import {setWxConfig} from '../utils'
- import {setDocumentTitle} from '../../../components/vueHashCalendar/utils/util'
- export default {
- name: "courseTeam",
- components: { Team },
- data() {
- return {
- canReq: true,
- noDate: false,
- type: this.$route.params.id,//1 or 2
- page: {
- cur: 1,
- size: 10,
- total: 0
- },
- teamList: [],
- keyword: ""
- };
- },
- computed: {
- title() {
- return this.type == 1 ? "我的团队" : "近30天交易";
- }
- },
- created() {
- this.init();
- if(this.$isWx){
- setWxConfig();
- }
- },
- methods: {
- debouce(callback,time){
- let timer;
- return ()=>{
- clearTimeout(timer)
- timer = setTimeout(()=>{
- callback()
- },time)
- }
- },
- // 触底加载
- getMoreList(done) {
- console.log("到底了");
- if (!this.noDate) {
- setTimeout(() => {
- this.getList(done);
- }, 300);
- } else {
- this.$refs.recordScroller.finishInfinite(true);
- }
- },
- // 初始化
- init() {
- this.type = this.$route.params.id;
- if(this.type == 1){
- setDocumentTitle('我的团队')
- }else if(this.type == 2){
- setDocumentTitle('近30天交易')
- }
- this.getList();
- },
- //导航左侧返回
- onClickLeft() {
- if(window.history.length>1){
- this.$router.go(-1);
- }else{
- this.$router.replace('/courseHome')
- }
- },
- // 获取团队列表
- getList(done) {
- let data = {
- page: this.page.cur,
- pageSize: this.page.size,
- keyword: this.keyword
- };
- if (this.type==1) {
- getDealerTeam(data).then(res => {
- this.teamList = this.teamList.concat(res.list);
- this.page.total = res.total;
- this.page.cur = res.current;
- if (res.pages == res.current || res.pages == 0) {
- console.log("已无更多");
- if (done) done(true);
- this.noDate = true;
- } else {
- console.log("更多...");
- if (done) done();
- this.page.cur++; //下拉一次页数+1
- this.noDate = false;
- }
- });
- } else if(this.type==2) {
- getDealerPerson(data).then(res => {
- this.teamList = res.list;
- this.page.total = res.total;
- this.page.cur = res.current;
- if (res.pages == res.current || res.pages == 0) {
- if (done) done(true);
- this.noDate = true;
- } else {
- if (done) done();
- this.page.cur++; //下拉一次页数+1
- this.noDate = false;
- }
- });
- }
- },
- // 搜索
- search(val) {
- this.keyword = val;
- this.page.cur = 1;
- this.teamList = []
- this.getList();
- }
- }
- };
- </script>
- <style scoped lang="scss">
- @import url('../utils/navBar.scss');
- .team-x {
- .teamContent {
- height: calc(100vh - 0.92rem);
- position: relative;
- }
- }
- </style>
|