Authored by ccbikai

api 支持签名

@@ -12,6 +12,7 @@ const _ = require('lodash'); @@ -12,6 +12,7 @@ const _ = require('lodash');
12 const log = require('./logger'); 12 const log = require('./logger');
13 const cache = require('./cache'); 13 const cache = require('./cache');
14 const Timer = require('./timer'); 14 const Timer = require('./timer');
  15 +const sign = require('./sign');
15 const config = require('../config/common'); 16 const config = require('../config/common');
16 const api = config.domains.api; 17 const api = config.domains.api;
17 const serviceApi = config.domains.service; 18 const serviceApi = config.domains.service;
@@ -131,7 +132,7 @@ class Http { @@ -131,7 +132,7 @@ class Http {
131 get(url, data, cacheOption) { 132 get(url, data, cacheOption) {
132 const options = { 133 const options = {
133 url: `${this.ApiUrl}${url}`, 134 url: `${this.ApiUrl}${url}`,
134 - qs: data, 135 + qs: data.client_secret ? data : sign.apiSign(data),
135 json: true, 136 json: true,
136 timeout: 3000 137 timeout: 3000
137 }; 138 };
@@ -152,7 +153,7 @@ class Http { @@ -152,7 +153,7 @@ class Http {
152 post(url, data) { 153 post(url, data) {
153 const options = { 154 const options = {
154 url: `${this.ApiUrl}${url}`, 155 url: `${this.ApiUrl}${url}`,
155 - form: data, 156 + form: data.client_secret ? data : sign.apiSign(data),
156 method: 'post', 157 method: 'post',
157 json: true, 158 json: true,
158 timeout: 3000 159 timeout: 3000