eric_weixin 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -6,6 +6,15 @@ class EricWeixin::PublicAccount < ActiveRecord::Base
|
|
6
6
|
has_many :two_dimension_codes, :class_name => 'TwoDimensionCode', foreign_key: "weixin_public_account_id"
|
7
7
|
has_one :access_token, :class_name => 'AccessToken', foreign_key: "public_account_id"
|
8
8
|
has_many :customs_service_records, class_name: 'CustomsServiceRecord', foreign_key: "weixin_public_account_id"
|
9
|
+
|
10
|
+
#根据微信号名称获取微信账号相关信息
|
11
|
+
# ::EricWeixin::PublicAccount.get_public_account_by_name 'dfxt'
|
12
|
+
def self.get_public_account_by_name name
|
13
|
+
accounts = ::EricWeixin::PublicAccount.where name: name
|
14
|
+
return nil if accounts.blank?
|
15
|
+
accounts[0]
|
16
|
+
end
|
17
|
+
|
9
18
|
#
|
10
19
|
# def self.get_secret app_id
|
11
20
|
# account = ::EricWeixin::PublicAccount.where(weixin_app_id: app_id).first
|
@@ -0,0 +1,131 @@
|
|
1
|
+
<% session_content = get_session_content(params[:session_content_id])[:article] || {} rescue {} %>
|
2
|
+
|
3
|
+
<%= tinymce_assets %>
|
4
|
+
<div class="row">
|
5
|
+
<div class="columns small-2 text-right">
|
6
|
+
<label class="inline">选择公众号</label>
|
7
|
+
</div>
|
8
|
+
<div class="columns small-5 end">
|
9
|
+
<%= select_tag "article[public_account_id]", options_from_collection_for_select(::EricWeixin::PublicAccount.all, 'id', 'name', get_show_value(@media_article.public_account_id, v1:session_content[:public_account_id], v2:@media_article.public_account_id)) %>
|
10
|
+
</div>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<div class="row">
|
14
|
+
<div class="columns small-2 text-right">
|
15
|
+
<label class="inline">图文标签</label>
|
16
|
+
</div>
|
17
|
+
<div class="columns small-5 end">
|
18
|
+
<%= text_field_tag "article[tag]", (get_show_value(@media_article.tag, v1:session_content[:tag]) ) %>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<div class="row">
|
23
|
+
<div class="columns small-2 text-right">
|
24
|
+
<label class="inline">请选择缩略图</label>
|
25
|
+
</div>
|
26
|
+
<div class="columns small-5 end">
|
27
|
+
<img id="suoluetu" src="<%= ::EricWeixin::MediaResource.find_by_id(get_show_value(@media_article.thumb_media_id, v1:session_content[:thumb_media_id])).local_link rescue '' %>" width="100" height="100">
|
28
|
+
</div><%= link_to '选择封面', '#', class: 'button tiny', 'data-reveal-id' => 'AddPosterModal' %>
|
29
|
+
</div>
|
30
|
+
<br/>
|
31
|
+
<%= hidden_field_tag "article[thumb_media_id]", (get_show_value(@media_article.thumb_media_id, v1:session_content[:thumb_media_id]) rescue '') %>
|
32
|
+
|
33
|
+
<div class="row">
|
34
|
+
<div class="columns small-2 text-right">
|
35
|
+
<label class="inline">作者</label>
|
36
|
+
</div>
|
37
|
+
<div class="columns small-5 end">
|
38
|
+
<%= text_field_tag "article[author]", (get_show_value(@media_article.author, v1:session_content[:author]) rescue '') %>
|
39
|
+
</div>
|
40
|
+
</div>
|
41
|
+
|
42
|
+
<div class="row">
|
43
|
+
<div class="columns small-2 text-right">
|
44
|
+
<label class="inline">标题</label>
|
45
|
+
</div>
|
46
|
+
<div class="columns small-5 end">
|
47
|
+
<%= text_field_tag "article[title]", (get_show_value(@media_article.title, v1:session_content[:title]) rescue '') %>
|
48
|
+
</div>
|
49
|
+
</div>
|
50
|
+
|
51
|
+
<div class="row">
|
52
|
+
<div class="columns small-2 text-right">
|
53
|
+
<label class="inline">摘要</label>
|
54
|
+
</div>
|
55
|
+
<div class="columns small-5 end">
|
56
|
+
<%= text_field_tag "article[digest]", (get_show_value(@media_article.digest, v1:session_content[:digest]) rescue '') %>
|
57
|
+
</div>
|
58
|
+
</div>
|
59
|
+
|
60
|
+
<div class="row">
|
61
|
+
<div class="columns small-2 text-right">
|
62
|
+
<label class="inline"></label>
|
63
|
+
</div>
|
64
|
+
<div class="columns small-5 end">
|
65
|
+
<%= check_box_tag "article[show_cover_pic]", true , (get_show_value((@media_article.show_cover_pic==true ? 'true' : 'false'), v1:session_content[:show_cover_pic])=='true' rescue '') %>
|
66
|
+
<label class="inline text-left">是否在正文显示封面</label>
|
67
|
+
</div>
|
68
|
+
</div>
|
69
|
+
|
70
|
+
<div class="row">
|
71
|
+
<div class="columns small-2 text-right">
|
72
|
+
<label class="inline"></label>
|
73
|
+
</div>
|
74
|
+
<div class="columns small-5 end">
|
75
|
+
<%= check_box_tag "article[is_first_article]", true , (get_show_value((@media_article.is_first_article==true ? 'true' : 'false'), v1:session_content[:is_first_article])=='true' rescue '') %>
|
76
|
+
<label class="inline">是否首图</label>
|
77
|
+
</div>
|
78
|
+
</div>
|
79
|
+
|
80
|
+
<div class="row">
|
81
|
+
<div class="columns small-2 end text-right">
|
82
|
+
<label class="inline">内容</label>
|
83
|
+
</div>
|
84
|
+
</div>
|
85
|
+
|
86
|
+
<div class="row">
|
87
|
+
<div class="columns small-12">
|
88
|
+
<%= text_area_tag "article[content]", (get_show_value(@media_article.content, v1:session_content[:content]) rescue ''), :class => "tinymce", :rows => 40, :cols => 120 %>
|
89
|
+
</div>
|
90
|
+
</div>
|
91
|
+
|
92
|
+
<br/>
|
93
|
+
|
94
|
+
<div class="row">
|
95
|
+
<div class="columns small-2 text-right">
|
96
|
+
<label class="inline">阅读原文链接</label>
|
97
|
+
</div>
|
98
|
+
<div class="columns small-10 end">
|
99
|
+
<%= text_field_tag "article[content_source_url]", (get_show_value(@media_article.content_source_url, v1:session_content[:content_source_url]) rescue '') %>
|
100
|
+
</div>
|
101
|
+
</div>
|
102
|
+
|
103
|
+
<div class="row">
|
104
|
+
<div class="columns small-6 text-center">
|
105
|
+
<%= submit_tag '提交', class: 'button tiny' %>
|
106
|
+
</div>
|
107
|
+
<div class="columns small-6 text-center">
|
108
|
+
<%= submit_tag '预览', class: 'button tiny' %>
|
109
|
+
</div>
|
110
|
+
</div>
|
111
|
+
|
112
|
+
<script language="javascript">
|
113
|
+
tinyMCE.init({
|
114
|
+
selector: '#article_content',
|
115
|
+
plugins : 'advlist code colorpicker fullscreen image link paste preview print save lists table wordcount textcolor',
|
116
|
+
toolbar1: "forecolor backcolor newdocument bold italic underline strikethrough alignleft",
|
117
|
+
toolbar2: "styleselect formatselect fontselect fontsizeselect cut copy paste",
|
118
|
+
toolbar3: "indent blockquote undo redo removeformat subscript superscript hr link unlink image charmap pastetext print preview anchor pagebreak spellchecker searchreplace visualblocks visualchars",
|
119
|
+
toolbar4: "code fullscreen insertdatetime media nonbreaking save cancel table ltr rtl emoticons template forecolor backcolor insertfile aligncenter alignright alignjustify bullist numlist outdent"
|
120
|
+
});
|
121
|
+
</script>
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
<!--弹出选择缩略图模式框-->
|
126
|
+
<div id="AddPosterModal" class="reveal-modal" data-reveal>
|
127
|
+
<h3>选择封面</h3>
|
128
|
+
<div class="panel callout radius" id="select_pic_div">
|
129
|
+
<%= render partial: 'select_pic' %>
|
130
|
+
</div>
|
131
|
+
</div>
|
@@ -0,0 +1,78 @@
|
|
1
|
+
<% @pics.each_with_index do |pic, index| %>
|
2
|
+
<% if index%6==0 %>
|
3
|
+
<div class="row">
|
4
|
+
<% end %>
|
5
|
+
<div class="columns small-2 <%= @pics.count == index+1 ? 'end' : '' %>">
|
6
|
+
<label class="inline"><span><%= radio_button_tag 'picture', pic.id, false, onchange: "change_thumb_media_id('#{pic.id}','#{pic.local_link}')" %></span>
|
7
|
+
<img src='<%= pic.local_link %>' width="100" height="100"></label>
|
8
|
+
</div>
|
9
|
+
<% if index%6==5 || @pics.count == index+1 %>
|
10
|
+
</div>
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
13
|
+
<div class="row">
|
14
|
+
<div class="columns small-12 text-right">
|
15
|
+
<% if @current_page == 1 %>
|
16
|
+
<%= "上一页" %>
|
17
|
+
<% else %>
|
18
|
+
<%= link_to '上一页',"javascript:pre_page(#{@current_page||1})", disabled: (@current_page ==1 ? 'false' : 'true') %>
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
<% if @current_page == @total_page %>
|
22
|
+
<%= "下一页" %>
|
23
|
+
<% else %>
|
24
|
+
<%= link_to '下一页',"javascript:next_page(#{@current_page||1})" %>
|
25
|
+
<% end %>
|
26
|
+
<%= "当前第#{@current_page||1}页 共#{@total_page}页" %>
|
27
|
+
</div>
|
28
|
+
</div>
|
29
|
+
<div class="row">
|
30
|
+
<div class="columns small-2 small-offset-5 text-center">
|
31
|
+
<%= link_to '确定', 'javascript:close_modal()', class: 'text-center button tiny' %>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<script language="javascript">
|
36
|
+
function change_thumb_media_id(thumb_media_id, link) {
|
37
|
+
$("#article_thumb_media_id").val(thumb_media_id);
|
38
|
+
$("#suoluetu").attr('src',link);
|
39
|
+
}
|
40
|
+
|
41
|
+
function close_modal(){
|
42
|
+
$('#AddPosterModal').foundation('reveal', 'close');
|
43
|
+
}
|
44
|
+
|
45
|
+
function pre_page(current_page){
|
46
|
+
target_page = current_page - 1;
|
47
|
+
if(target_page == 0){
|
48
|
+
target_page = 1;
|
49
|
+
}
|
50
|
+
$.ajax({
|
51
|
+
url: '/eric_weixin/cms/weixin/media_articles/select_pic',
|
52
|
+
type: 'get',
|
53
|
+
data: {target_page: target_page},
|
54
|
+
async: false
|
55
|
+
}).done(
|
56
|
+
function(result){
|
57
|
+
$("#select_pic_div").html(result);
|
58
|
+
}
|
59
|
+
);
|
60
|
+
}
|
61
|
+
|
62
|
+
function next_page(current_page){
|
63
|
+
target_page = current_page + 1;
|
64
|
+
if(target_page > <%= @total_page %>){
|
65
|
+
target_page = <%= @total_page %>;
|
66
|
+
}
|
67
|
+
$.ajax({
|
68
|
+
url: '/eric_weixin/cms/weixin/media_articles/select_pic',
|
69
|
+
type: 'get',
|
70
|
+
data: {target_page: target_page},
|
71
|
+
async: false
|
72
|
+
}).done(
|
73
|
+
function(result){
|
74
|
+
$("#select_pic_div").html(result);
|
75
|
+
}
|
76
|
+
);
|
77
|
+
}
|
78
|
+
</script>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<h3 class="text-center">微信素材管理</h3>
|
2
|
+
<%= form_tag '/eric_weixin/cms/weixin/media_articles/', 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 :title, params[:title] %>
|
9
|
+
</div>
|
10
|
+
<div class="columns small-4">
|
11
|
+
<%= submit_tag '查询', class: 'button tiny' %>
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<table>
|
17
|
+
<thead>
|
18
|
+
<th>图文名称</th><th>创建时间</th><th>原文链接</th><th>首图</th><th>摘要</th><th>操作</th>
|
19
|
+
</thead>
|
20
|
+
<% @media_articles.each do |media_article| %>
|
21
|
+
<tr>
|
22
|
+
<td><%= media_article.title %></td>
|
23
|
+
<td><%= media_article.created_at.chinese_format %></td>
|
24
|
+
<td><%= media_article.content_source_url %></td>
|
25
|
+
<td><%= media_article.is_first_article %></td>
|
26
|
+
<td><%= media_article.digest %></td>
|
27
|
+
<td><%= link_to '编辑', "/eric_weixin/cms/weixin/media_articles/#{media_article.id}/edit", class: 'button tiny' %></td>
|
28
|
+
</tr>
|
29
|
+
<% end %>
|
30
|
+
</table>
|
31
|
+
<%= will_paginate @media_articles %>
|
@@ -0,0 +1,90 @@
|
|
1
|
+
<h5>筛选供使用的文章</h5>
|
2
|
+
<table>
|
3
|
+
<% @media_articles.each do |media_article| %>
|
4
|
+
<tr>
|
5
|
+
<td><%= media_article.title %></td>
|
6
|
+
<td><img src="<%= media_article.media_resource.local_link %>" width="20" height="20"></td>
|
7
|
+
<td><%= media_article.is_first_article ? '首图文' : '' %></td>
|
8
|
+
<td><%= link_to '选中️', "javascript:select_this_to_target_news(#{media_article.id})" %></td>
|
9
|
+
</tr>
|
10
|
+
<% end %>
|
11
|
+
</table>
|
12
|
+
<div class="row">
|
13
|
+
<div class="columns small-12 text-right">
|
14
|
+
<% if @current_page == 1 %>
|
15
|
+
<%= "上一页" %>
|
16
|
+
<% else %>
|
17
|
+
<%= link_to '上一页',"javascript:pre_page(#{@current_page||1})", disabled: (@current_page ==1 ? 'false' : 'true') %>
|
18
|
+
<% end %>
|
19
|
+
|
20
|
+
<% if @current_page == @total_page %>
|
21
|
+
<%= "下一页" %>
|
22
|
+
<% else %>
|
23
|
+
<%= link_to '下一页',"javascript:next_page(#{@current_page||1})" %>
|
24
|
+
<% end %>
|
25
|
+
<%= "当前第#{@current_page||1}页 共#{@total_page}页" %>
|
26
|
+
</div>
|
27
|
+
</div>
|
28
|
+
<script language="javascript">
|
29
|
+
|
30
|
+
function select_this_to_target_news(media_article_id){
|
31
|
+
existed_article_ids = $("#will_send_article_msg").val();
|
32
|
+
new_article_id = media_article_id;
|
33
|
+
$.ajax({
|
34
|
+
url: "/eric_weixin/cms/weixin/media_news/will_send_articles",
|
35
|
+
type: 'get',
|
36
|
+
data: {existed_article_ids: existed_article_ids, new_article_id: new_article_id}
|
37
|
+
}).done(
|
38
|
+
function(result){
|
39
|
+
if(result == "existed"){
|
40
|
+
alert("该文章已经在该图文里了");
|
41
|
+
} else {
|
42
|
+
$("#will_send_content").html(result);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
);
|
46
|
+
}
|
47
|
+
|
48
|
+
|
49
|
+
function pre_page(current_page){
|
50
|
+
tag = $("#condition_tag").val();
|
51
|
+
start_date = $("#condition_start_date").val();
|
52
|
+
end_date = $("#condition_end_date").val();
|
53
|
+
target_page = current_page - 1;
|
54
|
+
if(target_page == 0){
|
55
|
+
target_page = 1;
|
56
|
+
}
|
57
|
+
|
58
|
+
|
59
|
+
$.ajax({
|
60
|
+
url: '/eric_weixin/cms/weixin/media_news/query_media_articles',
|
61
|
+
type: 'get',
|
62
|
+
data: {tag: tag, start_date: start_date, end_date: end_date, page: target_page},
|
63
|
+
async: false
|
64
|
+
}).done(
|
65
|
+
function(result){
|
66
|
+
$("#query_result").html(result);
|
67
|
+
}
|
68
|
+
);
|
69
|
+
}
|
70
|
+
|
71
|
+
function next_page(current_page){
|
72
|
+
tag = $("#condition_tag").val();
|
73
|
+
start_date = $("#condition_start_date").val();
|
74
|
+
end_date = $("#condition_end_date").val();
|
75
|
+
target_page = current_page + 1;
|
76
|
+
if(target_page > <%= @total_page %>){
|
77
|
+
target_page = <%= @total_page %>;
|
78
|
+
}
|
79
|
+
$.ajax({
|
80
|
+
url: '/eric_weixin/cms/weixin/media_news/query_media_articles',
|
81
|
+
type: 'get',
|
82
|
+
data: {tag: tag, start_date: start_date, end_date: end_date, page: target_page},
|
83
|
+
async: false
|
84
|
+
}).done(
|
85
|
+
function(result){
|
86
|
+
$("#query_result").html(result);
|
87
|
+
}
|
88
|
+
);
|
89
|
+
}
|
90
|
+
</script>
|
@@ -0,0 +1,53 @@
|
|
1
|
+
<h5>最终要发送的图文</h5>
|
2
|
+
<table>
|
3
|
+
<% @will_send_articles.each do |will_send_article| %>
|
4
|
+
<tr>
|
5
|
+
<td><%= will_send_article.title %></td>
|
6
|
+
<td><img src="<%= will_send_article.media_resource.local_link %>" width="50" height="50"></td>
|
7
|
+
<td><%= will_send_article.is_first_article ? '首图文' : '' %></td>
|
8
|
+
<td>
|
9
|
+
<%= link_to '↑↑', "javascript:up_article(#{will_send_article.id})" %>
|
10
|
+
|
11
|
+
<%= link_to '↓↓', "javascript:down_article(#{will_send_article.id})" %>
|
12
|
+
</td>
|
13
|
+
</tr>
|
14
|
+
<% end %>
|
15
|
+
</table>
|
16
|
+
|
17
|
+
<%= hidden_field_tag :will_send_article_msg, @will_send_article_msg %>
|
18
|
+
|
19
|
+
<script language="javascript">
|
20
|
+
function up_article(article_id){
|
21
|
+
existed_article_ids = $("#will_send_article_msg").val();
|
22
|
+
$.ajax({
|
23
|
+
url: "/eric_weixin/cms/weixin/media_news/will_send_articles",
|
24
|
+
type: 'get',
|
25
|
+
data: {existed_article_ids: existed_article_ids, up_article_id: article_id}
|
26
|
+
}).done(
|
27
|
+
function(result){
|
28
|
+
if(result == "top"){
|
29
|
+
alert("已经在最顶部了");
|
30
|
+
} else {
|
31
|
+
$("#will_send_content").html(result);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
);
|
35
|
+
}
|
36
|
+
|
37
|
+
function down_article(article_id){
|
38
|
+
existed_article_ids = $("#will_send_article_msg").val();
|
39
|
+
$.ajax({
|
40
|
+
url: "/eric_weixin/cms/weixin/media_news/will_send_articles",
|
41
|
+
type: 'get',
|
42
|
+
data: {existed_article_ids: existed_article_ids, down_article_id: article_id}
|
43
|
+
}).done(
|
44
|
+
function(result){
|
45
|
+
if(result == "bottom"){
|
46
|
+
alert("已经在最底部了");
|
47
|
+
} else {
|
48
|
+
$("#will_send_content").html(result);
|
49
|
+
}
|
50
|
+
}
|
51
|
+
);
|
52
|
+
}
|
53
|
+
</script>
|
@@ -0,0 +1,284 @@
|
|
1
|
+
<h3 class="text-center">图文发送</h3>
|
2
|
+
<br/>
|
3
|
+
|
4
|
+
<div class="row">
|
5
|
+
<div class="columns small-3 text-right">
|
6
|
+
<label class="inline">选择公众号</label>
|
7
|
+
</div>
|
8
|
+
<div class="columns small-5 end">
|
9
|
+
<%= select_tag "condition[public_account_id]", options_from_collection_for_select(::EricWeixin::PublicAccount.all, 'id', 'name', '') %>
|
10
|
+
</div>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<div class="row">
|
14
|
+
<div class="columns small-3 text-right">
|
15
|
+
<label class="inline">图文标签</label>
|
16
|
+
</div>
|
17
|
+
<div class="columns small-5 end">
|
18
|
+
<%= text_field_tag 'condition[tag]' %>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
<div class="row">
|
22
|
+
<div class="columns small-3 text-right">
|
23
|
+
<label class="inline">图文创建时间</label>
|
24
|
+
</div>
|
25
|
+
<div class="columns small-2">
|
26
|
+
<%= date_field_tag 'condition[start_date]' %>
|
27
|
+
</div>
|
28
|
+
<div class="columns small-1 text-center">
|
29
|
+
<label class="inline">至</label>
|
30
|
+
</div>
|
31
|
+
<div class="columns small-2">
|
32
|
+
<%= date_field_tag 'condition[end_date]' %>
|
33
|
+
</div>
|
34
|
+
<div class="columns small-offset-1 small-3 text-center">
|
35
|
+
<%= link_to '查询', "javascript:query_media_articles()", class: 'button tiny' %>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
<script language="javascript">
|
39
|
+
function query_media_articles(){
|
40
|
+
tag = $("#condition_tag").val();
|
41
|
+
start_date = $("#condition_start_date").val();
|
42
|
+
end_date = $("#condition_end_date").val();
|
43
|
+
public_account_id = $("#condition_public_account_id").val();
|
44
|
+
$.ajax({
|
45
|
+
url: '/eric_weixin/cms/weixin/media_news/query_media_articles',
|
46
|
+
type: 'get',
|
47
|
+
data: {tag: tag, start_date: start_date, end_date: end_date, public_account_id: public_account_id}
|
48
|
+
}).done(
|
49
|
+
function(result){
|
50
|
+
$("#query_result").html(result);
|
51
|
+
}
|
52
|
+
)
|
53
|
+
}
|
54
|
+
</script>
|
55
|
+
<!--************************************** 查找到的内容 ************************************************-->
|
56
|
+
<div class="row">
|
57
|
+
<div id="query_result" class="columns small-12 panel callout radius">
|
58
|
+
|
59
|
+
</div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<!--************************************** 将要被发送的内容 ************************************************-->
|
63
|
+
<div class="row">
|
64
|
+
<div id="will_send_content" class="columns small-12 panel callout radius">
|
65
|
+
|
66
|
+
</div>
|
67
|
+
</div>
|
68
|
+
|
69
|
+
<div class="row">
|
70
|
+
<div class="columns small-6 text-right">
|
71
|
+
<label class="inline">发送对象</label>
|
72
|
+
</div>
|
73
|
+
<div class="columns small-3 end">
|
74
|
+
<%= select_tag 'send[target]', options_from_collection_for_select(::Weixin::Process.get_user_groups, 'first', 'second', '') %>
|
75
|
+
</div>
|
76
|
+
</div>
|
77
|
+
|
78
|
+
<div class="row">
|
79
|
+
<div class="columns small-6 text-right end">
|
80
|
+
<label class="inline">其他</label>
|
81
|
+
</div>
|
82
|
+
<div class="columns small-6 text-left">
|
83
|
+
<%= check_box_tag 'do_send[fix_time]', true, false %><label class="inline">定时发送(分钟数请设置为5分钟的整数倍:如10点05分,10点10分)</label>
|
84
|
+
</div>
|
85
|
+
</div>
|
86
|
+
<div class="row">
|
87
|
+
<div class="columns small-offset-6 small-6">
|
88
|
+
<div class="row">
|
89
|
+
<div class="columns small-4">
|
90
|
+
<label class="inline">定时发送时间:()</label>
|
91
|
+
</div>
|
92
|
+
<div class="columns small-4">
|
93
|
+
<%= date_field_tag 'send[fix_date]' %>
|
94
|
+
</div>
|
95
|
+
<div class="columns small-4">
|
96
|
+
<%= time_field_tag 'send[fix_time]' %>
|
97
|
+
</div>
|
98
|
+
</div>
|
99
|
+
</div>
|
100
|
+
</div>
|
101
|
+
<div class="row">
|
102
|
+
<div class="columns small-offset-6 small-6 text-left">
|
103
|
+
<%= check_box_tag 'send[save_to_history]', true, false %><label class="inline">保留为历史消息(所有用户可见)</label>
|
104
|
+
</div>
|
105
|
+
</div>
|
106
|
+
|
107
|
+
<br/><br/>
|
108
|
+
<%= hidden_field_tag :media_news_id, @media_news_id %>
|
109
|
+
<div class="row">
|
110
|
+
<div class="columns small-6 small-offset-3 end">
|
111
|
+
|
112
|
+
<div class="row">
|
113
|
+
<div class="columns small-4 text-center">
|
114
|
+
<%= link_to '预览', "#", class: "button tiny", 'data-reveal-id' => 'SendPreview' %>
|
115
|
+
</div>
|
116
|
+
<div class="columns small-4 text-center">
|
117
|
+
<%= link_to '保存', "javascript:save_news()", class: "button tiny" %>
|
118
|
+
</div>
|
119
|
+
<div class="columns small-4 text-center">
|
120
|
+
<%= link_to '立即发送', "javascript:send_news_now()", class: "button tiny" %>
|
121
|
+
</div>
|
122
|
+
</div>
|
123
|
+
|
124
|
+
</div>
|
125
|
+
</div>
|
126
|
+
|
127
|
+
<div id="SendPreview" class="reveal-modal" data-reveal>
|
128
|
+
<h3>选择预览用户</h3>
|
129
|
+
<div class="panel callout radius" id="select_pic_div">
|
130
|
+
|
131
|
+
<div class="row">
|
132
|
+
<div class="columns small-4 text-right">
|
133
|
+
<label class="inline">请输入用户昵称</label>
|
134
|
+
</div>
|
135
|
+
<div class="columns small-4">
|
136
|
+
<%= text_field_tag 'preview[nick_name]' %>
|
137
|
+
</div>
|
138
|
+
<div class="columns small-4">
|
139
|
+
<%= link_to '查询', "javascript:select_weixin_user()", class: 'button tiny' %>
|
140
|
+
</div>
|
141
|
+
</div>
|
142
|
+
|
143
|
+
<!--************************************** 查找到的预览用户 ************************************************-->
|
144
|
+
<div class="row">
|
145
|
+
<div id="preview_select_user" class="columns small-12 panel">
|
146
|
+
|
147
|
+
</div>
|
148
|
+
</div>
|
149
|
+
|
150
|
+
<div class="row">
|
151
|
+
<div class="columns small-6 text-center">
|
152
|
+
<%= link_to '发送', 'javascript:preview()', class: 'text-center button tiny' %>
|
153
|
+
</div>
|
154
|
+
<div class="columns small-6 text-center">
|
155
|
+
<%= link_to '取消', 'javascript:close_modal()', class: 'text-center button tiny' %>
|
156
|
+
</div>
|
157
|
+
</div>
|
158
|
+
</div>
|
159
|
+
</div>
|
160
|
+
|
161
|
+
<script language="javascript">
|
162
|
+
function close_modal(){
|
163
|
+
$('#SendPreview').foundation('reveal', 'close');
|
164
|
+
}
|
165
|
+
|
166
|
+
function select_weixin_user(){
|
167
|
+
nickname = $("#preview_nick_name").val();
|
168
|
+
public_account_id = $("#condition_public_account_id").val();
|
169
|
+
$.ajax({
|
170
|
+
url: "/eric_weixin/cms/weixin/media_news/query_weixin_users",
|
171
|
+
type: 'get',
|
172
|
+
data: {nickname: nickname, public_account_id: public_account_id}
|
173
|
+
}).done(
|
174
|
+
function (result) {
|
175
|
+
$("#preview_select_user").html(result);
|
176
|
+
}
|
177
|
+
)
|
178
|
+
}
|
179
|
+
|
180
|
+
function preview(){
|
181
|
+
preview_openid = $("#preview_openid").val();
|
182
|
+
will_send_article_msg = $("#will_send_article_msg").val();
|
183
|
+
user_group_name = $("#send_target").val();
|
184
|
+
send_at_fixed_time = $("#do_send_fix_time").val();
|
185
|
+
send_fixed_date = $("#send_fix_date").val();
|
186
|
+
send_fixed_time = $("#send_fix_time").val();
|
187
|
+
send_save_to_history = $("#send_save_to_history").val();
|
188
|
+
public_account_id = $("#condition_public_account_id").val();
|
189
|
+
media_news_id = $("#media_news_id").val();
|
190
|
+
$.ajax({
|
191
|
+
url: "/eric_weixin/cms/weixin/media_news/preview",
|
192
|
+
type: 'post',
|
193
|
+
data: {
|
194
|
+
will_send_article_msg: will_send_article_msg,
|
195
|
+
user_group_name: user_group_name,
|
196
|
+
send_at_fixed_time: send_at_fixed_time,
|
197
|
+
send_fixed_date: send_fixed_date,
|
198
|
+
send_fixed_time: send_fixed_time,
|
199
|
+
send_save_to_history: send_save_to_history,
|
200
|
+
public_account_id: public_account_id,
|
201
|
+
preview_openid: preview_openid,
|
202
|
+
media_news_id: media_news_id
|
203
|
+
}
|
204
|
+
}).done(
|
205
|
+
function(result){
|
206
|
+
if(result.substr(0,4)=="保存失败") {
|
207
|
+
alert(result);
|
208
|
+
} else {
|
209
|
+
$("#media_news_id").val(result);
|
210
|
+
$('#SendPreview').foundation('reveal', 'close');
|
211
|
+
alert("预览成功")
|
212
|
+
}
|
213
|
+
}
|
214
|
+
)
|
215
|
+
}
|
216
|
+
|
217
|
+
function save_news(){
|
218
|
+
will_send_article_msg = $("#will_send_article_msg").val();
|
219
|
+
user_group_name = $("#send_target").val();
|
220
|
+
send_at_fixed_time = $("#do_send_fix_time").val();
|
221
|
+
send_fixed_date = $("#send_fix_date").val();
|
222
|
+
send_fixed_time = $("#send_fix_time").val();
|
223
|
+
send_save_to_history = $("#send_save_to_history").val();
|
224
|
+
public_account_id = $("#condition_public_account_id").val();
|
225
|
+
media_news_id = $("#media_news_id").val();
|
226
|
+
$.ajax({
|
227
|
+
url: "/eric_weixin/cms/weixin/media_news/save_news",
|
228
|
+
type: 'post',
|
229
|
+
data: {
|
230
|
+
will_send_article_msg: will_send_article_msg,
|
231
|
+
user_group_name: user_group_name,
|
232
|
+
send_at_fixed_time: send_at_fixed_time,
|
233
|
+
send_fixed_date: send_fixed_date,
|
234
|
+
send_fixed_time: send_fixed_time,
|
235
|
+
send_save_to_history: send_save_to_history,
|
236
|
+
public_account_id: public_account_id,
|
237
|
+
media_news_id: media_news_id
|
238
|
+
}
|
239
|
+
}).done(
|
240
|
+
function(result){
|
241
|
+
if(result.substr(0,4)=="保存失败") {
|
242
|
+
alert(result);
|
243
|
+
} else {
|
244
|
+
$("#media_news_id").val(result);
|
245
|
+
alert("保存成功")
|
246
|
+
}
|
247
|
+
}
|
248
|
+
)
|
249
|
+
}
|
250
|
+
|
251
|
+
function send_news_now() {
|
252
|
+
will_send_article_msg = $("#will_send_article_msg").val();
|
253
|
+
user_group_name = $("#send_target").val();
|
254
|
+
send_at_fixed_time = $("#do_send_fix_time").val();
|
255
|
+
send_fixed_date = $("#send_fix_date").val();
|
256
|
+
send_fixed_time = $("#send_fix_time").val();
|
257
|
+
send_save_to_history = $("#send_save_to_history").val();
|
258
|
+
public_account_id = $("#condition_public_account_id").val();
|
259
|
+
media_news_id = $("#media_news_id").val();
|
260
|
+
$.ajax({
|
261
|
+
url: "/eric_weixin/cms/weixin/media_news/send_news_now",
|
262
|
+
type: 'post',
|
263
|
+
data: {
|
264
|
+
will_send_article_msg: will_send_article_msg,
|
265
|
+
user_group_name: user_group_name,
|
266
|
+
send_at_fixed_time: send_at_fixed_time,
|
267
|
+
send_fixed_date: send_fixed_date,
|
268
|
+
send_fixed_time: send_fixed_time,
|
269
|
+
send_save_to_history: send_save_to_history,
|
270
|
+
public_account_id: public_account_id,
|
271
|
+
media_news_id: media_news_id
|
272
|
+
}
|
273
|
+
}).done(
|
274
|
+
function(result){
|
275
|
+
if(result.substr(0,4)=="保存失败") {
|
276
|
+
alert(result);
|
277
|
+
} else {
|
278
|
+
$("#media_news_id").val(result);
|
279
|
+
alert("发送成功")
|
280
|
+
}
|
281
|
+
}
|
282
|
+
)
|
283
|
+
}
|
284
|
+
</script>
|