From 9d867aa22402cd7cd5a6836f3e577d40faa1d826 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 14 Aug 2016 11:50:31 +0800 Subject: [PATCH 01/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BE=AE=E4=BF=A1BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/new_comment.rb | 16 +++++++++++++++- app/controllers/wechats_controller.rb | 6 +++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb index e5e42e624..b8337451f 100644 --- a/app/api/mobile/apis/new_comment.rb +++ b/app/api/mobile/apis/new_comment.rb @@ -23,7 +23,21 @@ module Mobile refresh_token = session[:refresh_token] if access_token.present? && refresh_token.present? - refreshinfo = Wechat.api.web_refresh_access_token(refresh_token) + begin + refreshinfo = Wechat.api.web_refresh_access_token(refresh_token) + rescue + info = wechat.web_access_token(session[:wechat_code]) + openid =info["openid"] + access_token =info["access_token"] + if access_token + session[:access_token] = access_token + end + refresh_token = info["refresh_token"] + if refresh_token + session[:refresh_token] = refresh_token + end + refreshinfo = Wechat.api.web_refresh_access_token(refresh_token) + end access_token = refreshinfo["access_token"] refresh_token = refreshinfo["refresh_token"] diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index ced8854d9..3e81d491b 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -470,7 +470,11 @@ class WechatsController < ActionController::Base def user_binded?(openid) uw = UserWechat.where(openid: openid).first - uw && uw.bindtype == 0 + if uw.bindtype == 0 + uw + else + nil + end end def current_url From ba0d32bd09f916c7b5c9755234718d03fa8b3b9c Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 14 Aug 2016 11:59:26 +0800 Subject: [PATCH 02/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/new_comment.rb | 18 ++---------------- app/controllers/wechats_controller.rb | 2 +- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb index b8337451f..7a703bbc8 100644 --- a/app/api/mobile/apis/new_comment.rb +++ b/app/api/mobile/apis/new_comment.rb @@ -23,22 +23,8 @@ module Mobile refresh_token = session[:refresh_token] if access_token.present? && refresh_token.present? - begin - refreshinfo = Wechat.api.web_refresh_access_token(refresh_token) - rescue - info = wechat.web_access_token(session[:wechat_code]) - openid =info["openid"] - access_token =info["access_token"] - if access_token - session[:access_token] = access_token - end - refresh_token = info["refresh_token"] - if refresh_token - session[:refresh_token] = refresh_token - end - refreshinfo = Wechat.api.web_refresh_access_token(refresh_token) - end - + refreshinfo = Wechat.api.web_refresh_access_token(refresh_token) + access_token = refreshinfo["access_token"] refresh_token = refreshinfo["refresh_token"] session[:access_token] = access_token diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 3e81d491b..99ec193b0 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -470,7 +470,7 @@ class WechatsController < ActionController::Base def user_binded?(openid) uw = UserWechat.where(openid: openid).first - if uw.bindtype == 0 + if uw && uw.bindtype == 0 uw else nil From 962a62577b550e47d6a29073a5c562a531fa0c0d Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 14 Aug 2016 12:13:04 +0800 Subject: [PATCH 03/16] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/new_comment.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb index 7a703bbc8..549fd493f 100644 --- a/app/api/mobile/apis/new_comment.rb +++ b/app/api/mobile/apis/new_comment.rb @@ -23,7 +23,21 @@ module Mobile refresh_token = session[:refresh_token] if access_token.present? && refresh_token.present? - refreshinfo = Wechat.api.web_refresh_access_token(refresh_token) + begin + refreshinfo = Wechat.api.web_refresh_access_token(refresh_token) + rescue + info = wechat.web_access_token(session[:wechat_code]) + openid =info["openid"] + access_token =info["access_token"] + if access_token + session[:access_token] = access_token + end + refresh_token = info["refresh_token"] + if refresh_token + session[:refresh_token] = refresh_token + end + refreshinfo = Wechat.api.web_refresh_access_token(refresh_token) + end access_token = refreshinfo["access_token"] refresh_token = refreshinfo["refresh_token"] From 94777a42c4aa31cf93f9466e376077b533b02d6b Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 14 Aug 2016 12:16:30 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E8=8E=B7=E5=8F=96refresh=5Ftoken?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/new_comment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb index 549fd493f..02411c080 100644 --- a/app/api/mobile/apis/new_comment.rb +++ b/app/api/mobile/apis/new_comment.rb @@ -26,7 +26,7 @@ module Mobile begin refreshinfo = Wechat.api.web_refresh_access_token(refresh_token) rescue - info = wechat.web_access_token(session[:wechat_code]) + info = Wechat.api.web_access_token(session[:wechat_code]) openid =info["openid"] access_token =info["access_token"] if access_token From 6eca6253dbaade78cb83d01a18857932286dae02 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 14 Aug 2016 12:29:10 +0800 Subject: [PATCH 05/16] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=BF=80=E6=B4=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/new_comment.rb | 5 +++-- app/api/mobile/apis/users.rb | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb index 02411c080..872225e47 100644 --- a/app/api/mobile/apis/new_comment.rb +++ b/app/api/mobile/apis/new_comment.rb @@ -56,9 +56,10 @@ module Mobile user = us.register ({:login=>openid, :mail=>"#{openid}@163.com", :password=>"12345678", :password_confirmation=>"12345678", :should_confirmation_password => true}) - user.update_attributes(:lastname=>name) - raise user.errors.full_messages.first if user.new_record? + user.update_attributes(:lastname=>name) + #自动激活 + user = automatically_register(user) UserWechat.create!( openid: openid, user: user, diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index 62376dc6e..08f037588 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -2,6 +2,7 @@ module Mobile module Apis class Users < Grape::API + include AccountHelper resource :users do desc "查询是否已绑定" @@ -68,6 +69,8 @@ module Mobile user = us.register params.merge(:password_confirmation => params[:password], :should_confirmation_password => true) raise user.errors.full_messages.first if user.new_record? + #自动激活 + user = automatically_register(user) if uw && !uw.real? user.update_attributes(:lastname=>uw.user[:lastname]) From 0fc6b845844e2f60b46109790b42a2ae5e80bd14 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 14 Aug 2016 12:32:47 +0800 Subject: [PATCH 06/16] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=BF=80=E6=B4=BB?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/new_comment.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb index 872225e47..ad02762d4 100644 --- a/app/api/mobile/apis/new_comment.rb +++ b/app/api/mobile/apis/new_comment.rb @@ -5,6 +5,7 @@ module Mobile class NewComment< Grape::API include ApplicationHelper include ApiHelper + include AccountHelper resources :new_comment do desc "add a new comment" From f50cfe159c7a8079239baed213f54c7a58386ef2 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 14 Aug 2016 12:35:03 +0800 Subject: [PATCH 07/16] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user_wechat.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/user_wechat.rb b/app/models/user_wechat.rb index 8328a47df..c63411ab3 100644 --- a/app/models/user_wechat.rb +++ b/app/models/user_wechat.rb @@ -22,5 +22,6 @@ class UserWechat < ActiveRecord::Base Comment.where(author_id: old_user).update_all(author_id: u.id) Message.where(author_id: old_user).update_all(author_id: u.id) BlogComment.where(author_id: old_user).update_all(author_id: u.id) + UserActivity.where(user_id: old_user).update_all(user_id: u.id) end end From e17683d3d5a7f51fa2fcb5c253bd72846b8ad1ca Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 14 Aug 2016 12:42:39 +0800 Subject: [PATCH 08/16] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=BF=80=E6=B4=BB?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=B8=90=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/new_comment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb index ad02762d4..d4a156271 100644 --- a/app/api/mobile/apis/new_comment.rb +++ b/app/api/mobile/apis/new_comment.rb @@ -60,7 +60,7 @@ module Mobile raise user.errors.full_messages.first if user.new_record? user.update_attributes(:lastname=>name) #自动激活 - user = automatically_register(user) + user = AccountHelper.automatically_register(user) UserWechat.create!( openid: openid, user: user, From 22e4e56029597c8e9ca7e391a5877dc3be89d1fc Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 14 Aug 2016 13:24:07 +0800 Subject: [PATCH 09/16] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=BF=80=E6=B4=BB=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/new_comment.rb | 10 ++++++++-- app/api/mobile/apis/users.rb | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb index d4a156271..228fee157 100644 --- a/app/api/mobile/apis/new_comment.rb +++ b/app/api/mobile/apis/new_comment.rb @@ -5,7 +5,6 @@ module Mobile class NewComment< Grape::API include ApplicationHelper include ApiHelper - include AccountHelper resources :new_comment do desc "add a new comment" @@ -17,6 +16,7 @@ module Mobile unless current_user #如果当前用户不存在 则需要根据微信昵称注册一个帐号 openid = session[:wechat_openid] + openid = "asfsdf" raise "无法获取到openid,请在微信中打开本页面" unless openid us = UsersService.new @@ -60,7 +60,13 @@ module Mobile raise user.errors.full_messages.first if user.new_record? user.update_attributes(:lastname=>name) #自动激活 - user = AccountHelper.automatically_register(user) + if Setting.self_registration != '3' + user.activate + user.last_login_on = Time.now + if user.save + UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0) + end + end UserWechat.create!( openid: openid, user: user, diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index 08f037588..53884f779 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -2,7 +2,6 @@ module Mobile module Apis class Users < Grape::API - include AccountHelper resource :users do desc "查询是否已绑定" @@ -70,7 +69,14 @@ module Mobile :should_confirmation_password => true) raise user.errors.full_messages.first if user.new_record? #自动激活 - user = automatically_register(user) + if Setting.self_registration != '3' + # user = automatically_register(user) + user.activate + user.last_login_on = Time.now + if user.save + UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0) + end + end if uw && !uw.real? user.update_attributes(:lastname=>uw.user[:lastname]) From 2f8b459a6f67efaa9fd2f25e6142674d2585e96d Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 14 Aug 2016 13:35:00 +0800 Subject: [PATCH 10/16] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=BF=80=E6=B4=BB=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/new_comment.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb index 228fee157..6d46b2f59 100644 --- a/app/api/mobile/apis/new_comment.rb +++ b/app/api/mobile/apis/new_comment.rb @@ -16,7 +16,6 @@ module Mobile unless current_user #如果当前用户不存在 则需要根据微信昵称注册一个帐号 openid = session[:wechat_openid] - openid = "asfsdf" raise "无法获取到openid,请在微信中打开本页面" unless openid us = UsersService.new From f9ee56111fc44d0742a75c12d306b0c775566ed8 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 14 Aug 2016 13:46:46 +0800 Subject: [PATCH 11/16] . --- Gemfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 39a181d05..80c0e1c2a 100644 --- a/Gemfile +++ b/Gemfile @@ -50,16 +50,16 @@ gem 'elasticsearch-model' gem 'elasticsearch-rails' #rails 3.2.22.2 bug - # gem "test-unit", "~>3.0" + gem "test-unit", "~>3.0" ### profile - # gem 'oneapm_rpm' + gem 'oneapm_rpm' group :development do gem 'grape-swagger' gem 'better_errors', '~> 1.1.0' # gem "query_reviewer" - # gem 'rack-mini-profiler', '~> 0.9.3' + gem 'rack-mini-profiler', '~> 0.9.3' if RUBY_PLATFORM =~ /w32/ gem 'win32console' end From 7e40c2447f2ddabfc1e0c2d423bbc505f2a6711e Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 14 Aug 2016 15:25:46 +0800 Subject: [PATCH 12/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=B8=90=E5=8F=B7=E6=98=BE=E7=A4=BA=EF=BC=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/users.rb | 4 ++-- app/controllers/wechats_controller.rb | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index 53884f779..764dc957f 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -47,7 +47,7 @@ module Mobile end ws = WechatService.new - ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台。", user.login+"("+user.show_name+")", Time.now.strftime("%Y-%m-%d")) + ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台。", user.show_name+"("+user.login+")", Time.now.strftime("%Y-%m-%d")) present status: 0, message: '您已成功绑定Trustie平台' end @@ -89,7 +89,7 @@ module Mobile end ws = WechatService.new - ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台。", user.login+"("+user.show_name+")", Time.now.strftime("%Y-%m-%d")) + ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台。", user.show_name+"("+user.login+")", Time.now.strftime("%Y-%m-%d")) present :data, user, with: Mobile::Entities::User present :status, 0 end diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 99ec193b0..0226e703c 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -386,7 +386,7 @@ class WechatsController < ActionController::Base user: user ) ws = WechatService.new - ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台!", user.login+"("+user.show_name+")", format_time(Time.now)) + ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台!", user.show_name+"("+user.login+")", format_time(Time.now)) render :json => {status:0, msg: "绑定成功"} rescue Exception=>e render :json => {status: -1, msg: e.message} @@ -416,9 +416,9 @@ class WechatsController < ActionController::Base render 'wechats/open_wechat', layout: nil and return end - # unless user_binded?(open_id) - # @path = '/login' - # else + unless user_binded?(open_id) && params[:state] != "invite_code" && params[:state] != "project_invite_code" && params[:state] != "blog_comment" && params[:state] != "course_notice" && params[:state] != "project_discussion" && params[:state] != "course_discussion" && params[:state] != "homework" && params[:state] != "issues" && params[:state] != "journal_for_message" + @path = '/login' + else if params[:state] == 'myclass' @course_id = params[:id]; elsif params[:state] == 'myproject' @@ -436,7 +436,7 @@ class WechatsController < ActionController::Base end # redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}" and return end - # end + end render 'wechats/user_activities', layout: nil end From 2659b742fd6c0928007cb44f166d3872da2c78d6 Mon Sep 17 00:00:00 2001 From: Tim Date: Sun, 14 Aug 2016 15:30:57 +0800 Subject: [PATCH 13/16] =?UTF-8?q?=E6=88=90=E5=91=98=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=A4=B4=E5=83=8F=E9=AB=98=E5=BA=A6=E4=B8=8D=E4=B8=80=E8=87=B4?= =?UTF-8?q?=EF=BC=9B=E9=82=80=E8=AF=B7=E5=86=85=E5=AE=B9=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/class.html | 6 +- public/assets/wechat/project.html | 10 +- .../wechat/controllers/invite_code.js | 2 +- .../wechat/controllers/project_invite_code.js | 2 +- public/javascripts/wechat/others/factory.js | 932 +++++++++--------- 5 files changed, 476 insertions(+), 476 deletions(-) diff --git a/public/assets/wechat/class.html b/public/assets/wechat/class.html index f93168206..e720c90c9 100644 --- a/public/assets/wechat/class.html +++ b/public/assets/wechat/class.html @@ -31,7 +31,7 @@
授课老师
- {{teacher.name}} + {{teacher.name}} 管理员 助教 @@ -39,7 +39,7 @@
- {{reviewer.name}} + {{reviewer.name}} 待审批 ▶
@@ -47,7 +47,7 @@
我的同学
- {{student.name}} + {{student.name}}
diff --git a/public/assets/wechat/project.html b/public/assets/wechat/project.html index 3af3ce9c6..733f0899d 100644 --- a/public/assets/wechat/project.html +++ b/public/assets/wechat/project.html @@ -108,30 +108,30 @@
管理人员({{project_master_members.length}})
- {{master.user.real_name == "" ? master.user.name : master.user.real_name }} + {{master.user.real_name == "" ? master.user.name : master.user.real_name }}
- {{user.real_name == "" ? user.name : user.real_name }} + {{user.real_name == "" ? user.name : user.real_name }} 待审批 ▶
开发人员({{project_develop_members.length}})
- {{develop.user.real_name == "" ? develop.user.name : develop.user.real_name}} + {{develop.user.real_name == "" ? develop.user.name : develop.user.real_name}}
- {{user.real_name == "" ? user.name : user.real_name}} + {{user.real_name == "" ? user.name : user.real_name}} 待审批 ▶
报告人员({{project_report_members.length}})
- {{report.user.real_name == "" ? report.user.name : report.user.real_name}} + {{report.user.real_name == "" ? report.user.name : report.user.real_name}}
diff --git a/public/javascripts/wechat/controllers/invite_code.js b/public/javascripts/wechat/controllers/invite_code.js index 512e506e8..4722916bd 100644 --- a/public/javascripts/wechat/controllers/invite_code.js +++ b/public/javascripts/wechat/controllers/invite_code.js @@ -13,7 +13,7 @@ app.controller('InviteCodeController', ['$scope','$http', '$routeParams','config console.log(response.data); vm.course = response.data.data; - var desc = "您的好友邀请您加入班级:\n"+vm.course.name+"\n和小伙伴一起踏上便捷的学习之旅吧!"; + var desc = "您的好友邀请您加入班级:\n"+vm.course.name+" \n和小伙伴一起踏上便捷的学习之旅吧!"; var link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+window.g_appid+ "&redirect_uri="+window.g_localhost+"/wechat/user_activities?id="+vm.course.id+ "&response_type=code&scope=snsapi_base&state=invite_code&connect_redirect=1#wechat_redirect"; diff --git a/public/javascripts/wechat/controllers/project_invite_code.js b/public/javascripts/wechat/controllers/project_invite_code.js index 8058797f1..20323e39c 100644 --- a/public/javascripts/wechat/controllers/project_invite_code.js +++ b/public/javascripts/wechat/controllers/project_invite_code.js @@ -13,7 +13,7 @@ app.controller('ProjectInviteCodeController', ['$scope','$http', '$routeParams', console.log(response.data); vm.project = response.data.data; - var desc = "您的好友邀请您加入项目:\n"+vm.project.name+"\n和小伙伴一起踏上便捷的研发之旅吧!"; + var desc = "您的好友邀请您加入项目:\n"+vm.project.name+" \n和小伙伴一起踏上便捷的研发之旅吧!"; var link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+window.g_appid+ "&redirect_uri="+window.g_localhost+"/wechat/user_activities?id="+vm.project.id+ "&response_type=code&scope=snsapi_base&state=project_invite_code&connect_redirect=1#wechat_redirect"; diff --git a/public/javascripts/wechat/others/factory.js b/public/javascripts/wechat/others/factory.js index e6ffcf76c..1c40c9c10 100644 --- a/public/javascripts/wechat/others/factory.js +++ b/public/javascripts/wechat/others/factory.js @@ -1,466 +1,466 @@ -app.factory('alertService', function(){ - function Alert(){ - this.title = null; - this.message = null; - this.visible = null; - this.cb = null; - this.invite = ""; - } - - Alert.prototype.showMessage = function(title, msg, cb){ - this.message = msg; - this.title = title; - this.visible = true; - this.cb = cb; - this.invite = ""; - } - - Alert.prototype.dismiss = function(){ - this.message = null; - this.title = null; - this.visible = false; - this.invite = ""; - if(this.cb) {this.cb();} - } - - return { - create: function(){ - return new Alert(); - } - } -}); - -app.factory('wx', ['$window', function($window){ - var wechat = $window.wx; - return wechat; -}]); - -app.factory('auth', ['$http','$routeParams', '$q', 'session', 'config',function($http,$routeParams, $q, session,config){ - //是否已经绑定 - var isBind = function(){ - var defer = $q.defer(); - - var token = getToken(); - if(token && token.length>10){ - defer.resolve(token); - } else { - var code = window.g_code || $routeParams.code || session.get("code"); - $http.post( - '/wechat/get_bind', - {} ///不用传code了,都由服务器来处理 - ).then(function(response){ - if(response.data.status!=0){ - defer.reject(response.data.message); - }else { - session.save("token", response.data.token); - defer.resolve(response.data.token); - } - }).catch(function(e){ - defer.reject(e); - }); - } - - return defer.promise; - } - - var getToken = function(){ - return 'token';//session.get("token"); - } - return {get_bind: isBind, token: getToken}; -}]); - -app.factory("session", function(){ - return { - save: function(key,value){ - sessionStorage.setItem(key,value); - }, - get: function(key){ - return sessionStorage.getItem(key); - } - } -}); - -app.factory('rms', function(){ - var _saveStorage = {}; - var save = function(key, value){ - _saveStorage[key] = value; - }; - - var get = function(key){ - return _saveStorage[key]; - }; - - return {save: save, get: get}; -}); - -app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$location', function($http, auth, $routeParams,rms,config,wx,$location){ - var addCommonReply = function(id, type, data,args, cb){ - //先判断有没有绑定 -// $http.post( -// '/wechat/is_bind', -// {} ///不用传code了,都由服务器来处理 -// ).then(function(response){ -// console.log(response.data); -// if(response.data.status != 0){ -// $location.path("/login_tip"); -// } -// }); - - if(!data.comment || data.comment.length<=0){ - return; - } - - var temp = data.comment.replace(/\n/g,'
'); - - var userInfo = { - type: type, - content: temp, - token: auth.token() - }; - //回复按钮禁用 - data.disabled = true; - - $http({ - method: 'POST', - url: apiUrl+ "new_comment/"+id, - data: userInfo - }).then(function successCallback(response) { - //alert("提交成功"); - //数据提交完成,回复按钮启用 - console.log(response); - if(response.data.status == -1){ - console.log("回复失败!"); - data.comment = ""; - if(response.data.tip == 0){ - args.scope.replytip = "您不是该私有班级成员,不能回复"; - } - else{ - args.scope.replytip = "您不是该私有项目成员,不能回复"; - } - return; - } - - data.disabled = false; - if(typeof cb === 'function'){ - cb(response.data.subscribe); - } - - //保证内外回复数一致 - activities = rms.get("activities") || []; - course_activities = rms.get("course_activities") || []; - project_activities = rms.get("project_activities") || []; - for(var i in activities){ - if(activities[i].act_id == id){ - activities[i].reply_count += 1; - break; - } - } - for(var i in course_activities){ - if(course_activities[i].act_id == id){ - course_activities[i].reply_count += 1; - break; - } - } - for(var i in project_activities){ - if(project_activities[i].act_id == id){ - project_activities[i].reply_count += 1; - break; - } - } - rms.save("activities",activities); - rms.save("course_activities",course_activities); - rms.save("project_activities",project_activities); - - }, function errorCallback(response) { - }); - }; - -// var loadCommonData = function(id, type,replytype,page){ -// return $http({ -// method: 'GET', -// url: apiUrl+ type + "/" + id+"?token="+auth.token(), -// }) -// }; - - var loadCommonData = function(id, type,replytype,page){ - return $http({ - method: 'POST', - url: apiUrl+ type + "/" + id, - dataType: 'jsonp', - data:{token:auth.token(),type:replytype,page:page} - }) - }; - - var addCommonPraise = function(act){ -// act.praise_count += 1; -// act.has_praise = true; - - $http({ - method: 'POST', - url: apiUrl + "praise/" + act.act_id, - data:{token:auth.token(),type:act.act_type} - }).then(function successCallback(response) { - console.log(response.data); - }, function errorCallback(response) { - }); - - }; - - var decreaseCommonPraise = function(act){ -// act.praise_count -= 1; -// act.has_praise = false; - $http({ - method: 'POST', - url: apiUrl + "praise/" + act.act_id, - data:{token:auth.token(),type:act.act_type} - }).then(function successCallback(response) { - console.log(response.data); - }, function errorCallback(response) { - }); - }; - - var init = function(args){ - args.scope.replytip = "输入回复内容~"; - args.scope.formData = {comment: ''}; - var loadData = function(id,replytype,page){ - loadCommonData(id, args.type,replytype,page).then(function successCallback(response) { - console.log(response.data); - //--------------分享内容定制------------- - var tmptile = "分享动态"; - var imgUrl = ""; - - if(response.data.data.title){ - tmptile = response.data.data.title; - } - - var tmpname = "匿名用户"; - - if(response.data.data.user){ - tmpname = response.data.data.user.realname; - imgUrl = window.g_localhost+response.data.data.user.img_url; - } - - if(response.data.data.author){ - tmpname = response.data.data.author.realname; - imgUrl = window.g_localhost+response.data.data.author.img_url; - } - - var desc = "" - if(response.data.data.content){ - desc = response.data.data.content.replace(/<[^>]+>/g,"").replace(/\s*/g,"").replace(/ /g,""); - } - - if(response.data.data.description){ - desc = response.data.data.description.replace(/<[^>]+>/g,"").replace(/\s*/g,"").replace(/ /g,""); - } - - if(desc.length > 30){ - desc = desc.substring(0,30)+"..."; - } - - var title = tmpname+":"+tmptile; - console.log("desc = "+desc); - console.log("imgUrl= "+imgUrl); - - var link = ""; - - if(args.urlName == "discussion"){ - var urlName = response.data.type_name + "_discussion"; - link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+window.g_appid + - "&redirect_uri="+window.g_localhost+"/wechat/user_activities?id="+response.data.data.act_id+ - "&response_type=code&scope=snsapi_userinfo&state="+urlName+"&connect_redirect=1#wechat_redirect"; - } - else{ - link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+window.g_appid + - "&redirect_uri="+window.g_localhost+"/wechat/user_activities?id="+response.data.data.act_id+ - "&response_type=code&scope=snsapi_userinfo&state="+args.urlName+"&connect_redirect=1#wechat_redirect"; - } - -// if(args.urlName == "discussion"){ -// var urlName = response.data.type_name + "_discussion"; -// link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d" + -// "&redirect_uri=https://test.forge.trustie.net/wechat/user_activities?id="+response.data.data.act_id+ -// "&response_type=code&scope=snsapi_base&state="+urlName+"&connect_redirect=1#wechat_redirect"; -// } -// else{ -// link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d" + -// "&redirect_uri=https://test.forge.trustie.net/wechat/user_activities?id="+response.data.data.act_id+ -// "&response_type=code&scope=snsapi_base&state="+args.urlName+"&connect_redirect=1#wechat_redirect"; -// } - - console.log("link= "+link); - - wxConfig(title,desc,imgUrl,link); - - //--------------分享内容定制------------- - args.loadCallback(response.data); - }, function errorCallback(response) { - }); - }; - - loadData(args.id,0,0); - args.scope.addReply = function(data){ - console.log(data.comment); - addCommonReply(args.id, args.replyType, data,args, function(subscribe){ - args.scope.formData = {comment: ''}; - if(subscribe == 0){ - $location.path("/login_tip"); - return; - } - else{ - loadData(args.id,0,0); - } - - if(typeof args.replyCallback === 'function'){ - args.replyCallback(); - } - }); - }; - -// 动态详情界面点赞与动态界面的数据要同步 保证进入详情点赞后出来显示一致 - args.scope.addPraise = function(act){ - activities = rms.get("activities") || []; - course_activities = rms.get("course_activities") || []; - project_activities = rms.get("project_activities") || []; - for(var i in activities){ - if(activities[i].act_id == act.act_id){ - activities[i].praise_count += 1; - activities[i].has_praise = true; - break; - } - } - for(var i in course_activities){ - if(course_activities[i].act_id == act.act_id){ - course_activities[i].praise_count += 1; - course_activities[i].has_praise = true; - break; - } - } - for(var i in project_activities){ - if(project_activities[i].act_id == act.act_id){ - project_activities[i].praise_count += 1; - project_activities[i].has_praise = true; - break; - } - } - rms.save("activities",activities); - rms.save("course_activities",course_activities); - rms.save("project_activities",project_activities); - - act.praise_count += 1; - act.has_praise = true; - addCommonPraise(act); - }; - - args.scope.decreasePraise = function(act){ - activities = rms.get("activities") || []; - course_activities = rms.get("course_activities") || []; - project_activities = rms.get("project_activities") || []; - for(var i in activities){ - if(activities[i].act_id == act.act_id){ - activities[i].praise_count -= 1; - activities[i].has_praise = false; - break; - } - } - for(var i in course_activities){ - if(course_activities[i].act_id == act.act_id){ - course_activities[i].praise_count -= 1; - course_activities[i].has_praise = false; - break; - } - } - for(var i in project_activities){ - if(project_activities[i].act_id == act.act_id){ - project_activities[i].praise_count -= 1; - project_activities[i].has_praise = false; - break; - } - } - rms.save("activities",activities); - rms.save("course_activities",course_activities); - rms.save("project_activities",project_activities); - - act.praise_count -= 1; - act.has_praise = false; - decreaseCommonPraise(act); - }; - - args.scope.showMoreReply = function(replytype,data){ - if(!data.page){ - data.page = 1; - } - else{ - data.page = data.page + 1; - } - - loadCommonData(data.id, args.type,replytype,data.page).then(function successCallback(response) { - args.loadCallback(response.data); - }, function errorCallback(response) { - }); - }; - - args.scope.commentreply_path = config.rootPath+ 'templates/comment_reply.html'; - - }; - - var wxConfig = function(title,desc,imgUrl,link){ - - if(title == null || title == ""){ - title = 'Trustie创新实践平台'; - } - - if(desc == null || desc == ""){ - desc = 'Trustie创新实践平台'; - } - - if(imgUrl == null || imgUrl == ""){ - imgUrl = window.g_localhost+'/images/wechat/wx_logo.jpg'; - } - - wx.ready(function(){ - wx.onMenuShareTimeline({ - title: title, // 分享标题 - link: link, // 分享链接 - imgUrl: imgUrl, // 分享图标 - success: function () { - console.log("share successed."); - }, - cancel: function () { - console.log("share canceled."); - } - }); - - wx.onMenuShareAppMessage({ - title: title, // 分享标题 - desc: desc, // 分享描述 - link: link, // 分享链接 -// imgUrl: '', // 分享图标 - imgUrl: imgUrl, // 分享图标 -// type: '', // 分享类型,music、video或link,不填默认为link -// dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空 - success: function () { - // 用户确认分享后执行的回调函数 - }, - cancel: function () { - // 用户取消分享后执行的回调函数 - } - }); - }); - }; - - var checkLogin = function(){ - $http.post( - '/wechat/is_bind', - {} ///不用传code了,都由服务器来处理 - ).then(function(response){ - console.log(response.data); - if(response.data.status != 0){ - $location.path("/login"); - return; - } - }); - }; - - return {init: init, addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise, wxConfig: wxConfig, checkLogin: checkLogin}; -}]); +app.factory('alertService', function(){ + function Alert(){ + this.title = null; + this.message = null; + this.visible = null; + this.cb = null; + this.invite = ""; + } + + Alert.prototype.showMessage = function(title, msg, cb){ + this.message = msg; + this.title = title; + this.visible = true; + this.cb = cb; + this.invite = ""; + } + + Alert.prototype.dismiss = function(){ + this.message = null; + this.title = null; + this.visible = false; + this.invite = ""; + if(this.cb) {this.cb();} + } + + return { + create: function(){ + return new Alert(); + } + } +}); + +app.factory('wx', ['$window', function($window){ + var wechat = $window.wx; + return wechat; +}]); + +app.factory('auth', ['$http','$routeParams', '$q', 'session', 'config',function($http,$routeParams, $q, session,config){ + //是否已经绑定 + var isBind = function(){ + var defer = $q.defer(); + + var token = getToken(); + if(token && token.length>10){ + defer.resolve(token); + } else { + var code = window.g_code || $routeParams.code || session.get("code"); + $http.post( + '/wechat/get_bind', + {} ///不用传code了,都由服务器来处理 + ).then(function(response){ + if(response.data.status!=0){ + defer.reject(response.data.message); + }else { + session.save("token", response.data.token); + defer.resolve(response.data.token); + } + }).catch(function(e){ + defer.reject(e); + }); + } + + return defer.promise; + } + + var getToken = function(){ + return 'token';//session.get("token"); + } + return {get_bind: isBind, token: getToken}; +}]); + +app.factory("session", function(){ + return { + save: function(key,value){ + sessionStorage.setItem(key,value); + }, + get: function(key){ + return sessionStorage.getItem(key); + } + } +}); + +app.factory('rms', function(){ + var _saveStorage = {}; + var save = function(key, value){ + _saveStorage[key] = value; + }; + + var get = function(key){ + return _saveStorage[key]; + }; + + return {save: save, get: get}; +}); + +app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$location', function($http, auth, $routeParams,rms,config,wx,$location){ + var addCommonReply = function(id, type, data,args, cb){ + //先判断有没有绑定 +// $http.post( +// '/wechat/is_bind', +// {} ///不用传code了,都由服务器来处理 +// ).then(function(response){ +// console.log(response.data); +// if(response.data.status != 0){ +// $location.path("/login_tip"); +// } +// }); + + if(!data.comment || data.comment.length<=0){ + return; + } + + var temp = data.comment.replace(/\n/g,'
'); + + var userInfo = { + type: type, + content: temp, + token: auth.token() + }; + //回复按钮禁用 + data.disabled = true; + + $http({ + method: 'POST', + url: apiUrl+ "new_comment/"+id, + data: userInfo + }).then(function successCallback(response) { + //alert("提交成功"); + //数据提交完成,回复按钮启用 + console.log(response); + if(response.data.status == -1){ + console.log("回复失败!"); + data.comment = ""; + if(response.data.tip == 0){ + args.scope.replytip = "您不是该私有班级成员,不能回复"; + } + else{ + args.scope.replytip = "您不是该私有项目成员,不能回复"; + } + return; + } + + data.disabled = false; + if(typeof cb === 'function'){ + cb(response.data.subscribe); + } + + //保证内外回复数一致 + activities = rms.get("activities") || []; + course_activities = rms.get("course_activities") || []; + project_activities = rms.get("project_activities") || []; + for(var i in activities){ + if(activities[i].act_id == id){ + activities[i].reply_count += 1; + break; + } + } + for(var i in course_activities){ + if(course_activities[i].act_id == id){ + course_activities[i].reply_count += 1; + break; + } + } + for(var i in project_activities){ + if(project_activities[i].act_id == id){ + project_activities[i].reply_count += 1; + break; + } + } + rms.save("activities",activities); + rms.save("course_activities",course_activities); + rms.save("project_activities",project_activities); + + }, function errorCallback(response) { + }); + }; + +// var loadCommonData = function(id, type,replytype,page){ +// return $http({ +// method: 'GET', +// url: apiUrl+ type + "/" + id+"?token="+auth.token(), +// }) +// }; + + var loadCommonData = function(id, type,replytype,page){ + return $http({ + method: 'POST', + url: apiUrl+ type + "/" + id, + dataType: 'jsonp', + data:{token:auth.token(),type:replytype,page:page} + }) + }; + + var addCommonPraise = function(act){ +// act.praise_count += 1; +// act.has_praise = true; + + $http({ + method: 'POST', + url: apiUrl + "praise/" + act.act_id, + data:{token:auth.token(),type:act.act_type} + }).then(function successCallback(response) { + console.log(response.data); + }, function errorCallback(response) { + }); + + }; + + var decreaseCommonPraise = function(act){ +// act.praise_count -= 1; +// act.has_praise = false; + $http({ + method: 'POST', + url: apiUrl + "praise/" + act.act_id, + data:{token:auth.token(),type:act.act_type} + }).then(function successCallback(response) { + console.log(response.data); + }, function errorCallback(response) { + }); + }; + + var init = function(args){ + args.scope.replytip = "输入回复内容~"; + args.scope.formData = {comment: ''}; + var loadData = function(id,replytype,page){ + loadCommonData(id, args.type,replytype,page).then(function successCallback(response) { + console.log(response.data); + //--------------分享内容定制------------- + var tmptile = "分享动态"; + var imgUrl = ""; + + if(response.data.data.title){ + tmptile = response.data.data.title; + } + + var tmpname = "匿名用户"; + + if(response.data.data.user){ + tmpname = response.data.data.user.realname; + imgUrl = window.g_localhost+response.data.data.user.img_url; + } + + if(response.data.data.author){ + tmpname = response.data.data.author.realname; + imgUrl = window.g_localhost+response.data.data.author.img_url; + } + + var desc = "" + if(response.data.data.content){ + desc = response.data.data.content.replace(/<[^>]+>/g,"").replace(/\s*/g,"").replace(/ /g,""); + } + + if(response.data.data.description){ + desc = response.data.data.description.replace(/<[^>]+>/g,"").replace(/\s*/g,"").replace(/ /g,""); + } + + if(desc.length > 30){ + desc = desc.substring(0,30)+"..."; + } + + var title = tmpname+":"+tmptile; + console.log("desc = "+desc); + console.log("imgUrl= "+imgUrl); + + var link = ""; + + if(args.urlName == "discussion"){ + var urlName = response.data.type_name + "_discussion"; + link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+window.g_appid + + "&redirect_uri="+window.g_localhost+"/wechat/user_activities?id="+response.data.data.act_id+ + "&response_type=code&scope=snsapi_userinfo&state="+urlName+"&connect_redirect=1#wechat_redirect"; + } + else{ + link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+window.g_appid + + "&redirect_uri="+window.g_localhost+"/wechat/user_activities?id="+response.data.data.act_id+ + "&response_type=code&scope=snsapi_userinfo&state="+args.urlName+"&connect_redirect=1#wechat_redirect"; + } + +// if(args.urlName == "discussion"){ +// var urlName = response.data.type_name + "_discussion"; +// link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d" + +// "&redirect_uri=https://test.forge.trustie.net/wechat/user_activities?id="+response.data.data.act_id+ +// "&response_type=code&scope=snsapi_base&state="+urlName+"&connect_redirect=1#wechat_redirect"; +// } +// else{ +// link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d" + +// "&redirect_uri=https://test.forge.trustie.net/wechat/user_activities?id="+response.data.data.act_id+ +// "&response_type=code&scope=snsapi_base&state="+args.urlName+"&connect_redirect=1#wechat_redirect"; +// } + + console.log("link= "+link); + + wxConfig(title,desc,imgUrl,link); + + //--------------分享内容定制------------- + args.loadCallback(response.data); + }, function errorCallback(response) { + }); + }; + + loadData(args.id,0,0); + args.scope.addReply = function(data){ + console.log(data.comment); + addCommonReply(args.id, args.replyType, data,args, function(subscribe){ + args.scope.formData = {comment: ''}; + if(subscribe == 0){ + $location.path("/login_tip"); + return; + } + else{ + loadData(args.id,0,0); + } + + if(typeof args.replyCallback === 'function'){ + args.replyCallback(); + } + }); + }; + +// 动态详情界面点赞与动态界面的数据要同步 保证进入详情点赞后出来显示一致 + args.scope.addPraise = function(act){ + activities = rms.get("activities") || []; + course_activities = rms.get("course_activities") || []; + project_activities = rms.get("project_activities") || []; + for(var i in activities){ + if(activities[i].act_id == act.act_id){ + activities[i].praise_count += 1; + activities[i].has_praise = true; + break; + } + } + for(var i in course_activities){ + if(course_activities[i].act_id == act.act_id){ + course_activities[i].praise_count += 1; + course_activities[i].has_praise = true; + break; + } + } + for(var i in project_activities){ + if(project_activities[i].act_id == act.act_id){ + project_activities[i].praise_count += 1; + project_activities[i].has_praise = true; + break; + } + } + rms.save("activities",activities); + rms.save("course_activities",course_activities); + rms.save("project_activities",project_activities); + + act.praise_count += 1; + act.has_praise = true; + addCommonPraise(act); + }; + + args.scope.decreasePraise = function(act){ + activities = rms.get("activities") || []; + course_activities = rms.get("course_activities") || []; + project_activities = rms.get("project_activities") || []; + for(var i in activities){ + if(activities[i].act_id == act.act_id){ + activities[i].praise_count -= 1; + activities[i].has_praise = false; + break; + } + } + for(var i in course_activities){ + if(course_activities[i].act_id == act.act_id){ + course_activities[i].praise_count -= 1; + course_activities[i].has_praise = false; + break; + } + } + for(var i in project_activities){ + if(project_activities[i].act_id == act.act_id){ + project_activities[i].praise_count -= 1; + project_activities[i].has_praise = false; + break; + } + } + rms.save("activities",activities); + rms.save("course_activities",course_activities); + rms.save("project_activities",project_activities); + + act.praise_count -= 1; + act.has_praise = false; + decreaseCommonPraise(act); + }; + + args.scope.showMoreReply = function(replytype,data){ + if(!data.page){ + data.page = 1; + } + else{ + data.page = data.page + 1; + } + + loadCommonData(data.id, args.type,replytype,data.page).then(function successCallback(response) { + args.loadCallback(response.data); + }, function errorCallback(response) { + }); + }; + + args.scope.commentreply_path = config.rootPath+ 'templates/comment_reply.html'; + + }; + + var wxConfig = function(title,desc,imgUrl,link){ + + if(title == null || title == ""){ + title = 'Trustie创新实践平台'; + } + + if(desc == null || desc == ""){ + desc = 'Trustie创新实践平台'; + } + + if(imgUrl == null || imgUrl == ""){ + imgUrl = window.g_localhost+'/images/wechat/wx_logo.jpg'; + } + + wx.ready(function(){ + wx.onMenuShareTimeline({ + title: title, // 分享标题 + link: link, // 分享链接 + imgUrl: imgUrl, // 分享图标 + success: function () { + console.log("share successed."); + }, + cancel: function () { + console.log("share canceled."); + } + }); + + wx.onMenuShareAppMessage({ + title: title, // 分享标题 + desc: desc, // 分享描述 + link: link, // 分享链接 +// imgUrl: '', // 分享图标 + imgUrl: imgUrl, // 分享图标 +// type: '', // 分享类型,music、video或link,不填默认为link +// dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空 + success: function () { + // 用户确认分享后执行的回调函数 + }, + cancel: function () { + // 用户取消分享后执行的回调函数 + } + }); + }); + }; + + var checkLogin = function(){ + $http.post( + '/wechat/is_bind', + {} ///不用传code了,都由服务器来处理 + ).then(function(response){ + console.log(response.data); + if(response.data.status != 0){ + $location.path("/login"); + return; + } + }); + }; + + return {init: init, addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise, wxConfig: wxConfig, checkLogin: checkLogin}; +}]); From a7ef293356e130d7fb81cca9683cff67a074c3b8 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 14 Aug 2016 15:33:24 +0800 Subject: [PATCH 14/16] . --- app/controllers/wechats_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 0226e703c..f8cfb755d 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -416,7 +416,7 @@ class WechatsController < ActionController::Base render 'wechats/open_wechat', layout: nil and return end - unless user_binded?(open_id) && params[:state] != "invite_code" && params[:state] != "project_invite_code" && params[:state] != "blog_comment" && params[:state] != "course_notice" && params[:state] != "project_discussion" && params[:state] != "course_discussion" && params[:state] != "homework" && params[:state] != "issues" && params[:state] != "journal_for_message" + unless (user_binded?(open_id) || params[:state] == "invite_code" || params[:state] == "project_invite_code" || params[:state] == "blog_comment" || params[:state] == "course_notice" || params[:state] == "project_discussion" || params[:state] == "course_discussion" || params[:state] == "homework" || params[:state] == "issues" || params[:state] == "journal_for_message") @path = '/login' else if params[:state] == 'myclass' From 19becbfdf3bd5328d692b22d11758efeab19a78a Mon Sep 17 00:00:00 2001 From: Tim Date: Sun, 14 Aug 2016 16:06:37 +0800 Subject: [PATCH 15/16] =?UTF-8?q?=E9=82=80=E8=AF=B7=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/controllers/invite_code.js | 2 +- public/javascripts/wechat/controllers/project_invite_code.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/javascripts/wechat/controllers/invite_code.js b/public/javascripts/wechat/controllers/invite_code.js index 4722916bd..50c14c0c3 100644 --- a/public/javascripts/wechat/controllers/invite_code.js +++ b/public/javascripts/wechat/controllers/invite_code.js @@ -13,7 +13,7 @@ app.controller('InviteCodeController', ['$scope','$http', '$routeParams','config console.log(response.data); vm.course = response.data.data; - var desc = "您的好友邀请您加入班级:\n"+vm.course.name+" \n和小伙伴一起踏上便捷的学习之旅吧!"; + var desc = "您的好友邀请您加入班级:【"+vm.course.name+"】,和小伙伴一起踏上便捷的学习之旅吧!"; var link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+window.g_appid+ "&redirect_uri="+window.g_localhost+"/wechat/user_activities?id="+vm.course.id+ "&response_type=code&scope=snsapi_base&state=invite_code&connect_redirect=1#wechat_redirect"; diff --git a/public/javascripts/wechat/controllers/project_invite_code.js b/public/javascripts/wechat/controllers/project_invite_code.js index 20323e39c..a68bf430b 100644 --- a/public/javascripts/wechat/controllers/project_invite_code.js +++ b/public/javascripts/wechat/controllers/project_invite_code.js @@ -13,7 +13,7 @@ app.controller('ProjectInviteCodeController', ['$scope','$http', '$routeParams', console.log(response.data); vm.project = response.data.data; - var desc = "您的好友邀请您加入项目:\n"+vm.project.name+" \n和小伙伴一起踏上便捷的研发之旅吧!"; + var desc = "您的好友邀请您加入项目:【"+vm.project.name+"】,和小伙伴一起踏上便捷的研发之旅吧!"; var link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+window.g_appid+ "&redirect_uri="+window.g_localhost+"/wechat/user_activities?id="+vm.project.id+ "&response_type=code&scope=snsapi_base&state=project_invite_code&connect_redirect=1#wechat_redirect"; From 8a94d205f4101425b78385d4e143b2ed6eb9113f Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 14 Aug 2016 16:20:53 +0800 Subject: [PATCH 16/16] . --- app/controllers/wechats_controller.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index f8cfb755d..6ccfbcce1 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -415,10 +415,13 @@ class WechatsController < ActionController::Base unless open_id render 'wechats/open_wechat', layout: nil and return end + + logger.info "user_activities!!!!!!!!!!!!!!" + logger.info params - unless (user_binded?(open_id) || params[:state] == "invite_code" || params[:state] == "project_invite_code" || params[:state] == "blog_comment" || params[:state] == "course_notice" || params[:state] == "project_discussion" || params[:state] == "course_discussion" || params[:state] == "homework" || params[:state] == "issues" || params[:state] == "journal_for_message") - @path = '/login' - else + # unless (user_binded?(open_id) || params[:state] == "invite_code" || params[:state] == "project_invite_code" || params[:state] == "blog_comment" || params[:state] == "course_notice" || params[:state] == "project_discussion" || params[:state] == "course_discussion" || params[:state] == "homework" || params[:state] == "issues" || params[:state] == "journal_for_message") + # @path = '/login' + # else if params[:state] == 'myclass' @course_id = params[:id]; elsif params[:state] == 'myproject' @@ -436,7 +439,7 @@ class WechatsController < ActionController::Base end # redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}" and return end - end + # end render 'wechats/user_activities', layout: nil end