微信自动绑定用户修改
This commit is contained in:
parent
3a000a360a
commit
6af15b7121
|
@ -19,11 +19,14 @@ module Mobile
|
||||||
unless current_user
|
unless current_user
|
||||||
#如果当前用户不存在
|
#如果当前用户不存在
|
||||||
openid = session[:wechat_openid]
|
openid = session[:wechat_openid]
|
||||||
raise "请在微信中关注Trustie创新实践平台后再打开本页面" unless openid
|
raise "无法获取到openid,请在微信中打开本页面" unless openid
|
||||||
|
|
||||||
us = UsersService.new
|
us = UsersService.new
|
||||||
#login mail password
|
#login mail password
|
||||||
user = us.register ({:login=>openid, :mail=>openid+"@163.com",
|
|
||||||
|
login = openid[0..3]+"***"+openid.last
|
||||||
|
|
||||||
|
user = us.register ({:login=>login, :mail=>login+"@163.com",
|
||||||
:password=>"12345678", :password_confirmation=>"12345678", :should_confirmation_password => true})
|
:password=>"12345678", :password_confirmation=>"12345678", :should_confirmation_password => true})
|
||||||
raise user.errors.full_messages.first if user.new_record?
|
raise user.errors.full_messages.first if user.new_record?
|
||||||
UserWechat.create!(
|
UserWechat.create!(
|
||||||
|
|
|
@ -27,8 +27,7 @@ module Mobile
|
||||||
post 'wxbind' do
|
post 'wxbind' do
|
||||||
openid = session[:wechat_openid]
|
openid = session[:wechat_openid]
|
||||||
logger.debug "openid ============== #{openid}"
|
logger.debug "openid ============== #{openid}"
|
||||||
# raise "无法获取到openid,请在微信中打开本页面" unless openid
|
raise "无法获取到openid,请在微信中打开本页面" unless openid
|
||||||
raise "请在微信中关注公众号'Trustie创新实践平台'后再打开本页面" unless openid
|
|
||||||
uw = UserWechat.where(openid: openid).first
|
uw = UserWechat.where(openid: openid).first
|
||||||
raise "此微信号已绑定用户(#{uw.user.login}), 不能重复绑定" if uw
|
raise "此微信号已绑定用户(#{uw.user.login}), 不能重复绑定" if uw
|
||||||
|
|
||||||
|
@ -56,8 +55,7 @@ module Mobile
|
||||||
post do
|
post do
|
||||||
openid = session[:wechat_openid]
|
openid = session[:wechat_openid]
|
||||||
logger.debug "openid ============== #{openid}"
|
logger.debug "openid ============== #{openid}"
|
||||||
# raise "无法获取到openid,请在微信中打开本页面" unless openid
|
raise "无法获取到openid,请在微信中打开本页面" unless openid
|
||||||
raise "请在微信中关注Trustie创新实践平台后再打开本页面" unless openid
|
|
||||||
|
|
||||||
uw = UserWechat.where(openid: openid).first
|
uw = UserWechat.where(openid: openid).first
|
||||||
if uw
|
if uw
|
||||||
|
|
|
@ -424,7 +424,13 @@ class WechatsController < ActionController::Base
|
||||||
|
|
||||||
session[:wechat_openid] = open_id
|
session[:wechat_openid] = open_id
|
||||||
if params[:code]
|
if params[:code]
|
||||||
redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}&userid=#{params[:userid]}" and return
|
if params[:userid]
|
||||||
|
redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}&userid=#{params[:userid]}" and return
|
||||||
|
elsif params[:id]
|
||||||
|
redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}" and return
|
||||||
|
else
|
||||||
|
redirect_to "/wechat/user_activities##{@path}" and return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
# end
|
# end
|
||||||
render 'wechats/user_activities', layout: nil
|
render 'wechats/user_activities', layout: nil
|
||||||
|
|
|
@ -117,7 +117,8 @@ app.controller('ProjectController', ['$scope', 'config','$http','$timeout', 'aut
|
||||||
rms.save("project_activities",vm.project_activities);
|
rms.save("project_activities",vm.project_activities);
|
||||||
rms.save('project_has_more', vm.project_has_more);
|
rms.save('project_has_more', vm.project_has_more);
|
||||||
rms.save("project",vm.project);
|
rms.save("project",vm.project);
|
||||||
$location.path('/'+type+'/'+act_id);
|
// $location.path('/'+type+'/'+act_id);
|
||||||
|
$location.path("/"+type).search({id: act_id});
|
||||||
};
|
};
|
||||||
|
|
||||||
//切换 按钮
|
//切换 按钮
|
||||||
|
|
Loading…
Reference in New Issue