原因:小程序跳转页面多个请求同时并发时,会出现短暂的白屏,封装的请求自带结束loading,所以第一个请求结束后就提早结束loading,解决方式
getNetData() {
//打请求标记,确保最后一个请求结束的隐藏loading
this.resCount=7;
this.getOverviewData();
this.getClockInfo();
this.getGridmanGenderRate();
this.getAgeRangeList();
this.getAttendenceRank();
this.getPatrolFeedbackByHour();
this.getPatrolTaskAnalysis();
},
cacelLoading(){
this.resCount-=1;
if(this.resCount<1){
uni.hideLoading();
}else{
uni.showLoading({
title:'加载中,请稍候'
});
}
},
在每一个请求里加上this.cacelLoading();,确保最后一个请求完毕后再取消展示loading
getClockInfo() {
this.$ApiService.doPost({
url: this.$Api.URL.URL_GetGridClockState,
data: {
queryStartTime: this.currentParam.alarmTimeStart,
queryEndTime: this.currentParam.alarmTimeEnd,
gridId: this.gridId,
},
success: (res) => {
this.attendanceNumInfo = res.rows;
this.cacelLoading();
},
fail: (err) => {
this.cacelLoading();
},
});
},
网友评论