eric_weixin 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +6 -1
- data/app/assets/javascripts/eric_weixin/application.js +1 -0
- data/app/assets/javascripts/eric_weixin/cms/base.js +6 -5
- data/app/controllers/eric_weixin/application_controller.rb +98 -0
- data/app/controllers/eric_weixin/cms/base_controller.rb +1 -1
- data/app/controllers/eric_weixin/cms/weixin/media_articles_controller.rb +73 -0
- data/app/controllers/eric_weixin/cms/weixin/media_news_controller.rb +175 -0
- data/app/controllers/eric_weixin/cms/weixin/media_resources_controller.rb +68 -0
- data/app/controllers/eric_weixin/wz/pays_controller.rb +15 -0
- data/app/controllers/eric_weixin/wz/weixin_controller.rb +2 -2
- data/app/helpers/eric_weixin/application_helper.rb +6 -0
- data/app/helpers/eric_weixin/cms/weixin/public_accounts_helper.rb +3 -3
- data/app/models/eric_weixin/access_token.rb +1 -0
- data/app/models/eric_weixin/media_article.rb +53 -0
- data/app/models/eric_weixin/media_article_news.rb +6 -0
- data/app/models/eric_weixin/media_news.rb +216 -0
- data/app/models/eric_weixin/media_resource.rb +172 -0
- data/app/models/eric_weixin/public_account.rb +9 -0
- data/app/views/eric_weixin/cms/weixin/media_articles/_media_article.html.erb +131 -0
- data/app/views/eric_weixin/cms/weixin/media_articles/_select_pic.html.erb +78 -0
- data/app/views/eric_weixin/cms/weixin/media_articles/edit.html.erb +4 -0
- data/app/views/eric_weixin/cms/weixin/media_articles/index.html.erb +31 -0
- data/app/views/eric_weixin/cms/weixin/media_articles/new.html.erb +15 -0
- data/app/views/eric_weixin/cms/weixin/media_news/_select_article.html.erb +90 -0
- data/app/views/eric_weixin/cms/weixin/media_news/_select_user.html.erb +8 -0
- data/app/views/eric_weixin/cms/weixin/media_news/_will_send_article.html.erb +53 -0
- data/app/views/eric_weixin/cms/weixin/media_news/new.html.erb +284 -0
- data/app/views/eric_weixin/cms/weixin/media_resources/_media_resource.html.erb +62 -0
- data/app/views/eric_weixin/cms/weixin/media_resources/edit.html.erb +20 -0
- data/app/views/eric_weixin/cms/weixin/media_resources/index.html.erb +49 -0
- data/app/views/eric_weixin/cms/weixin/media_resources/new.html.erb +4 -0
- data/app/views/eric_weixin/cms/weixin/url_encodes/_new.html.erb +6 -6
- data/app/views/eric_weixin/wz/pays/pay_fail.html.erb +2 -0
- data/app/views/eric_weixin/wz/pays/pay_ok.html.erb +2 -0
- data/app/views/eric_weixin/wz/pays/prepay.html.erb +49 -0
- data/app/views/layouts/eric_weixin/cms/base.html.erb +1 -1
- data/app/views/layouts/eric_weixin/wz/pays.html.erb +11 -0
- data/config/initializers/assets.rb +1 -1
- data/config/initializers/inflections.rb +19 -0
- data/config/routes.rb +20 -6
- data/config/tinymce.yml +11 -0
- data/db/migrate/20150813080541_add_mch_id_to_weixin_public_accounts.rb +5 -0
- data/db/migrate/20150817105643_alert_weixin_reply_message_rules_s_reply_message_length.rb +5 -0
- data/db/migrate/20150817143407_add_mch_key_to_weixin_public_account.rb +5 -0
- data/db/migrate/20150818090435_create_weixin_media_resources.rb +13 -0
- data/db/migrate/20150818094553_create_weixin_media_articles.rb +17 -0
- data/db/migrate/20150818095654_create_weixin_media_news.rb +18 -0
- data/db/migrate/20150818100348_create_weixin_media_articles_news.rb +11 -0
- data/db/migrate/20150904045253_add_host_name_to_public_account.rb +5 -0
- data/lib/eric_weixin.rb +2 -0
- data/lib/eric_weixin/modules/ip.rb +2 -0
- data/lib/eric_weixin/modules/pay.rb +31 -0
- data/lib/eric_weixin/version.rb +1 -1
- metadata +38 -2
@@ -0,0 +1,62 @@
|
|
1
|
+
<% session_content = get_session_content(params[:session_content_id])[:resource] || {} rescue {} %>
|
2
|
+
|
3
|
+
<h3 class="text-center">新增素材</h3>
|
4
|
+
|
5
|
+
<div class="row">
|
6
|
+
<div class="columns small-3 text-right">
|
7
|
+
<label class="inline">素材标签</label>
|
8
|
+
</div>
|
9
|
+
<div class="columns small-3">
|
10
|
+
<%= text_field_tag "resource[tags]", get_show_value(params[:tags], v1:session_content[:tags], v2:@media_resource.tags) %>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<div class="columns small-3 text-right">
|
14
|
+
<label class="inline">选择公众号</label>
|
15
|
+
</div>
|
16
|
+
<div class="columns small-3 end">
|
17
|
+
<%= select_tag "resource[public_account_id]", options_from_collection_for_select(::EricWeixin::PublicAccount.all, 'id', 'name', get_show_value(params[:public_account_id], v1:session_content[:public_account_id], v2:@media_resource.public_account_id)) %>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
|
21
|
+
<div class="row">
|
22
|
+
<div class="columns small-3 text-right">
|
23
|
+
<label class="inline">素材类型</label>
|
24
|
+
</div>
|
25
|
+
<div class="columns small-3">
|
26
|
+
<%= select_tag "resource[category_name]", options_from_collection_for_select(::EricWeixin::MediaResource::RESOURCE_TYPE, 'first', 'second', get_show_value(params[:category_name], v1:session_content[:category_name], v2:@media_resource.category_name)) %>
|
27
|
+
</div>
|
28
|
+
<div class="columns small-3 text-right">
|
29
|
+
<label class="inline">请选择图片(jpg\png 小于1M)</label>
|
30
|
+
</div>
|
31
|
+
<div class="small-3 columns end">
|
32
|
+
<input class="fake diff" type="text" value="<%= @media_resource.wechat_link %>" disabled="disabled" style="background-color: white" name="resource[pic]" id="resource_pic"/>
|
33
|
+
<input class="file diff" type="file" name="pic" onchange="document.getElementById('resource_pic').value=this.value"/>
|
34
|
+
</div>
|
35
|
+
</div>
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
<style>
|
41
|
+
.diff {
|
42
|
+
position: absolute;
|
43
|
+
}
|
44
|
+
.fake.diff{
|
45
|
+
background-color:white;
|
46
|
+
/*width:450px;*/
|
47
|
+
disabled:disabled;
|
48
|
+
z-index: 0
|
49
|
+
}
|
50
|
+
.upload.diff{
|
51
|
+
color: #000;
|
52
|
+
top:10px;
|
53
|
+
/*left:470px;*/
|
54
|
+
z-index: 0
|
55
|
+
}
|
56
|
+
.file.diff{
|
57
|
+
opacity:0;
|
58
|
+
/*width:500px;*/
|
59
|
+
height: 27px;
|
60
|
+
z-index: 1
|
61
|
+
}
|
62
|
+
</style>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<h3 class="text-center"> 编辑素材标签</h3>
|
2
|
+
<% session_content = get_session_content(params[:session_content_id])[:resource] || {} rescue {} %>
|
3
|
+
<%= form_tag "/eric_weixin/cms/weixin/media_resources/#{@media_resource.id}", method: :patch, :multipart => true do %>
|
4
|
+
<div class="row">
|
5
|
+
<div class="columns small-3 text-right">
|
6
|
+
<label class="inline">素材标签</label>
|
7
|
+
</div>
|
8
|
+
s<%= session_content[:tags] %>||
|
9
|
+
<br/>
|
10
|
+
@<%= @media_resource.tags %>||
|
11
|
+
<br/>
|
12
|
+
p<%= params[:tags] %>||<br/>
|
13
|
+
<div class="columns small-3">
|
14
|
+
<%= text_field_tag "resource[tags]", get_show_value(params[:tags], v1:session_content[:tags], v2:@media_resource.tags) %>
|
15
|
+
</div>
|
16
|
+
<div class="columns small-3 text-center end">
|
17
|
+
<%= submit_tag '保存', class: 'button tiny' %>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
<% end %>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
<h3 class="text-center">微信素材管理</h3>
|
2
|
+
<%= form_tag '/eric_weixin/cms/weixin/media_resources/', method: :get do %>
|
3
|
+
<div class="row">
|
4
|
+
<div class="columns small-2 text-right">
|
5
|
+
<label class="inline">标签名称</label>
|
6
|
+
</div>
|
7
|
+
<div class="columns small-2">
|
8
|
+
<%= text_field_tag :tag, params[:tag] %>
|
9
|
+
</div>
|
10
|
+
<div class="columns small-2 text-right">
|
11
|
+
<label class="inline">素材类型</label>
|
12
|
+
</div>
|
13
|
+
<div class="columns small-2">
|
14
|
+
<%= select_tag :category_name, options_from_collection_for_select(::EricWeixin::MediaResource::RESOURCE_TYPE, 'first', 'second', params[:category_name]) %>
|
15
|
+
</div>
|
16
|
+
<div class="columns small-4">
|
17
|
+
<%= submit_tag '查询', class: 'button tiny' %>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
<% end %>
|
21
|
+
|
22
|
+
<table>
|
23
|
+
<tr>
|
24
|
+
<th width="20%">图片预览</th>
|
25
|
+
<th width="10%">类型</th>
|
26
|
+
<th width="10%">创建时间</th>
|
27
|
+
|
28
|
+
<th width="30%">链接</th>
|
29
|
+
<th width="10%">操作</th>
|
30
|
+
</tr>
|
31
|
+
<% @media_resources.each do |media_resource| %>
|
32
|
+
<tr>
|
33
|
+
<td>
|
34
|
+
<img src="<%= media_resource.local_link %>" width="100" height="100">
|
35
|
+
|
36
|
+
</td>
|
37
|
+
<td><%= ::EricWeixin::MediaResource::RESOURCE_TYPE[media_resource.category_name] %></td>
|
38
|
+
<td><%= media_resource.created_at.chinese_format %></td>
|
39
|
+
|
40
|
+
<td style="WORD-BREAK: break-all; WORD-WRAP: break-word"><%= media_resource.wechat_link %></td>
|
41
|
+
<td>
|
42
|
+
<a href="/eric_weixin/cms/weixin/media_resources/<%= media_resource.id %>/edit">编辑标签</a>
|
43
|
+
<%= link_to '删除', "/eric_weixin/cms/weixin/media_resources/#{media_resource.id}", method: :delete, data: {confirm: '确定删除?'} %>
|
44
|
+
</td>
|
45
|
+
|
46
|
+
</tr>
|
47
|
+
<% end %>
|
48
|
+
</table>
|
49
|
+
<%= will_paginate @media_resources %>
|
@@ -2,19 +2,19 @@
|
|
2
2
|
|
3
3
|
<% unless @details_url.blank? %>
|
4
4
|
<textarea disabled="disabled" readonly="readonly" rows="9">
|
5
|
-
|
6
|
-
|
5
|
+
生成的url为:
|
6
|
+
<%= @details_url %>
|
7
7
|
|
8
|
-
|
8
|
+
对应的短址: <%= @short_details_url %>
|
9
9
|
</textarea>
|
10
10
|
<% end %>
|
11
11
|
|
12
12
|
<% unless @only_id_url.blank? %>
|
13
13
|
<textarea disabled="disabled" readonly="readonly" rows="9">
|
14
|
-
|
15
|
-
|
14
|
+
生成的url为:
|
15
|
+
<%= @only_id_url %>
|
16
16
|
|
17
|
-
|
17
|
+
对应的短址: <%= @short_only_id_url %>
|
18
18
|
</textarea>
|
19
19
|
<% end %>
|
20
20
|
<% else %>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
<%
|
2
|
+
timestamp = Time.now.to_i.to_s
|
3
|
+
noncestr = SecureRandom.uuid.tr('-', '')
|
4
|
+
public_account = ::EricWeixin::PublicAccount.find_by_weixin_app_id(params[:appid])
|
5
|
+
options = {}
|
6
|
+
options[:appId] = params[:appid]
|
7
|
+
options[:timeStamp] = timestamp
|
8
|
+
options[:nonceStr] = noncestr
|
9
|
+
options[:package] = "prepay_id=#{@prepay_id}"
|
10
|
+
options[:signType] = "MD5"
|
11
|
+
paySign = ::EricWeixin::Pay.generate_sign options, public_account.mch_key
|
12
|
+
%>
|
13
|
+
|
14
|
+
<script language="javascript">
|
15
|
+
function onBridgeReady(){
|
16
|
+
WeixinJSBridge.invoke(
|
17
|
+
'getBrandWCPayRequest',{
|
18
|
+
"appId": "<%= params[:appid] %>", //公众号名称,由商户传入
|
19
|
+
"timeStamp": "<%= timestamp %>", //时间戳,自1970年以来的秒数
|
20
|
+
"nonceStr":"<%= noncestr %>", //随机串
|
21
|
+
"package":"prepay_id=<%= @prepay_id %>",
|
22
|
+
"signType":"MD5", //微信签名方式:
|
23
|
+
"paySign":"<%= paySign %>" //微信签名
|
24
|
+
},
|
25
|
+
function(res){
|
26
|
+
if(res.err_msg == "get_brand_wcpay_request:ok" ) {
|
27
|
+
document.getElementById('message').innerHTML = '您支付成功,谢谢。';
|
28
|
+
} // 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回 ok,但并不保证它绝对可靠。
|
29
|
+
else {
|
30
|
+
document.getElementById('message').innerHTML = '您支付失败,请返回重新尝试,谢谢。';
|
31
|
+
}
|
32
|
+
}
|
33
|
+
);
|
34
|
+
}
|
35
|
+
|
36
|
+
|
37
|
+
if (typeof WeixinJSBridge == "undefined"){
|
38
|
+
if( document.addEventListener ){
|
39
|
+
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
|
40
|
+
}else if (document.attachEvent){
|
41
|
+
document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
|
42
|
+
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
|
43
|
+
}
|
44
|
+
}else{
|
45
|
+
onBridgeReady();
|
46
|
+
}
|
47
|
+
</script>
|
48
|
+
<br/><br/><br/><br/><br/><br/><br/>
|
49
|
+
<h1 id="message" style="text-align: center"></h1>
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<meta charset="utf-8"/>
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
6
6
|
|
7
|
-
<title><%= content_for?(:title) ? yield(:title) : "
|
7
|
+
<title><%= content_for?(:title) ? yield(:title) : "微信后台" %></title>
|
8
8
|
<%= javascript_include_tag "eric_weixin/cms/base" %>
|
9
9
|
<%= stylesheet_link_tag "eric_weixin/cms/base" %>
|
10
10
|
<%= javascript_include_tag "vendor/modernizr" %>
|
@@ -7,4 +7,4 @@ Rails.application.config.assets.version = '1.0'
|
|
7
7
|
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
8
8
|
# Rails.application.config.assets.precompile += %w( search.js )
|
9
9
|
Rails.application.config.assets.precompile += %w( eric_weixin/cms/base.js )
|
10
|
-
Rails.application.config.assets.precompile += %w( eric_weixin/cms/base.css )
|
10
|
+
Rails.application.config.assets.precompile += %w( eric_weixin/cms/base.css )
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format. Inflections
|
4
|
+
# are locale specific, and you may define rules for as many different
|
5
|
+
# locales as you wish. All of these examples are active by default:
|
6
|
+
ActiveSupport::Inflector.inflections(:en) do |inflect|
|
7
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
8
|
+
# inflect.singular /^(ox)en/i, '\1'
|
9
|
+
# inflect.irregular 'person', 'people'
|
10
|
+
# inflect.uncountable %w( fish sheep )
|
11
|
+
inflect.uncountable %w( media_news )
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
# These inflection rules are supported but not enabled by default:
|
16
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
17
|
+
# inflect.acronym 'RESTful'
|
18
|
+
# end
|
19
|
+
|
data/config/routes.rb
CHANGED
@@ -4,8 +4,9 @@ EricWeixin::Engine.routes.draw do
|
|
4
4
|
get "/weixin/service1/ddd" => "wz/weixin#aa"
|
5
5
|
get "/weixin/snsapi" => "wz/weixin#snsapi_api"
|
6
6
|
get "/weixin/snsuserinfo" => "wz/weixin#snsapi_userinfo"
|
7
|
-
|
8
|
-
|
7
|
+
|
8
|
+
get "/weixin/pay" => "wz/pays#prepay"
|
9
|
+
|
9
10
|
namespace :cms do
|
10
11
|
namespace :weixin do
|
11
12
|
resources :public_accounts do
|
@@ -15,7 +16,6 @@ EricWeixin::Engine.routes.draw do
|
|
15
16
|
post :create_menu
|
16
17
|
end
|
17
18
|
end
|
18
|
-
|
19
19
|
resources :weixin_users do
|
20
20
|
member do
|
21
21
|
post :modify_remark
|
@@ -30,13 +30,27 @@ EricWeixin::Engine.routes.draw do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
resources :reply_message_rules
|
33
|
-
|
34
33
|
resources :two_dimension_codes
|
35
34
|
resources :url_encodes
|
36
|
-
|
37
|
-
|
38
35
|
resources :customs_service_records
|
39
36
|
|
37
|
+
resources :media_resources
|
38
|
+
resources :media_articles do
|
39
|
+
collection do
|
40
|
+
get :select_pic
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
resources :media_news do
|
45
|
+
collection do
|
46
|
+
get :query_media_articles
|
47
|
+
get :will_send_articles
|
48
|
+
post :save_news
|
49
|
+
post :preview
|
50
|
+
post :send_news_now
|
51
|
+
get :query_weixin_users
|
52
|
+
end
|
53
|
+
end
|
40
54
|
end
|
41
55
|
end
|
42
56
|
end
|
data/config/tinymce.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateWeixinMediaResources < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :weixin_media_resources do |t|
|
4
|
+
t.string :tags
|
5
|
+
t.string :category_name
|
6
|
+
t.string :local_link
|
7
|
+
t.string :wechat_link
|
8
|
+
t.string :media_id
|
9
|
+
t.integer :public_account_id
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateWeixinMediaArticles < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :weixin_media_articles do |t|
|
4
|
+
t.string :thumb_media_id
|
5
|
+
t.string :author
|
6
|
+
t.string :title
|
7
|
+
t.string :content_source_url, limit: 2000
|
8
|
+
t.text :content
|
9
|
+
t.string :digest, limit: 2000
|
10
|
+
t.boolean :show_cover_pic
|
11
|
+
t.string :tag
|
12
|
+
t.boolean :is_first_article
|
13
|
+
t.integer :public_account_id
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateWeixinMediaNews < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :weixin_media_news do |t|
|
4
|
+
t.datetime :planned_send_time
|
5
|
+
t.datetime :send_time
|
6
|
+
t.string :user_group_name
|
7
|
+
t.string :media_id
|
8
|
+
t.datetime :upload_time
|
9
|
+
t.boolean :is_to_all
|
10
|
+
t.integer :sent_count
|
11
|
+
t.integer :total_count
|
12
|
+
t.integer :filter_count
|
13
|
+
t.integer :status
|
14
|
+
t.integer :public_account_id
|
15
|
+
t.timestamps
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/eric_weixin.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "eric_weixin/version"
|
2
2
|
require "rest-client"
|
3
|
+
require "tinymce-rails"
|
3
4
|
require "eric_weixin/engine"
|
4
5
|
|
5
6
|
require 'eric_weixin/modules/mult_customer'
|
@@ -7,6 +8,7 @@ require 'eric_weixin/modules/reply_message'
|
|
7
8
|
require 'eric_weixin/modules/snsapi'
|
8
9
|
require 'eric_weixin/modules/ip'
|
9
10
|
require 'eric_weixin/modules/analyze_data'
|
11
|
+
require 'eric_weixin/modules/pay'
|
10
12
|
|
11
13
|
|
12
14
|
module EricWeixin
|