let?timestamp?=?(new?Date()).getTime().toString();?
timestamp?=?timestamp.substr(0,13);
//设置集合的全局变量
pm.collectionVariables.set("timestamp",?timestamp);
var?appkey='AKNOJ5NA2JTR6WGV7';
pm.collectionVariables.set("appkey",appkey);
?
function generateUUID() {
? return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
? ? var r = Math.random() * 16 | 0,
? ? ? ? v = c === 'x' ? r : (r & 0x3 | 0x8);
? ? return v.toString(16);
? });
}
console.log(generateUUID());
var nonce = generateUUID();
pm.collectionVariables.set("nonce",generateUUID());
const requestBody = pm.request.body.raw;//获取请求体
const newRequestBody = requestBody.replace(/\s+/g, '');//将请求体的空格和换行删除
var tiantian='ebbcoff02ffbfqkxkxhof8btzufa1uts';
var?signStr?='appkey'+appkey +'nonce'+nonce+'timestamp'+timestamp+newRequestBody+tiantian;
console.log("signStr?:"+signStr);
?
//md5加密
var?signature=CryptoJS.MD5(signStr).toString().toUpperCase();
console.log("sign:"+signature);
pm.collectionVariables.set("sign",?signature);