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 @@ -8,6 +8,7 @@ const api_timeout = 2000; //接口超时时间,默认2s
8 //引入接口映射关系表 8 //引入接口映射关系表
9 import api from './api.url' 9 import api from './api.url'
10 import uri_dc from './uri' 10 import uri_dc from './uri'
  11 +import bot from './rebot'
11 12
12 const server_host = uri_dc.HOST__LINE; 13 const server_host = uri_dc.HOST__LINE;
13 14
@@ -74,9 +75,9 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr @@ -74,9 +75,9 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr
74 let param = ""; 75 let param = "";
75 for (let key in data) { 76 for (let key in data) {
76 let val = data[key]; 77 let val = data[key];
77 - if (val !== "" && val !== null) {  
78 - param += '&' + key + '=' + val  
79 - } 78 + //if (val !== "" && val !== null) {
  79 + param += '&' + key + '=' + val
  80 + //}
80 } 81 }
81 let cache_key = act; 82 let cache_key = act;
82 if (param) { 83 if (param) {
@@ -146,8 +147,9 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr @@ -146,8 +147,9 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr
146 'content-type': 'application/x-www-form-urlencoded' 147 'content-type': 'application/x-www-form-urlencoded'
147 }, 148 },
148 success: function (res) { 149 success: function (res) {
149 - console.log('request.api[' + (new Date() - stime) + 'ms]==>', host + cache_key + ('&formids=' + formids.toString()) + '\nrequest.success', res.data); 150 + console.log('request.api[' + (new Date() - stime) + 'ms]==>', host + cache_key + '\nrequest.success', res.data);
150 // return; 151 // return;
  152 + //bot.msg({url: host + cache_key, res: res.data})
151 if (res.data) { 153 if (res.data) {
152 if (cachetime != 0 && res.data.ret == 200) { 154 if (cachetime != 0 && res.data.ret == 200) {
153 cache(cache_key, res.data, cachetime);//.then().catch(); 155 cache(cache_key, res.data, cachetime);//.then().catch();
@@ -157,6 +159,7 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr @@ -157,6 +159,7 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr
157 res.data.msg = res.data.msg.replace('非法请求:', ''); 159 res.data.msg = res.data.msg.replace('非法请求:', '');
158 } catch (e) { 160 } catch (e) {
159 console.log('res-fail', res, e); 161 console.log('res-fail', res, e);
  162 + bot.msg({url: host + cache_key, res: res.data})
160 if (wx.getRealtimeLogManager) { 163 if (wx.getRealtimeLogManager) {
161 const logger = wx.getRealtimeLogManager() 164 const logger = wx.getRealtimeLogManager()
162 logger.error('接口错误', {url: host + cache_key, res: res.data}) 165 logger.error('接口错误', {url: host + cache_key, res: res.data})
@@ -164,6 +167,7 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr @@ -164,6 +167,7 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr
164 } 167 }
165 } 168 }
166 } else { 169 } else {
  170 + bot.msg({url: host + cache_key, res: res})
167 if (wx.getRealtimeLogManager) { 171 if (wx.getRealtimeLogManager) {
168 const logger = wx.getRealtimeLogManager() 172 const logger = wx.getRealtimeLogManager()
169 logger.error('接口错误', {url: host + cache_key, res: res}) 173 logger.error('接口错误', {url: host + cache_key, res: res})
@@ -182,6 +186,7 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr @@ -182,6 +186,7 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr
182 // }); 186 // });
183 //query.show(); 187 //query.show();
184 //console.log('net',query); 188 //console.log('net',query);
  189 + bot.msg({url: host + cache_key, res: res})
185 if (wx.getRealtimeLogManager) { 190 if (wx.getRealtimeLogManager) {
186 const logger = wx.getRealtimeLogManager() 191 const logger = wx.getRealtimeLogManager()
187 logger.error('调用失败', {url: host + cache_key, res: res}) 192 logger.error('调用失败', {url: host + cache_key, res: res})
  1 +//https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=9094c8cc-ec7f-4221-b1d9-50e71e008aa9
  2 +import util from './util'
  3 +export default {
  4 + async msg (json){
  5 + let openid=await getApp().getOpenid()
  6 + if(!openid) return;
  7 + let pages = getCurrentPages();
  8 + //let p = pages[pages.length - 1];
  9 + let px='',pl=pages.length,str=''
  10 + for(let pi=pl-1,pj=0;pi>=0;pi--){
  11 + px+=">"+str+util.http_build_query(pages[pi].options,pages[pi].route)+"\n"
  12 + str+='→';
  13 + pj++
  14 + if(pj>2) break;
  15 + }
  16 + wx.request({
  17 + url: 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=9094c8cc-ec7f-4221-b1d9-50e71e008aa9',
  18 + //url: 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=6093c5ae-d02a-4708-99a2-e80b82280fd0',//测试用
  19 + method: 'POST',
  20 + data: {
  21 + msgtype:'markdown',
  22 + markdown:{
  23 + content:
  24 + "**"+util.unixtoTime(new Date()/1000,'YYYY-MM-DD HH:II:SS')+"**\n"+
  25 + px+
  26 + "><font color=\"red\">"+openid+"</font>\n"+
  27 + ">"+json.url+"\n\n"+
  28 + (typeof json.res == 'string'?json.res:JSON.stringify(json.res)).substr(0,500)+"\n\n"
  29 + },
  30 + },
  31 + header: {
  32 + 'Content-Type': 'application/json'
  33 + },
  34 + })
  35 + },
  36 +}