Showing
1 changed file
with
0 additions
and
7 deletions
@@ -59,8 +59,6 @@ let calcSigature = function(ticket_res, res) { // 计算signature | @@ -59,8 +59,6 @@ let calcSigature = function(ticket_res, res) { // 计算signature | ||
59 | let str = `jsapi_ticket=${ticket}&noncestr=${nonceStr}×tamp=${timestamp}&url=${url}`; | 59 | let str = `jsapi_ticket=${ticket}&noncestr=${nonceStr}×tamp=${timestamp}&url=${url}`; |
60 | let signature = sha1(str); | 60 | let signature = sha1(str); |
61 | 61 | ||
62 | - console.log(str + '&signature=' + signature); | ||
63 | - | ||
64 | let result = { | 62 | let result = { |
65 | appId: appID, | 63 | appId: appID, |
66 | nonceStr, | 64 | nonceStr, |
@@ -69,7 +67,6 @@ let calcSigature = function(ticket_res, res) { // 计算signature | @@ -69,7 +67,6 @@ let calcSigature = function(ticket_res, res) { // 计算signature | ||
69 | signature | 67 | signature |
70 | }; | 68 | }; |
71 | 69 | ||
72 | - // console.log('result', result); | ||
73 | return res.jsonp(result); | 70 | return res.jsonp(result); |
74 | }; | 71 | }; |
75 | 72 | ||
@@ -85,7 +82,6 @@ let getResult = function(wechat_res, req, res, next) { // 向微信接口获取a | @@ -85,7 +82,6 @@ let getResult = function(wechat_res, req, res, next) { // 向微信接口获取a | ||
85 | .then(result => { // 先获取accessToken | 82 | .then(result => { // 先获取accessToken |
86 | let access_token = result.access_token; | 83 | let access_token = result.access_token; |
87 | 84 | ||
88 | - console.log('token:', access_token); | ||
89 | return getTicket(req, access_token, next, appID, appSecret, mpPrefix) | 85 | return getTicket(req, access_token, next, appID, appSecret, mpPrefix) |
90 | .then(ticket_res => { // 通过accessToken获取ticket | 86 | .then(ticket_res => { // 通过accessToken获取ticket |
91 | if (ticket_res && ticket_res.ticket) { | 87 | if (ticket_res && ticket_res.ticket) { |
@@ -94,7 +90,6 @@ let getResult = function(wechat_res, req, res, next) { // 向微信接口获取a | @@ -94,7 +90,6 @@ let getResult = function(wechat_res, req, res, next) { // 向微信接口获取a | ||
94 | let create_time = moment().format('YYYY-MM-DD HH:mm:ss'); | 90 | let create_time = moment().format('YYYY-MM-DD HH:mm:ss'); |
95 | let expired_time = moment().add(expired, 'seconds').format('YYYY-MM-DD HH:mm:ss'); | 91 | let expired_time = moment().add(expired, 'seconds').format('YYYY-MM-DD HH:mm:ss'); |
96 | 92 | ||
97 | - // console.log('ticket_res:', ticket_res); | ||
98 | req.ctx(WechatModel). | 93 | req.ctx(WechatModel). |
99 | saveAccessKeys(access_token, access_ticket, create_time, expired_time, type) | 94 | saveAccessKeys(access_token, access_ticket, create_time, expired_time, type) |
100 | .then(() => { | 95 | .then(() => { |
@@ -132,14 +127,12 @@ const wechatShare = { | @@ -132,14 +127,12 @@ const wechatShare = { | ||
132 | 127 | ||
133 | req.ctx(WechatModel).getAccessKeys() | 128 | req.ctx(WechatModel).getAccessKeys() |
134 | .then(keys_res => { // 先查询数据库中是否有access_token并且未过期 | 129 | .then(keys_res => { // 先查询数据库中是否有access_token并且未过期 |
135 | - console.log(keys_res); | ||
136 | if (keys_res.length > 0) { | 130 | if (keys_res.length > 0) { |
137 | let access_token = keys_res[0].access_token; | 131 | let access_token = keys_res[0].access_token; |
138 | let access_ticket = keys_res[0].access_ticket; | 132 | let access_ticket = keys_res[0].access_ticket; |
139 | let expired = new Date(keys_res[0].access_expired).getTime(); | 133 | let expired = new Date(keys_res[0].access_expired).getTime(); |
140 | let now = Date.now(); | 134 | let now = Date.now(); |
141 | 135 | ||
142 | - console.log('data_time!', expired, now, keys_res[0].access_expired); | ||
143 | if (now > expired) { // 过期则去 取新的token与ticket 并且更新数据库 | 136 | if (now > expired) { // 过期则去 取新的token与ticket 并且更新数据库 |
144 | return Promise.reject({ | 137 | return Promise.reject({ |
145 | type: 'update' | 138 | type: 'update' |
-
Please register or login to post a comment