From c053cefe77797f5154b6db70f98e679f2ba13a38 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 6 Sep 2019 16:54:26 +0800 Subject: [PATCH 1/6] fix js sdk signature api --- app/controllers/wechats/js_sdk_signatures_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/wechats/js_sdk_signatures_controller.rb b/app/controllers/wechats/js_sdk_signatures_controller.rb index 6d7b3d87d..0b66cc263 100644 --- a/app/controllers/wechats/js_sdk_signatures_controller.rb +++ b/app/controllers/wechats/js_sdk_signatures_controller.rb @@ -1,6 +1,6 @@ class Wechats::JsSdkSignaturesController < ApplicationController def create - timestamp = (Time.now.to_f * 1000).to_i + timestamp = Time.now.to_i noncestr = ('A'..'z').to_a.sample(8).join signature = Util::Wechat.js_sdk_signature(params[:url], noncestr, timestamp) From 968f19e24cedcc4cbefa0d456e267feb4e143c7f Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 6 Sep 2019 17:02:18 +0800 Subject: [PATCH 2/6] fix js sdk signature api --- app/libs/util/wechat.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/libs/util/wechat.rb b/app/libs/util/wechat.rb index 069322f18..1b064ba94 100644 --- a/app/libs/util/wechat.rb +++ b/app/libs/util/wechat.rb @@ -7,7 +7,8 @@ module Util::Wechat attr_accessor :appid, :secret def js_sdk_signature(url, noncestr, timestamp) - str = { jsapi_ticket: jsapi_ticket, noncestr: noncestr, timestamp: timestamp, url: url }.to_query + data = { jsapi_ticket: jsapi_ticket, noncestr: noncestr, timestamp: timestamp, url: url } + str = data.map { |k, v| "#{k}=#{v}" }.join('&') Digest::SHA1.hexdigest(str) end From 0bb9e39e94f5a06b125645b41d31664dcc12a3f5 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Fri, 6 Sep 2019 17:08:37 +0800 Subject: [PATCH 3/6] window.encodeURIComponent --- public/react/src/App.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/App.js b/public/react/src/App.js index 3013eca7b..193b53e03 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -287,7 +287,7 @@ class App extends Component { const url = '/wechats/js_sdk_signature.json' const currentUrl = window.location.href.split('#')[0] axios.post(url, { - url: currentUrl, + url: window.encodeURIComponent(currentUrl), }).then((response) => { console.log('got res') const data = response.data; From 80a21594009c116b34f7721784cecb2182c9fd8d Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Fri, 6 Sep 2019 17:11:15 +0800 Subject: [PATCH 4/6] window.__testUrl --- public/react/src/App.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/App.js b/public/react/src/App.js index 193b53e03..e8184b7f2 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -287,7 +287,7 @@ class App extends Component { const url = '/wechats/js_sdk_signature.json' const currentUrl = window.location.href.split('#')[0] axios.post(url, { - url: window.encodeURIComponent(currentUrl), + url: window.__testUrl || window.encodeURIComponent(currentUrl), }).then((response) => { console.log('got res') const data = response.data; From d0a18456231ef54cf9165787ff7316c2e51b34d3 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Fri, 6 Sep 2019 17:22:02 +0800 Subject: [PATCH 5/6] all --- public/react/src/modules/courses/busyWork/commonWork.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/busyWork/commonWork.js b/public/react/src/modules/courses/busyWork/commonWork.js index 20343c870..f8042d476 100644 --- a/public/react/src/modules/courses/busyWork/commonWork.js +++ b/public/react/src/modules/courses/busyWork/commonWork.js @@ -227,7 +227,7 @@ class commonWork extends Component{ } clearSelection = () => { - this.setState({ checkBoxValues: [] }) + this.setState({ checkBoxValues: [], checkAll: false }) } // onSetPublic = () => { From b7cd926bdaf3a1ecd71e9371d95e1569265b7be6 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Fri, 6 Sep 2019 17:28:26 +0800 Subject: [PATCH 6/6] currentUrl --- public/react/src/App.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/public/react/src/App.js b/public/react/src/App.js index e8184b7f2..af9e33bd6 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -286,8 +286,9 @@ class App extends Component { const wx = window.wx const url = '/wechats/js_sdk_signature.json' const currentUrl = window.location.href.split('#')[0] + // window.encodeURIComponent() axios.post(url, { - url: window.__testUrl || window.encodeURIComponent(currentUrl), + url: window.__testUrl || currentUrl, }).then((response) => { console.log('got res') const data = response.data; @@ -295,7 +296,7 @@ class App extends Component { debug: false, appId: data.appid, timestamp: data.timestamp, - nonceStr: data.nonceStr, + nonceStr: data.noncestr, signature: data.signature, jsApiList: [ 'onMenuShareTimeline',//