Merge branch 'weixin_guange' into develop

This commit is contained in:
yuanke 2016-08-14 11:25:30 +08:00
commit 68b0ac39ee
3 changed files with 8 additions and 5 deletions

View File

@ -37,7 +37,7 @@ module Mobile
raise "此用户已经绑定过公众号, 请换一个帐户试试" if user.user_wechat
if uw && !user.real?
if uw && !uw.real?
uw.migrate_user(user)
else
UserWechat.create!(
@ -69,7 +69,7 @@ module Mobile
:should_confirmation_password => true)
raise user.errors.full_messages.first if user.new_record?
if uw && !user.real?
if uw && !uw.real?
user.update_attributes(:lastname=>uw.user[:lastname])
uw.migrate_user(user)
else

View File

@ -252,13 +252,16 @@ class WechatsController < ActionController::Base
end
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"
logger.info "tmpurl!!!!!!!!!!!!!!"
logger.info tmpurl
news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "欢迎使用Trustie创新实践服务平台
" } }
request.reply.news(news) do |article, n, index| # article is return object
url = "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#wechat_redirect"
url = tmpurl
pic_url = "#{ROOT_URL}/images/weixin_pic.jpg"
article.item title: "#{n[:title]}",
description: n[:content],

View File

@ -15,9 +15,9 @@ class UserWechat < ActiveRecord::Base
self.save
## 主要是将comment 迁移
User.delete(old_user)
User.delete(old_user)
JournalForMessages.where(user_id: old_user).update_all(user_id: u.id)
JournalsForMessage.where(user_id: old_user).update_all(user_id: u.id)
Journal.where(user_id: old_user).update_all(user_id: u.id)
Comment.where(author_id: old_user).update_all(author_id: u.id)
Message.where(author_id: old_user).update_all(author_id: u.id)