// 开发者本机ip
const globalDevIp=’http://172.16.65.46:9191′
// 全局变量
pm.globals.set(“variable_key”, “variable_value”);
var moment=require(‘moment’);
var date=new Date();
date=moment(date).format(“YYYY-MM-DD HH:mm:ss”);
var transNo=moment(date).format(“YYYYMMDDHHmmss”);
pm.environment.set(“req_time”, date);
pm.environment.set(“transNo”, transNo);
pm.environment.set(‘globalDevIp’, globalDevIp)
// 注册全局方法
pm.globals.set(‘loadUtils’, function loadUtils() {
let utils={
// 获取个人编号-依赖于HT000-获取个人/企业数据(先执行HT000)
getPerson: (name)=> {
try {
let globalPerson=pm.environment.get(‘globalPerson’);
if (globalPerson && globalPerson.length==32) {
return globalPerson
}
let tempObj=pm.environment.get(‘psersonAccountMap’);
if (typeof tempObj==’object’) {
return tempObj[name || globalPerson].id
} else {
throw(new Error(‘在全局配置的HT000中,设置全局个人编号’))
}
} catch(e) {
const errorMsg=’获取全局个人编号失败,’ + (e.message || e)
console.error(errorMsg)
throw(new Error(errorMsg))
}
},
// 设置bizContent和sign签名
setBizContent: (biz_content)=> {
…
},
// 可视化结果
devRedirectUrl(url) {
if (!url && !url.includes(‘?’)) return
const ip=pm.environment.get(‘globalDevIp’)|| pm.environment.get(‘api_url_prefix’)
const temp=url.split(‘?’)[1].replace(‘×tamp’, ‘×tamp’)
const redirectUrlWebs=ip + ‘/#/webs?’+ temp
const redirectUrlApp=ip + ‘/#/app?’+ temp
const globalDevIp=’http://172.16.65.46:9191′
// 全局变量
pm.globals.set(“variable_key”, “variable_value”);
var moment=require(‘moment’);
var date=new Date();
date=moment(date).format(“YYYY-MM-DD HH:mm:ss”);
var transNo=moment(date).format(“YYYYMMDDHHmmss”);
pm.environment.set(“req_time”, date);
pm.environment.set(“transNo”, transNo);
pm.environment.set(‘globalDevIp’, globalDevIp)
// 注册全局方法
pm.globals.set(‘loadUtils’, function loadUtils() {
let utils={
// 获取个人编号-依赖于HT000-获取个人/企业数据(先执行HT000)
getPerson: (name)=> {
try {
let globalPerson=pm.environment.get(‘globalPerson’);
if (globalPerson && globalPerson.length==32) {
return globalPerson
}
let tempObj=pm.environment.get(‘psersonAccountMap’);
if (typeof tempObj==’object’) {
return tempObj[name || globalPerson].id
} else {
throw(new Error(‘在全局配置的HT000中,设置全局个人编号’))
}
} catch(e) {
const errorMsg=’获取全局个人编号失败,’ + (e.message || e)
console.error(errorMsg)
throw(new Error(errorMsg))
}
},
// 设置bizContent和sign签名
setBizContent: (biz_content)=> {
…
},
// 可视化结果
devRedirectUrl(url) {
if (!url && !url.includes(‘?’)) return
const ip=pm.environment.get(‘globalDevIp’)|| pm.environment.get(‘api_url_prefix’)
const temp=url.split(‘?’)[1].replace(‘×tamp’, ‘×tamp’)
const redirectUrlWebs=ip + ‘/#/webs?’+ temp
const redirectUrlApp=ip + ‘/#/app?’+ temp
pm.visualizer.set(`
<div style=”width: 100vw; height: 100vh; font-family: monospace; color:blue; word-bread: pre-wrap; “>
<textarea style=”width: 100vw; height: 30%; ” readonly>${redirectUrlWebs}</textarea>
<textarea style=”width: 100vw; height: 30%; ” readonly>${redirectUrlApp}</textarea>
</div>
`)
}
};
return utils;
} + ‘; loadUtils();’);
console.log(‘全局方法已经注册’)
© 版权声明
文章版权归作者所有,未经允许请勿转载。