|
|
|
@ -14,7 +14,8 @@ module Mobile
|
|
|
|
|
post 'wxbind' do
|
|
|
|
|
openid = params[:openid]
|
|
|
|
|
raise "无法获取到openid,请在微信中打开本页面" unless openid
|
|
|
|
|
raise "此微信号已绑定用户, 不能重复绑定" if UserWechat.where(openid: openid).first
|
|
|
|
|
uw = UserWechat.where(openid: openid).first
|
|
|
|
|
raise "此微信号已绑定用户(#{uw.user.login}), 不能重复绑定" if uw
|
|
|
|
|
|
|
|
|
|
user, last_login_on = User.try_to_login(params[:login], params[:password])
|
|
|
|
|
raise "用户名或密码错误,请重新输入" unless user
|
|
|
|
@ -26,8 +27,8 @@ module Mobile
|
|
|
|
|
openid: openid,
|
|
|
|
|
user: user
|
|
|
|
|
)
|
|
|
|
|
ws = WechatService.new
|
|
|
|
|
ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台", user.login, format_time(Time.now))
|
|
|
|
|
# ws = WechatService.new
|
|
|
|
|
# ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台", user.login, format_time(Time.now))
|
|
|
|
|
present status: 0
|
|
|
|
|
present message: '绑定成功'
|
|
|
|
|
end
|
|
|
|
|