修改绑定流程

This commit is contained in:
guange 2016-03-03 23:27:05 +08:00
parent 697906509b
commit 79004e1328
2 changed files with 14 additions and 10 deletions

View File

@ -24,7 +24,7 @@ class WechatsController < ActionController::Base
end
on :event, with: 'subscribe' do |request|
sendBind(request)
default_msg(request)
end
# When unsubscribe user scan qrcode qrscene_xxxxxx to subscribe in public account
@ -125,6 +125,10 @@ class WechatsController < ActionController::Base
end
on :click, with: 'MY_NEWS' do |request, key|
default_msg(req)
end
def default_msg(request)
uw = user_binded?(request[:FromUserName])
if uw && uw.user
@ -137,9 +141,9 @@ class WechatsController < ActionController::Base
activity = process_activity(a)
if activity
news << {title: activity[0],
content: activity[1],
picurl: "#{i == 1 ? logo : 'https://www.trustie.net/'+activity[2]}",
url: activity[3]
content: activity[1],
picurl: "#{i == 1 ? logo : 'https://www.trustie.net/'+activity[2]}",
url: activity[3]
}
end
@ -172,7 +176,7 @@ class WechatsController < ActionController::Base
raise "非法操作, code不存在" unless params[:code]
openid = get_openid(params[:code])
raise "无法获取到openid" unless openid
raise "此微信号已绑定用户, 不能得复绑定" if UserWechat.where(openid: openid).first
raise "此微信号已绑定用户, 不能得复绑定" if user_binded?(openid)
user, last_login_on = User.try_to_login(params[:username], params[:password])
raise "用户名或密码错误,请重新登录" unless user

View File

@ -3,11 +3,11 @@ button:
type: "click"
name: "最新动态"
key: "MY_NEWS"
-
type: "view"
name: "进入网站"
url: "http://www.trustie.net/"
-
type: "click"
name: "意见返馈"
key: "FEEDBACK"
key: "FEEDBACK"
-
type: "view"
name: "进入网站"
url: "http://www.trustie.net/"