|
发表于 2020-2-25 13:13:54
|
显示全部楼层
河北省保定市
GetSignature: function (url,param) {
/// <summary>获取接口签名</summary>
url = Cmn.Func.Trim(url);
var _verif*Fg = CmnAjax.Func.GetVerif*Fg(url);
if (_verif*Fg["CacheToken"] === "" || _verif*Fg["CacheToken"] === undefined) {
_verif*Fg["CacheToken"] = "";
Cmn.Log("在获取签名时,Tk为空。");
}
var _tmp = [],
_paramString = "",
_tmpStr = "",
_lcKeyJson = []; //小写主键的参数json
var _urlParamList = Cmn.Func.GetParamListFromurl(url);
var _json = {};
var _tmpKey;
//json合并原先合并方式会把undefined的剔除掉,所以改写了
//$.extend(_json, param, _urlParamList);
for (_tmpKey in param) {
if (param[_tmpKey] === undefined || param[_tmpKey] === null) {
param[_tmpKey] = "";
}
_json[_tmpKey] = param[_tmpKey];
}
for (_tmpKey in _urlParamList) {
if (_json[_tmpKey] !== undefined) { Cmn.Log("接口验证时存在重复的参数:" + _tmpKey + ",请去掉重复参数! 接口地址:" + url);}
_json[_tmpKey] = _urlParamList[_tmpKey];
}
//将json的参数加到数组中
for (_tmpKey in _json) {
if (_tmpKey !== "Cg_sg") {
_tmpStr = _tmpKey.toLocaleLowerCase();
_tmp.push(_tmpStr);
_lcKeyJson[_tmpStr] = _json[_tmpKey];
//if (_lcKeyJson[_tmpStr] === undefined) { _lcKeyJson[_tmpStr] = _json[_tmpKey]; }
//else { Cmn.Log("接口验证时存在重复的键:" + _tmpStr + " 接口地址:" + url); }
}
}
_tmp.sort();
for (var _i = 0; _i < _tmp.length; _i++) {
var _tmpVal = _lcKeyJson[_tmp[_i]];
_paramString += "&" + _tmp[_i] + "=" + _tmpVal;
}
_paramString = _paramString.substring(1, _paramString.length) + CmnAjax*Fg.ItfTokenKey + _verif*Fg["CacheToken"];
_paramString = $.md5(_paramString);
return _paramString;
} |
|