微信关注提示语优化

This commit is contained in:
guange 2016-12-05 16:27:25 +08:00
parent 6c37645c9e
commit dcfb9d589e
2 changed files with 12 additions and 1 deletions

View File

@ -107,6 +107,7 @@ class WechatsController < ActionController::Base
end end
on :event, with: 'unsubscribe' do |request| on :event, with: 'unsubscribe' do |request|
unBind(request)
request.reply.success # user can not receive this message request.reply.success # user can not receive this message
end end
@ -274,12 +275,17 @@ class WechatsController < ActionController::Base
end end
end end
def unBind(request)
uw = user_binded?(request[:FromUserName])
uw.try(:subscribe!)
end
def sendBind(request) def sendBind(request)
tmpurl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{ROOT_URL+'/wechat/user_activities'}&response_type=code&scope=snsapi_base&state=login&connect_redirect=1#wechat_redirect" tmpurl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{ROOT_URL+'/wechat/user_activities'}&response_type=code&scope=snsapi_base&state=login&connect_redirect=1#wechat_redirect"
logger.info "tmpurl!!!!!!!!!!!!!!" logger.info "tmpurl!!!!!!!!!!!!!!"
logger.info tmpurl logger.info tmpurl
news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "欢迎使用Trustie创新实践服务平台 news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "欢迎使用Trustie创新实践服务平台
www.trustie.net
" } } " } }

View File

@ -24,4 +24,9 @@ class UserWechat < ActiveRecord::Base
BlogComment.where(author_id: old_user).update_all(author_id: u.id) BlogComment.where(author_id: old_user).update_all(author_id: u.id)
UserActivity.where(user_id: old_user).update_all(user_id: u.id) UserActivity.where(user_id: old_user).update_all(user_id: u.id)
end end
def unsubscribe!
self.delete
end
end end