|
@ -8,6 +8,7 @@ export class Server { |
|
|
// const _token = uni.getStorageSync('venueData').token || '';
|
|
|
// const _token = uni.getStorageSync('venueData').token || '';
|
|
|
// if(_token)data['token'] = _token;
|
|
|
// if(_token)data['token'] = _token;
|
|
|
// if(method === 'POST'&&_token)url = url + `?token=${_token}`
|
|
|
// if(method === 'POST'&&_token)url = url + `?token=${_token}`
|
|
|
|
|
|
|
|
|
uni.request({ |
|
|
uni.request({ |
|
|
url, |
|
|
url, |
|
|
timeout: 20000, |
|
|
timeout: 20000, |
|
@ -16,12 +17,9 @@ export class Server { |
|
|
method, // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
|
|
|
method, // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
|
|
|
header: {...header}, // 设置请求的 header // {'custom-header': 'application/json'}
|
|
|
header: {...header}, // 设置请求的 header // {'custom-header': 'application/json'}
|
|
|
success: res=>{ |
|
|
success: res=>{ |
|
|
// if(islog)console.log('req success---->',{
|
|
|
|
|
|
// link: url,
|
|
|
|
|
|
// query: data,
|
|
|
|
|
|
// method: method,
|
|
|
|
|
|
// data: res,
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(res.extension)util.updateTimeDifference(res.extension); //每次请求都更新时间差
|
|
|
|
|
|
|
|
|
if(isDefaultGet){ |
|
|
if(isDefaultGet){ |
|
|
if(failMsg == '')throw Error('默认回调,失败提示不能为空 key -> failMsg'); |
|
|
if(failMsg == '')throw Error('默认回调,失败提示不能为空 key -> failMsg'); |
|
|
defaultGet({ |
|
|
defaultGet({ |
|
@ -82,10 +80,14 @@ export class Server { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
get({url,data={},header={},isDefaultGet=true,failMsg=''}){ |
|
|
get({url,data={},header={},isDefaultGet=true,failMsg=''}){ |
|
|
|
|
|
let params = {} |
|
|
|
|
|
header = util.resetHeader(header,url,data,params) |
|
|
return this.request(url,data,'GET',header,isDefaultGet,failMsg); |
|
|
return this.request(url,data,'GET',header,isDefaultGet,failMsg); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
post({url,data={},header={},isDefaultGet=true,failMsg=''}){ |
|
|
post({url,data={},header={},isDefaultGet=true,failMsg=''}){ |
|
|
|
|
|
let params = {} |
|
|
|
|
|
header = util.resetHeader(header,url,data,params) |
|
|
return this.request(url,data,'POST',header,isDefaultGet,failMsg); |
|
|
return this.request(url,data,'POST',header,isDefaultGet,failMsg); |
|
|
} |
|
|
} |
|
|
// post({url,data={},header={'custom-header': 'application/json'},isDefaultGet=true,failMsg=''}){
|
|
|
// post({url,data={},header={'custom-header': 'application/json'},isDefaultGet=true,failMsg=''}){
|
|
|