|
...
|
...
|
@@ -8,6 +8,7 @@ const api_timeout = 2000; //接口超时时间,默认2s |
|
|
|
//引入接口映射关系表
|
|
|
|
import api from './api.url'
|
|
|
|
import uri_dc from './uri'
|
|
|
|
import bot from './rebot'
|
|
|
|
|
|
|
|
const server_host = uri_dc.HOST__LINE;
|
|
|
|
|
|
...
|
...
|
@@ -74,9 +75,9 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr |
|
|
|
let param = "";
|
|
|
|
for (let key in data) {
|
|
|
|
let val = data[key];
|
|
|
|
if (val !== "" && val !== null) {
|
|
|
|
param += '&' + key + '=' + val
|
|
|
|
}
|
|
|
|
//if (val !== "" && val !== null) {
|
|
|
|
param += '&' + key + '=' + val
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
let cache_key = act;
|
|
|
|
if (param) {
|
|
...
|
...
|
@@ -146,8 +147,9 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr |
|
|
|
'content-type': 'application/x-www-form-urlencoded'
|
|
|
|
},
|
|
|
|
success: function (res) {
|
|
|
|
console.log('request.api[' + (new Date() - stime) + 'ms]==>', host + cache_key + ('&formids=' + formids.toString()) + '\nrequest.success', res.data);
|
|
|
|
console.log('request.api[' + (new Date() - stime) + 'ms]==>', host + cache_key + '\nrequest.success', res.data);
|
|
|
|
// return;
|
|
|
|
//bot.msg({url: host + cache_key, res: res.data})
|
|
|
|
if (res.data) {
|
|
|
|
if (cachetime != 0 && res.data.ret == 200) {
|
|
|
|
cache(cache_key, res.data, cachetime);//.then().catch();
|
|
...
|
...
|
@@ -157,6 +159,7 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr |
|
|
|
res.data.msg = res.data.msg.replace('非法请求:', '');
|
|
|
|
} catch (e) {
|
|
|
|
console.log('res-fail', res, e);
|
|
|
|
bot.msg({url: host + cache_key, res: res.data})
|
|
|
|
if (wx.getRealtimeLogManager) {
|
|
|
|
const logger = wx.getRealtimeLogManager()
|
|
|
|
logger.error('接口错误', {url: host + cache_key, res: res.data})
|
|
...
|
...
|
@@ -164,6 +167,7 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr |
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
bot.msg({url: host + cache_key, res: res})
|
|
|
|
if (wx.getRealtimeLogManager) {
|
|
|
|
const logger = wx.getRealtimeLogManager()
|
|
|
|
logger.error('接口错误', {url: host + cache_key, res: res})
|
|
...
|
...
|
@@ -182,6 +186,7 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr |
|
|
|
// });
|
|
|
|
//query.show();
|
|
|
|
//console.log('net',query);
|
|
|
|
bot.msg({url: host + cache_key, res: res})
|
|
|
|
if (wx.getRealtimeLogManager) {
|
|
|
|
const logger = wx.getRealtimeLogManager()
|
|
|
|
logger.error('调用失败', {url: host + cache_key, res: res})
|
...
|
...
|
|