订阅时发绑定信息
This commit is contained in:
parent
15d5fe127e
commit
0ab579af98
|
@ -23,7 +23,7 @@ class WechatsController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
on :event, with: 'subscribe' do |request|
|
on :event, with: 'subscribe' do |request|
|
||||||
request.reply.text "#{request[:FromUserName]} subscribe now"
|
sendBind
|
||||||
end
|
end
|
||||||
|
|
||||||
# When unsubscribe user scan qrcode qrscene_xxxxxx to subscribe in public account
|
# When unsubscribe user scan qrcode qrscene_xxxxxx to subscribe in public account
|
||||||
|
@ -147,17 +147,22 @@ class WechatsController < ActionController::Base
|
||||||
url: n[:url]
|
url: n[:url]
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
sendBind
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def sendBind
|
||||||
openid = request[:FromUserName]
|
openid = request[:FromUserName]
|
||||||
attrs = wechat.user(openid)
|
attrs = wechat.user(openid)
|
||||||
UserWechat.delete_all(openid: openid)
|
UserWechat.delete_all(openid: openid)
|
||||||
uw = UserWechat.create!(attrs)
|
uw = UserWechat.create!(attrs)
|
||||||
news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "您还未绑定确实的用户,请先绑定." } }
|
news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "您还未绑定确实的用户,请先绑定." } }
|
||||||
request.reply.news(news) do |article, n, index| # article is return object
|
request.reply.news(news) do |article, n, index| # article is return object
|
||||||
|
url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{self.corpid}&redirect_uri=#{login_wechat_url(uid: uw.id)}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
|
||||||
article.item title: "#{n[:title]}",
|
article.item title: "#{n[:title]}",
|
||||||
description: n[:content],
|
description: n[:content],
|
||||||
pic_url: 'http://wechat.trustie.net/images/trustie_logo2.png',
|
pic_url: 'http://wechat.trustie.net/images/trustie_logo2.png',
|
||||||
url: login_wechat_url(openid: uw.id)
|
url: url
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue