Merge branch 'develop' into feature/activity
Showing
1 changed file
with
13 additions
and
6 deletions
@@ -5,8 +5,7 @@ | @@ -5,8 +5,7 @@ | ||
5 | */ | 5 | */ |
6 | 6 | ||
7 | 'use strict'; | 7 | 'use strict'; |
8 | - | ||
9 | -const qs = require('querystring'); | 8 | +const _ = require('lodash'); |
10 | const md5 = require('md5'); | 9 | const md5 = require('md5'); |
11 | 10 | ||
12 | const privateKey = { | 11 | const privateKey = { |
@@ -39,15 +38,23 @@ const packageSort = argument => { | @@ -39,15 +38,23 @@ const packageSort = argument => { | ||
39 | * @return {string} 生成的签名字符串 | 38 | * @return {string} 生成的签名字符串 |
40 | */ | 39 | */ |
41 | const makeSign = argument => { | 40 | const makeSign = argument => { |
42 | - return md5(qs.stringify(argument)).toLowerCase(); | 41 | + let qs = []; |
42 | + | ||
43 | + _.forEach(argument, function(value, key) { | ||
44 | + qs.push(key + '=' + _.trim(value)); | ||
45 | + }); | ||
46 | + | ||
47 | + return md5(qs.join('&')).toLowerCase(); | ||
43 | }; | 48 | }; |
44 | 49 | ||
45 | // 生成API签名,调用后端接口的时候有私钥校验 | 50 | // 生成API签名,调用后端接口的时候有私钥校验 |
46 | exports.apiSign = (params) => { | 51 | exports.apiSign = (params) => { |
52 | + const clientType = params.client_type || 'web'; | ||
53 | + | ||
47 | /* eslint-disable */ | 54 | /* eslint-disable */ |
48 | - var sign = packageSort(Object.assign({ | ||
49 | - client_type: 'h5', | ||
50 | - private_key: privateKey.h5, | 55 | + let sign = packageSort(Object.assign({ |
56 | + client_type: clientType, | ||
57 | + private_key: privateKey[clientType], | ||
51 | app_version: '3.8.2', | 58 | app_version: '3.8.2', |
52 | os_version: 'yohobuy:h5', | 59 | os_version: 'yohobuy:h5', |
53 | screen_size: '720x1280', | 60 | screen_size: '720x1280', |
-
Please register or login to post a comment