var ip = '10.9.39.5' // 新版本查询 function generateJson(method,params={},type='GET') { const data = { 'FWQQ_BWBH':getBWBH(), //报文编号 'BWLYIPDZ':getIP(), //12位IP 'BWLYDKH':'8083', //端口? 'FWQQZ_ZCXX':'A00111000026000004818', 'FWBS':'S00101100002600052004', 'FFBS':'FUN001', 'FWQQ_RQSJ':getTime(), 'FWQQ_NR':{ method:'appprepositionInvoke', params:{ method:method, type:type, token: '', params: params }}, 'XXCZRY_XM':'张森', 'XXCZRY_GMSFHM':'110226198909261410', 'XXCZRY_GAJGJGDM':'', 'FWQQSB_BH':'', 'FWQQ_SJSJLX':'service_request', 'YYSBS':'lt' } console.log(JSON.stringify(data)) } function getBWBH(){ let head = "SR" let ip = changeIP('10.9.39.5'); let mdate = new Date(); let year = mdate.getFullYear(); let month = mdate.getMonth()+1; let day = mdate.getDate(); let hour = mdate.getHours(); //获取当前小时数(0-23) let minutes = mdate.getMinutes(); //获取当前分钟数(0-59) let seconds = mdate.getSeconds(); //获取当前秒数(0-59) let mseconds = mdate.getMilliseconds(); //获取当前毫秒数(0~999) let end = Math.floor(Math.random()*(9999-1000))+1000;//生成随机4位流水号 let result = head+ip +year +formatStr(month,2)+formatStr(day,2) +formatStr(hour,2)+formatStr(minutes,2)+formatStr(seconds,2) +formatStr(mseconds,3)+end; return result; } function getIP(){ let ip = changeIP('10.9.39.5'); return ip; } function getTime(){ let mdate = new Date(); let year = mdate.getFullYear(); let month = mdate.getMonth()+1; let day = mdate.getDate(); let hour = mdate.getHours(); //获取当前小时数(0-23) let minutes = mdate.getMinutes(); //获取当前分钟数(0-59) let seconds = mdate.getSeconds(); //获取当前秒数(0-59) let result = ""+year +formatStr(month,2)+formatStr(day,2) +formatStr(hour,2)+formatStr(minutes,2)+formatStr(seconds,2) return result } function changeIP(ip){ const ip_ds = ip.split(".") let result = "" for(let item of ip_ds){ item = "000"+item result+=item.substr(-3) } return result; } function formatStr(str,length){ str = "000"+str return str.substr(0-length) } generateJson('app/tokenByCard',{card:'110226198909261410'})