Commit f6ba7bcb4686b5eb920a8084a5b2bf391c6c5dd8

Authored by vking
2 parents 84be03ad 94821c89

Merge remote-tracking branch 'remotes/origin/rebot' into master-rewrite-addnew

Showing 2 changed files with 45 additions and 4 deletions
... ... @@ -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})
... ...
//https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=9094c8cc-ec7f-4221-b1d9-50e71e008aa9
import util from './util'
export default {
async msg (json){
let openid=await getApp().getOpenid()
if(!openid) return;
let pages = getCurrentPages();
//let p = pages[pages.length - 1];
let px='',pl=pages.length,str=''
for(let pi=pl-1,pj=0;pi>=0;pi--){
px+=">"+str+util.http_build_query(pages[pi].options,pages[pi].route)+"\n"
str+='→';
pj++
if(pj>2) break;
}
wx.request({
url: 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=9094c8cc-ec7f-4221-b1d9-50e71e008aa9',
//url: 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=6093c5ae-d02a-4708-99a2-e80b82280fd0',//测试用
method: 'POST',
data: {
msgtype:'markdown',
markdown:{
content:
"**"+util.unixtoTime(new Date()/1000,'YYYY-MM-DD HH:II:SS')+"**\n"+
px+
"><font color=\"red\">"+openid+"</font>\n"+
">"+json.url+"\n\n"+
(typeof json.res == 'string'?json.res:JSON.stringify(json.res)).substr(0,500)+"\n\n"
},
},
header: {
'Content-Type': 'application/json'
},
})
},
}
\ No newline at end of file
... ...