diff --git a/utils/accessLog.js b/utils/accessLog.js index 82515c4..6074f26 100644 --- a/utils/accessLog.js +++ b/utils/accessLog.js @@ -15,14 +15,16 @@ export function saveAccessLog(to, f) { setNodeId(nodeId) } let flag = getApp().globalData.terminal + "_" + f; - let data = { - flag: flag, - fullPath: to.url.split("?")[0], - allPath: to.url, - menuName: to.tabBarText, - userId: store.state.user.userInfo.userId, - userName: store.state.user.userInfo.userName, - nodeId: nodeId - } - diyApi("/system/log/insSysAccessLog", data); + let data = { + platform: getApp().globalData.appId, + terminal: getApp().globalData.terminal, + nodeId: nodeId, + flag: getApp().globalData.terminal + "_" + f, + fullPath: to.url.split("?")[0], + allPath: to.url, + menuName: to.tabBarText, + userId: store.state.user.userInfo.userId, + userName: store.state.user.userInfo.userName + } + diyApi("/system/log/insSysAccessLog", data); } diff --git a/utils/request.js b/utils/request.js index 37bf244..733c528 100644 --- a/utils/request.js +++ b/utils/request.js @@ -1,5 +1,7 @@ import store from '@/store' import { getToken } from '@/utils/token' +import { setNodeId, getNodeId } from '@/utils/nodeId' +import { getLongRandom } from '@/utils/nineTool'; import errorCode from '@/utils/errorCode' import { getSessionCache, setSessionCache } from '@/utils/cache' import { toast, showConfirm, tansParams } from '@/utils/requestTool' @@ -16,6 +18,17 @@ const request = config => { if (getToken() && !isToken) { config.header['Authorization'] = 'Vrapile ' + getToken() } + + // 节点 + let nodeId = getNodeId(); + if(!nodeId){ + nodeId = getLongRandom(24); + setNodeId(nodeId); + } + config.header["platform"] = getApp().globalData.appId; + config.header["terminal"] = getApp().globalData.terminal; + config.header["nodeId"] = nodeId; + // get请求映射params参数 if (config.params) { let url = config.url + '?' + tansParams(config.params) @@ -54,9 +67,14 @@ const request = config => { header: config.header, dataType: 'json' }).then(res => { + // let [error, res] = response const code = res.data.code || res.data.status || 200 const msg = errorCode[code] || res.data.msg || errorCode['default'] - + // if (code != 200) { + // toast('后端接口连接异常') + // reject('后端接口连接异常') + // return + // } if (code === 401) { // 密码登录的,实现自动重新登录 let loginInfo = store.state.user.loginInfo; @@ -80,10 +98,10 @@ const request = config => { } } else if (code === 500) { toast(msg) - reject('500') + reject(res) } else if (code !== 200) { toast(msg) - reject(code) + reject(res) } resolve(res.data) }).catch(error => {