You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
1.2 KiB
1 lines
1.2 KiB
import Log from"../constants/log.js";const request=function(e,t){const{token:o="",url:a,method:r="POST",data:s,reTry:d,header:u={"Content-Type":"application/json"}}=e;try{uni.request({url:uni.eidBaseUrl+a,method:r,data:s,header:u,success(r){console.log("request success:",r),200===r.statusCode&&r.data?0==r.data.ErrorCode||0==r.data.code?t({ErrorCode:0,ErrorMsg:r.data.ErrorMsg,Data:r.data.Data||r.data.data,reTry:d}):t({ErrorCode:r.data.ErrorCode,ErrorMsg:r.data.ErrorMsg,Data:r.data.Data||r.data.data}):t({ErrorCode:-101,ErrorMsg:"请求错误,请稍后重试"})},fail(r){console.log("request error:",r),d&&d.tryCount&&0<d.tryCount?(d.tryCount--,uni.eidBaseUrl=uni.eidBackUpUrl,setTimeout(()=>{request(e,t)},d.retryDelay||0)):t({ErrorCode:-107,ErrorMsg:"request请求异常,请稍后重试"}),uni.reportLogToEid({token:o,event:Log.requestFail,errCode:"-1",errMsg:"requestFail 调用失败",data:{url:""+(uni.eidBaseUrl+a),err:r}})}})}catch(r){console.log("request error:",r),t({ErrorCode:-109,ErrorMsg:"request方法异常,请稍后重试"}),uni.reportLogToEid({token:o,event:Log.requestCatch,errCode:"-1",errMsg:"requestFail 调用失败",data:{url:""+(uni.eidBaseUrl+a),err:r}})}},$http=request;export{$http};
|