|
@@ -17,11 +17,13 @@ const reducenum = function(){
|
|
|
}
|
|
|
export const get=(url,data,callback,failback)=>{
|
|
|
addnum();
|
|
|
+ var authorization = wx.getStorageSync("authorization");
|
|
|
wx.request({
|
|
|
url: app.globalData.serverpath+url,
|
|
|
method: "GET",
|
|
|
header: {
|
|
|
- "Content-Type": "json"
|
|
|
+ "Content-Type": "json",
|
|
|
+ "Authorization":authorization
|
|
|
},
|
|
|
data:data,
|
|
|
success: function (res){
|
|
@@ -36,31 +38,39 @@ export const get=(url,data,callback,failback)=>{
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
-export const post=(url,data,header,callback,failback)=>{
|
|
|
+export const post=(url,data,header,callback,failback,noauth)=>{
|
|
|
var authorization = wx.getStorageSync("authorization")
|
|
|
if(typeof header=="function"){
|
|
|
+ noauth = failback;
|
|
|
failback = callback;
|
|
|
callback = header;
|
|
|
header = {};
|
|
|
}
|
|
|
- addnum();
|
|
|
- wx.request({
|
|
|
- url: app.globalData.serverpath+url,
|
|
|
- method: "POST",
|
|
|
- header: Object.assign({
|
|
|
- "Content-Type": "json",
|
|
|
- "Authorization":authorization
|
|
|
- },header),
|
|
|
- data:data,
|
|
|
- success: function (res){
|
|
|
- //console.debug(res);
|
|
|
- callback && callback(res);
|
|
|
- },
|
|
|
- fail: function (error){
|
|
|
- failback && failback(error);
|
|
|
- },
|
|
|
- complete: function () {
|
|
|
- reducenum();
|
|
|
+ if(authorization){
|
|
|
+ addnum();
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.serverpath+url,
|
|
|
+ method: "POST",
|
|
|
+ header: Object.assign({
|
|
|
+ "Content-Type": "application/json",
|
|
|
+ "Authorization":authorization,
|
|
|
+ "Accept": "application/vnd.vpgame.v1+json"
|
|
|
+ },header),
|
|
|
+ data:data,
|
|
|
+ success: function (res){
|
|
|
+ //console.debug(res);
|
|
|
+ callback && callback(res);
|
|
|
+ },
|
|
|
+ fail: function (error){
|
|
|
+ failback && failback(error);
|
|
|
+ },
|
|
|
+ complete: function () {
|
|
|
+ reducenum();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ if(typeof noauth=="function"){
|
|
|
+ noauth();
|
|
|
}
|
|
|
- })
|
|
|
-}
|
|
|
+ }
|
|
|
+}
|