4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'app/helpers/wechat/application_helper.rb', line 4
def wechat_raw_config_js(debug: false, apis: [])
page_url = controller.request.original_url
page_url.delete_suffix!('#')
js_hash = Wechat::Signature.signature(current_wechat_app.jsapi_ticket, page_url)
logger.debug "\e[35m Current page is: #{page_url}, Hash: #{js_hash.inspect} \e[0m"
<<-WECHAT_CONFIG_JS
wx.config({
debug: #{debug},
appId: '#{current_wechat_app.appid}',
timestamp: '#{js_hash[:timestamp]}',
nonceStr: '#{js_hash[:noncestr]}',
signature: '#{js_hash[:signature]}',
jsApiList: ['#{apis.join("','")}'],
openTagList: ['wx-open-subscribe']
})
WECHAT_CONFIG_JS
rescue => e
logger.debug e.message
end
|