uniapp循环请求接口之后跳转

if (this.model.caseWorkPartyModelList.length > 0) {
                    let promises = []; // 用于存储所有异步操作的Promise
                    let that = this
                    this.model.caseWorkPartyModelList.forEach(async (item, index) => {
                        if (item.idCard.indexOf('*') !== -1) {
                            let params = {
                                id:this.model.caseWorkPartyModelList[index].id
                            }
                            // 将每个异步调用放入promises数组
                            promises.push(
                                new Promise(async (resolve) => {
                                    let res1 = await queryIdCardByTel(params);
                                    console.log('res1res1', res1);
                                    if (res1.error_code == '200') {
                                        that.model.caseWorkPartyModelList[index].idCard = res1
                                            .data.idCard;
                                    }
                                    resolve(); // 异步操作完成后resolve这个Promise
                                })
                            );
                        }
                    })
                    await Promise.all(promises);
                }
                uni.navigateTo({
                    url: '/casemodel/pages/case-mediate/mediate-fail/mediate-fail?type=' + JSON.stringify(this.model)
                })

 

posted @ 2024-05-13 11:14  prince11  阅读(58)  评论(0编辑  收藏  举报