Commit 993ee502b9df52a39166cbbda656eefad7269951

Authored by vking
1 parent ab15ff41

sign

@@ -4,6 +4,11 @@ @@ -4,6 +4,11 @@
4 "lockfileVersion": 1, 4 "lockfileVersion": 1,
5 "requires": true, 5 "requires": true,
6 "dependencies": { 6 "dependencies": {
  7 + "js-sha1": {
  8 + "version": "0.6.0",
  9 + "resolved": "https://registry.npmjs.org/js-sha1/-/js-sha1-0.6.0.tgz",
  10 + "integrity": "sha512-01gwBFreYydzmU9BmZxpVk6svJJHrVxEN3IOiGl6VO93bVKYETJ0sIth6DASI6mIFdt7NmfX9UiByRzsYHGU9w=="
  11 + },
7 "mta-wechat-analysis": { 12 "mta-wechat-analysis": {
8 "version": "1.3.9", 13 "version": "1.3.9",
9 "resolved": "https://registry.npmjs.org/mta-wechat-analysis/-/mta-wechat-analysis-1.3.9.tgz", 14 "resolved": "https://registry.npmjs.org/mta-wechat-analysis/-/mta-wechat-analysis-1.3.9.tgz",
@@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
13 "author": "", 13 "author": "",
14 "license": "ISC", 14 "license": "ISC",
15 "dependencies": { 15 "dependencies": {
  16 + "js-sha1": "^0.6.0",
16 "mta-wechat-analysis": "^1.3.7" 17 "mta-wechat-analysis": "^1.3.7"
17 } 18 }
18 } 19 }
@@ -9,6 +9,7 @@ const api_timeout = 2000; //接口超时时间,默认2s @@ -9,6 +9,7 @@ const api_timeout = 2000; //接口超时时间,默认2s
9 import api from './api.url' 9 import api from './api.url'
10 import uri_dc from './uri' 10 import uri_dc from './uri'
11 import bot from './rebot' 11 import bot from './rebot'
  12 +const sha1=require('js-sha1');
12 13
13 const server_host = uri_dc.HOST__LINE; 14 const server_host = uri_dc.HOST__LINE;
14 15
@@ -136,7 +137,7 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr @@ -136,7 +137,7 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr
136 } 137 }
137 let stime = new Date(); 138 let stime = new Date();
138 wx.request({ 139 wx.request({
139 - url: host + act, 140 + url: host + act+'&'+getSignQuery(),
140 method: 'POST', 141 method: 'POST',
141 data: data, 142 data: data,
142 header: { 143 header: {
@@ -297,4 +298,18 @@ function msgSecCheck(host,params){ @@ -297,4 +298,18 @@ function msgSecCheck(host,params){
297 }) 298 })
298 }) 299 })
299 } 300 }
  301 +function getSignQuery(){
  302 + let token='HY6FX#X5IXF%TRYnb9Yzfe9qgtSBBYib';
  303 + let timestamp=parseInt(new Date()/1000).toString()
  304 + let nonce=Math.random().toString(36).substr(2);
  305 + nonce+=Math.random().toString(36).substr(2)
  306 + nonce+=Math.random().toString(36).substr(2);
  307 + nonce=nonce.toUpperCase()
  308 + let singArr=[token,nonce,timestamp].sort()
  309 + console.log('singStr',singArr)
  310 + let singStr=singArr.join('')
  311 + console.log('singStr',singStr)
  312 + let sign=sha1(singStr)
  313 + return `timestamp=${timestamp}&nonce=${nonce}&sign=${sign}`
  314 +}
300 export default __api(); 315 export default __api();