Authored by baoss

修复url公共参数格式问题

@@ -61,9 +61,7 @@ const sign = async(data, encode = false) => { @@ -61,9 +61,7 @@ const sign = async(data, encode = false) => {
61 return ''; 61 return '';
62 } 62 }
63 63
64 - data = stringify(data, {  
65 - encode: encode  
66 - }); 64 + data = stringifyParam(data, encode)
67 65
68 return HmacSHA256(data, verifyKey).toString(); 66 return HmacSHA256(data, verifyKey).toString();
69 67
@@ -73,6 +71,12 @@ const sign = async(data, encode = false) => { @@ -73,6 +71,12 @@ const sign = async(data, encode = false) => {
73 // verifyKey = 'bc330db80e80fa1f0204e7bbf83063f2' 71 // verifyKey = 'bc330db80e80fa1f0204e7bbf83063f2'
74 // } 72 // }
75 } 73 }
  74 +const stringifyParam = (data, encode = false) => {
  75 + data = stringify(data, {
  76 + encode: encode
  77 + });
  78 + return data
  79 +}
76 export const computeSecret = (data, url, encode = false) => { 80 export const computeSecret = (data, url, encode = false) => {
77 let newData = { 81 let newData = {
78 private_key: dataUtils.getConfig().apiParams.private_key 82 private_key: dataUtils.getConfig().apiParams.private_key
@@ -89,7 +93,7 @@ export const computeSecret = (data, url, encode = false) => { @@ -89,7 +93,7 @@ export const computeSecret = (data, url, encode = false) => {
89 93
90 if (url) { 94 if (url) {
91 let body = createBody(data); 95 let body = createBody(data);
92 - let queryStrigPair = sign(body, true); 96 + let queryStrigPair = stringifyParam(body, true);;
93 97
94 url = url.indexOf('?') >= 0 ? url + '&' + queryStrigPair : url + '?' + queryStrigPair; 98 url = url.indexOf('?') >= 0 ? url + '&' + queryStrigPair : url + '?' + queryStrigPair;
95 newData.url = url 99 newData.url = url