Commit e80165e1 authored by coolfish's avatar coolfish

处理

parent accac142
...@@ -511,6 +511,11 @@ ...@@ -511,6 +511,11 @@
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=" "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg="
}, },
"charenc": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz",
"integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc="
},
"chokidar": { "chokidar": {
"version": "1.7.0", "version": "1.7.0",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz",
...@@ -581,6 +586,11 @@ ...@@ -581,6 +586,11 @@
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
}, },
"crypt": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz",
"integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs="
},
"cryptiles": { "cryptiles": {
"version": "2.0.5", "version": "2.0.5",
"resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz",
...@@ -2240,6 +2250,11 @@ ...@@ -2240,6 +2250,11 @@
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz",
"integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ="
}, },
"sha1": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/sha1/-/sha1-1.1.1.tgz",
"integrity": "sha1-rdqnqTFo85PxnrKxUJFhjicA+Eg="
},
"slash": { "slash": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz", "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz",
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
"morgan": "~1.8.1", "morgan": "~1.8.1",
"nodemon": "^1.11.0", "nodemon": "^1.11.0",
"request": "^2.81.0", "request": "^2.81.0",
"serve-favicon": "~2.4.2" "serve-favicon": "~2.4.2",
"sha1": "^1.1.1"
} }
} }
...@@ -4,7 +4,8 @@ var wx = require('./util/wx.js'); ...@@ -4,7 +4,8 @@ var wx = require('./util/wx.js');
/* GET home page. */ /* GET home page. */
router.get('/', function(req, res, next) { router.get('/', function(req, res, next) {
wx.getWXSign(function (err, data) { var clientUrl = 'http://' + req.hostname + req.url;
wx.getWXSign(clientUrl, function (err, data) {
res.render('index', { res.render('index', {
appid: data.appid || '', appid: data.appid || '',
timestamp: data.timestamp || '', timestamp: data.timestamp || '',
......
import request from 'request' import request from 'request'
import jsSHA from 'jssha' import sha1 from 'sha1'
const appid = 'wx66e59f0e402601f3'; const appid = 'wx66e59f0e402601f3';
const secret = '184897070ca93a0e563cb6b79962a98c'; const secret = '184897070ca93a0e563cb6b79962a98c';
...@@ -41,12 +41,7 @@ const sign = function (jsapi_ticket, url) { ...@@ -41,12 +41,7 @@ const sign = function (jsapi_ticket, url) {
timestamp: createTimestamp(), timestamp: createTimestamp(),
url: url url: url
}; };
var string = raw(ret); ret.signature = sha1(raw(ret));
console.log(string)
var shaObj = new jsSHA('SHA-1', 'TEXT');
shaObj.update(string);
ret.signature = shaObj.getHash('HEX');
console.log(ret)
return { return {
appid: appid, appid: appid,
nonceStr: ret.nonceStr, nonceStr: ret.nonceStr,
...@@ -82,7 +77,7 @@ const getJsapiTicket = function (callback) { ...@@ -82,7 +77,7 @@ const getJsapiTicket = function (callback) {
}); });
} }
const getWXSign = function (callback) { const getWXSign = function (clientUrl, callback) {
var nowTime = createTimestamp(); var nowTime = createTimestamp();
var result = {}; var result = {};
if (!wxStatus['timestamp'] || nowTime - wxStatus['timestamp'] > 7000) { if (!wxStatus['timestamp'] || nowTime - wxStatus['timestamp'] > 7000) {
...@@ -90,11 +85,11 @@ const getWXSign = function (callback) { ...@@ -90,11 +85,11 @@ const getWXSign = function (callback) {
if (err) { if (err) {
callback(err); callback(err);
} }
result = sign(wxStatus['ticket'], url); result = sign(wxStatus['ticket'], clientUrl);
callback(null, result); callback(null, result);
}); });
} else { } else {
result = sign(wxStatus['ticket'], url); result = sign(wxStatus['ticket'], clientUrl);
callback(null, result); callback(null, result);
} }
}; };
......
...@@ -182,7 +182,7 @@ ...@@ -182,7 +182,7 @@
title: '红椒易X小云蜂巢新媒体广告平台', title: '红椒易X小云蜂巢新媒体广告平台',
desc: '整合内容资源,提升广告主的品牌曝光能力,只需四步,即可完成广告投放需求。', desc: '整合内容资源,提升广告主的品牌曝光能力,只需四步,即可完成广告投放需求。',
link: 'http://hfads.apps.xiaoyun.com/', link: 'http://hfads.apps.xiaoyun.com/',
imgUrl: 'http://hfads.apps.xiaoyun.com/images/hjy@2x.png' imgUrl: 'http://hfads.apps.xiaoyun.com/images/hjy@wx.png'
}; };
wx.config({ wx.config({
debug: false, debug: false,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment