|
|
|
@ -118,7 +118,7 @@ class WechatsController < ActionController::Base
|
|
|
|
|
on :fallback, respond: 'fallback message'
|
|
|
|
|
|
|
|
|
|
on :click, with: 'MY_NEWS' do |request, key|
|
|
|
|
|
if user_binded?
|
|
|
|
|
if user_binded?(request[:FromUserName])
|
|
|
|
|
news = (1..count.to_i).each_with_object([]) { |n, memo| memo << { title: 'News title', content: "No. #{n} news content" } }
|
|
|
|
|
request.reply.news(news) do |article, n, index| # article is return object
|
|
|
|
|
article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: 'http://www.baidu.com/img/bdlogo.gif', url: 'http://www.baidu.com/'
|
|
|
|
@ -156,8 +156,7 @@ class WechatsController < ActionController::Base
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
def user_binded?
|
|
|
|
|
openid = request[:FromUserName]
|
|
|
|
|
def user_binded?(openid)
|
|
|
|
|
uw = UserWechat.where(openid: openid).first
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|