...
|
...
|
@@ -51,9 +51,11 @@ const handleParam = (params) => { |
|
|
const publicParams = _publicParams();
|
|
|
let newParams = {
|
|
|
...params,
|
|
|
session_key,
|
|
|
...publicParams,
|
|
|
};
|
|
|
if (session_key) {
|
|
|
newParams.session_key = session_key;
|
|
|
}
|
|
|
return newParams;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -61,10 +63,12 @@ const getUdid = (params) => { |
|
|
const globalData = getGlobalData();
|
|
|
if (params && !params.hasOwnProperty('udid')) {
|
|
|
let udid = globalData.udid ? globalData.udid : "";
|
|
|
if (udid.length == 0) {
|
|
|
if (udid.length === 0) {
|
|
|
udid = getYHStorageSync('udid', 'request');
|
|
|
}
|
|
|
params.udid = udid;
|
|
|
if (udid.length !== 0) {
|
|
|
params.udid = udid;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -73,7 +77,9 @@ const getUid = (params) => { |
|
|
if (params && !params.hasOwnProperty('uid')) {
|
|
|
// 判断 globalData 是否包含 uid
|
|
|
let uid = globalData.userInfo && globalData.userInfo.uid ? globalData.userInfo.uid : 0;
|
|
|
params.uid = uid;
|
|
|
if (uid !== 0) {
|
|
|
params.uid = uid;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -103,6 +109,7 @@ const _signParam = (params, encode = false) => { |
|
|
const _signResultParams = (params, encode = false) => {
|
|
|
let allParams = trimObject(params); // 去除首尾空格
|
|
|
let paramsPair = queryString.stringify(allParams, { encode: false });
|
|
|
console.log(paramsPair);
|
|
|
let client_secret = MD5(paramsPair);
|
|
|
delete allParams.private_key;
|
|
|
const resultParams = objectAssign(allParams, { client_secret });
|
...
|
...
|
@@ -119,9 +126,10 @@ const handleHeader = (options, newParams) => { |
|
|
}
|
|
|
let param = _signParam(newParams, false);
|
|
|
let resultString = crypto.HMAC(crypto.SHA256, param, p2SecretKey, "")
|
|
|
const session_key = newParams.session_key ? newParams.session_key : '';
|
|
|
let header = {
|
|
|
'x-yoho-verify': resultString,
|
|
|
'Cookies': 'JSESSIONID=' + newParams.session_key,
|
|
|
'Cookies': 'JSESSIONID=' + session_key,
|
|
|
}
|
|
|
return header;
|
|
|
}
|
...
|
...
|
|