多次调用多一个接口

位置:首页 / 技术中心 / 杂项

杂项 Admin 2026-03-19 23:22:17 94
使用 Promise.all 并行调用两个接口
      getlistUser() {
        let params = { ...this.searchForm };
        if (this.userType == 0) {
          let params1 = { ...params, auditStatus: 0 };
          let params2 = { ...params, auditStatus: 2 };
          Promise.all([list(params1), list(params2)]).then(([res1, res2]) => {
            this.tableData = [...res1.data.rows, ...res2.data.rows];
            this.total = res1.data.total + res2.data.total;
          });
        } else {
          params.userType = this.userType;
          params.auditStatus = 1;
          list(params).then((res) => {
            this.tableData = res.data.rows;
            this.total = res.data.total;
          });
        }
      },
18455111359 扫描二维码