@ -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)
@ -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
@ -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: 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',//
@ -227,7 +227,7 @@ class commonWork extends Component{
}
clearSelection = () => {
this.setState({ checkBoxValues: [] })
this.setState({ checkBoxValues: [], checkAll: false })
//
onSetPublic = () => {