Commit 993ee502b9df52a39166cbbda656eefad7269951

Authored by vking
1 parent ab15ff41

sign

... ... @@ -4,6 +4,11 @@
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"js-sha1": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/js-sha1/-/js-sha1-0.6.0.tgz",
"integrity": "sha512-01gwBFreYydzmU9BmZxpVk6svJJHrVxEN3IOiGl6VO93bVKYETJ0sIth6DASI6mIFdt7NmfX9UiByRzsYHGU9w=="
},
"mta-wechat-analysis": {
"version": "1.3.9",
"resolved": "https://registry.npmjs.org/mta-wechat-analysis/-/mta-wechat-analysis-1.3.9.tgz",
... ...
... ... @@ -13,6 +13,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"js-sha1": "^0.6.0",
"mta-wechat-analysis": "^1.3.7"
}
}
... ...
... ... @@ -9,6 +9,7 @@ const api_timeout = 2000; //接口超时时间,默认2s
import api from './api.url'
import uri_dc from './uri'
import bot from './rebot'
const sha1=require('js-sha1');
const server_host = uri_dc.HOST__LINE;
... ... @@ -136,7 +137,7 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr
}
let stime = new Date();
wx.request({
url: host + act,
url: host + act+'&'+getSignQuery(),
method: 'POST',
data: data,
header: {
... ... @@ -297,4 +298,18 @@ function msgSecCheck(host,params){
})
})
}
function getSignQuery(){
let token='HY6FX#X5IXF%TRYnb9Yzfe9qgtSBBYib';
let timestamp=parseInt(new Date()/1000).toString()
let nonce=Math.random().toString(36).substr(2);
nonce+=Math.random().toString(36).substr(2)
nonce+=Math.random().toString(36).substr(2);
nonce=nonce.toUpperCase()
let singArr=[token,nonce,timestamp].sort()
console.log('singStr',singArr)
let singStr=singArr.join('')
console.log('singStr',singStr)
let sign=sha1(singStr)
return `timestamp=${timestamp}&nonce=${nonce}&sign=${sign}`
}
export default __api();
\ No newline at end of file
... ...