Authored by 邱骏

修改appsecret

@@ -32,7 +32,9 @@ let getAccessToken = function(appId, secret, prefix) { // 获取access_token @@ -32,7 +32,9 @@ let getAccessToken = function(appId, secret, prefix) { // 获取access_token
32 }, 32 },
33 json: true 33 json: true
34 }).then(res => { 34 }).then(res => {
  35 + // console.log('getAccessToken=' + JSON.stringify(res));
35 return res; 36 return res;
  37 +
36 }); 38 });
37 39
38 }; 40 };
@@ -46,11 +48,12 @@ let getTicket = function(accessToken, appId, secret, prefix) { // 获取ticket @@ -46,11 +48,12 @@ let getTicket = function(accessToken, appId, secret, prefix) { // 获取ticket
46 }, 48 },
47 json: true 49 json: true
48 }).then(res => { 50 }).then(res => {
  51 + // console.log('getTicket=' + JSON.stringify(res));
49 return res; 52 return res;
50 }); 53 });
51 }; 54 };
52 55
53 -let calcSigature = function(ticket_res) { // 计算signature 56 +let calcSigature = function (ticket_res) { // 计算signature
54 let appID = ticket_res.appID; 57 let appID = ticket_res.appID;
55 let ticket = ticket_res.access_ticket; 58 let ticket = ticket_res.access_ticket;
56 let nonceStr = Math.random().toString(36).substr(2, 15); 59 let nonceStr = Math.random().toString(36).substr(2, 15);
@@ -59,6 +62,7 @@ let calcSigature = function(ticket_res) { // 计算signature @@ -59,6 +62,7 @@ let calcSigature = function(ticket_res) { // 计算signature
59 let str = `jsapi_ticket=${ticket}&noncestr=${nonceStr}&timestamp=${timestamp}&url=${url}`; 62 let str = `jsapi_ticket=${ticket}&noncestr=${nonceStr}&timestamp=${timestamp}&url=${url}`;
60 let signature = sha1(str); 63 let signature = sha1(str);
61 64
  65 + // console.log({appID, ticket, nonceStr, timestamp, url, str, signature});
62 return { 66 return {
63 appId: appID, 67 appId: appID,
64 nonceStr, 68 nonceStr,
@@ -66,6 +70,8 @@ let calcSigature = function(ticket_res) { // 计算signature @@ -66,6 +70,8 @@ let calcSigature = function(ticket_res) { // 计算signature
66 url, 70 url,
67 signature 71 signature
68 }; 72 };
  73 +
  74 +
69 }; 75 };
70 76
71 let getResult = function(wechat_res) { // 向微信接口获取access_token及ticket并计算signature 77 let getResult = function(wechat_res) { // 向微信接口获取access_token及ticket并计算signature
@@ -80,6 +86,7 @@ let getResult = function(wechat_res) { // 向微信接口获取access_token及ti @@ -80,6 +86,7 @@ let getResult = function(wechat_res) { // 向微信接口获取access_token及ti
80 86
81 return getTicket(access_token, appID, appSecret, mpPrefix) 87 return getTicket(access_token, appID, appSecret, mpPrefix)
82 .then(ticket_res => { // 通过accessToken获取ticket 88 .then(ticket_res => { // 通过accessToken获取ticket
  89 + // console.log('getResult=' + JSON.stringify(Object.assign({access_token: access_token, appID: appID}, ticket_res)));
83 return Object.assign({ 90 return Object.assign({
84 access_token: access_token, 91 access_token: access_token,
85 appID: appID 92 appID: appID
@@ -130,8 +137,7 @@ const wechatShare = { @@ -130,8 +137,7 @@ const wechatShare = {
130 let expired_time = moment().add(expired, 'seconds').format('YYYY-MM-DD HH:mm:ss') || ''; 137 let expired_time = moment().add(expired, 'seconds').format('YYYY-MM-DD HH:mm:ss') || '';
131 138
132 // 获取到ticket信息之后把相关字段保存到数据库中 139 // 获取到ticket信息之后把相关字段保存到数据库中
133 - return req.ctx(WechatModel).  
134 - saveAccessKeys(access_token, access_ticket, create_time, expired_time, keys_res.type) 140 + return req.ctx(WechatModel).saveAccessKeys(access_token, access_ticket, create_time, expired_time, keys_res.type)
135 .then(() => { 141 .then(() => {
136 return { 142 return {
137 appID: appId, 143 appID: appId,
@@ -85,7 +85,7 @@ module.exports = { @@ -85,7 +85,7 @@ module.exports = {
85 yohoSecret: '3bd815162342d9733f06ab6811082c64', 85 yohoSecret: '3bd815162342d9733f06ab6811082c64',
86 wechat: { 86 wechat: {
87 appID: 'wx1fe49f08f41b6c26', 87 appID: 'wx1fe49f08f41b6c26',
88 - appSecret: '5670f62abcebcd8d321615b46bd19ef4', 88 + appSecret: '1360c4a89275e1a4a4bbc8f6c5e44587',
89 token: 'weixin', 89 token: 'weixin',
90 prefix: 'https://api.weixin.qq.com/cgi-bin/', 90 prefix: 'https://api.weixin.qq.com/cgi-bin/',
91 mpPrefix: 'https://api.weixin.qq.com/cgi-bin/' 91 mpPrefix: 'https://api.weixin.qq.com/cgi-bin/'
No preview for this file type