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.
 

153 lines
3.7 KiB

var app = getApp();
var reconnectMethod = '';
var reconnectParams = [];
var newReconnectMethod = '';
var newReconnectParams = [];
/**
* method:接口str
* params:参数[]
* successaction:成功回调
*/
function requestLoading(method, params, successaction) {
reconnectMethod = method;
reconnectParams = params;
wx.showLoading({
title: "加载中",
})
var data = {
'id': 1,
'method': method,
'params': params
};
wx.request({
url: app.globalData.baseUrl,
data: data,
header: {
'content-type': 'application/json',
'cookie': app.globalData.cookie
},
method: 'POST',
success: function (res) {
// console.log(res)
if (res.data.error != null) {
if (res.data.error.code == 401) {
wx.request({
url: app.globalData.baseUrl,
data: {
'id': 1,
'method': "/MainSystem/B3MiniProgramRpc/Rpcs/CommonRpc/WeixinLogin",
'params': [app.globalData.appID, app.globalData.openID]
},
header: {
'content-type': 'application/json',
'cookie': app.globalData.cookie
},
method: 'POST',
success: function (res) {
app.globalData.cookie = res.data.result;
requestLoading(reconnectMethod, reconnectParams, successaction);
}
})
} else {
wx.showModal({
showCancel: false,
title: '执行出错',
content: res.data.error.message,
})
}
} else {
successaction(res.data)
}
},
fail: function (res) {
console.log(res)
wx.showModal({
title: '执行出错',
content: res,
})
},
complete: function (res) {
wx.hideLoading()
},
})
}
function transfer_request(method, params, successaction) {
newReconnectMethod = method;
newReconnectParams = params;
wx.showLoading({
title: "加载中",
})
var newData = {
"DecryptCookie": app.globalData.cookie,
"CustomerId": app.globalData.globalCustomerID,
"Method": method,
"Data": params
};
var baseUrl = app.globalData.tranferBaseUrl;
wx.request({
url: baseUrl,
data: newData,
header: {
'content-type': 'application/json',
'cookie': app.globalData.cookie
},
method: 'POST',
success: function (res) {
if (res.data.error != null) {
if (res.data.error.code == 401) {
wx.request({
url: app.globalData.tranferBaseUrl,
data: {
"DecryptCookie": app.globalData.cookie,
"CustomerId": app.globalData.globalCustomerID,
"Method": "/MainSystem/B3MiniProgramRpc/Rpcs/CommonRpc/WeixinLogin",
"Data": [app.globalData.appID, app.globalData.openID]
},
header: {
'content-type': 'application/json',
'cookie': app.globalData.cookie
},
method: 'POST',
success: function (res) {
app.globalData.cookie = res.data.result;
transfer_request(newReconnectMethod, newReconnectParams, successaction);
}
})
} else {
wx.showModal({
showCancel: false,
title: '执行出错',
content: res.data.error.message,
})
}
} else {
successaction(res.data)
}
},
fail: function (res) {
console.log(res)
wx.showModal({
title: '执行出错',
content: res,
});
},
complete: function (res) {
wx.hideLoading()
},
})
}
module.exports = {
requestLoading: requestLoading,
transfer_request: transfer_request
}