From 66357c40244a283a21f1cd607c038daaacb0a270 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Tue, 9 Aug 2016 17:01:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E4=BA=AB=E9=93=BE?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/issues.rb | 3 +++ app/api/mobile/apis/journal_for_messages.rb | 10 ++++++++ app/api/mobile/apis/messages.rb | 14 +++++++++++ app/api/mobile/apis/newss.rb | 10 ++++++++ app/api/mobile/apis/whomeworks.rb | 4 ++++ .../wechat/controllers/activity.js | 2 +- public/javascripts/wechat/controllers/blog.js | 1 + .../wechat/controllers/course_notice.js | 1 + .../wechat/controllers/discussion.js | 1 + .../wechat/controllers/homework.js | 1 + .../wechat/controllers/invite_code.js | 5 +++- .../javascripts/wechat/controllers/issue.js | 1 + .../wechat/controllers/journals.js | 1 + .../wechat/controllers/project_invite_code.js | 6 ++++- public/javascripts/wechat/others/factory.js | 24 +++++++++++++++---- public/javascripts/wechat/others/routes.js | 14 +++++------ 16 files changed, 84 insertions(+), 14 deletions(-) diff --git a/app/api/mobile/apis/issues.rb b/app/api/mobile/apis/issues.rb index 9223332e9..dfd5a3335 100644 --- a/app/api/mobile/apis/issues.rb +++ b/app/api/mobile/apis/issues.rb @@ -12,6 +12,8 @@ module Mobile # authenticate! user = current_user + #is_public true 公开 false 私有 1公开 0私有 + #0一级回复的更多 1 二级回复的更多 type = params[:type] || 0 page = params[:page] || 0 @@ -19,6 +21,7 @@ module Mobile present :data, issue, with: Mobile::Entities::Issue,user: user,type: type,page: page present :type, type present :page, page + present :is_public, issue.project.is_public present :status, 0 rescue Exception=>e present :status, -1 diff --git a/app/api/mobile/apis/journal_for_messages.rb b/app/api/mobile/apis/journal_for_messages.rb index d835d61c5..0ef875780 100644 --- a/app/api/mobile/apis/journal_for_messages.rb +++ b/app/api/mobile/apis/journal_for_messages.rb @@ -16,9 +16,19 @@ module Mobile page = params[:page] || 0 jour = JournalsForMessage.find params[:id] + + is_public = 1 + + if jour.jour_type == "Project" + is_public = jour.project.is_public + elsif jour.jour_type == "Course" + is_public = jour.course.is_public + end + present :data, jour, with: Mobile::Entities::Jours,user: user,type: type,page: page present :type, type present :page, page + present :is_public, is_public present :status, 0 rescue Exception=>e present :status, -1 diff --git a/app/api/mobile/apis/messages.rb b/app/api/mobile/apis/messages.rb index 1e20ea38f..963d2f4ab 100644 --- a/app/api/mobile/apis/messages.rb +++ b/app/api/mobile/apis/messages.rb @@ -15,9 +15,23 @@ module Mobile type = params[:type] || 0 page = params[:page] || 0 message = Message.find params[:id] + + is_public = 1 + type_name = "" + + if message.project + is_public = message.project.is_public + type_name = "project" + elsif message.course + is_public = message.course.is_public + type_name = "course" + end + present :data, message, with: Mobile::Entities::Message,user: user,type: type,page: page present :type, type present :page, page + present :is_public, is_public + present :type_name, type_name present :status, 0 rescue Exception=>e present :status, -1 diff --git a/app/api/mobile/apis/newss.rb b/app/api/mobile/apis/newss.rb index dfe6b5718..907958631 100644 --- a/app/api/mobile/apis/newss.rb +++ b/app/api/mobile/apis/newss.rb @@ -15,9 +15,19 @@ module Mobile type = params[:type] || 0 page = params[:page] || 0 news = News.find params[:id] + + is_public = 1 + + if news.project + is_public = news.project.is_public + elsif news.project + is_public = news.project.is_public + end + present :data, news, with: Mobile::Entities::News,user: user,type: type,page: page present :type, type present :page, page + present :is_public, is_public present :status, 0 rescue Exception=>e present :status, -1 diff --git a/app/api/mobile/apis/whomeworks.rb b/app/api/mobile/apis/whomeworks.rb index 79d04739f..572ce5e0b 100644 --- a/app/api/mobile/apis/whomeworks.rb +++ b/app/api/mobile/apis/whomeworks.rb @@ -15,8 +15,11 @@ module Mobile type = params[:type] || 0 page = params[:page] || 0 + is_public = 1 + if type == 0 homework = HomeworkCommon.find params[:id] + is_public = homework.course.is_public present :data, homework, with: Mobile::Entities::Whomework,user: user,type: type,page: page,comment_type: "homework" else jour = JournalsForMessage.find params[:id] @@ -24,6 +27,7 @@ module Mobile end present :type, type present :page, page + present :is_public, is_public present :status, 0 rescue Exception=>e present :status, -1 diff --git a/public/javascripts/wechat/controllers/activity.js b/public/javascripts/wechat/controllers/activity.js index df1a57b1c..3f75d9e99 100644 --- a/public/javascripts/wechat/controllers/activity.js +++ b/public/javascripts/wechat/controllers/activity.js @@ -146,7 +146,7 @@ app.controller('ActivityController', rms.save("activities",$scope.activities); rms.save("course_activities",$scope.course_activities); rms.save("project_activities",$scope.project_activities); - $location.path('/'+type+'/'+act_id); + $location.path("/"+type).search({id: act_id}); }; $scope.addPraise = function(act){ diff --git a/public/javascripts/wechat/controllers/blog.js b/public/javascripts/wechat/controllers/blog.js index 5fb61151d..21c1cf345 100644 --- a/public/javascripts/wechat/controllers/blog.js +++ b/public/javascripts/wechat/controllers/blog.js @@ -7,6 +7,7 @@ app.controller('BlogController', scope: $scope, type: 'blog_comments', replyType: 'BlogComment', + urlName: 'blog_comment', loadCallback: function(data){ console.log(data.data); diff --git a/public/javascripts/wechat/controllers/course_notice.js b/public/javascripts/wechat/controllers/course_notice.js index 77d2e6ab0..e9760b322 100644 --- a/public/javascripts/wechat/controllers/course_notice.js +++ b/public/javascripts/wechat/controllers/course_notice.js @@ -6,6 +6,7 @@ app.controller('CourseNoticeController', ['$scope', '$http', '$routeParams', 'au scope: $scope, type: 'newss', replyType: 'News', + urlName: 'course_notice', loadCallback: function(data){ $scope.news = data.data; }, diff --git a/public/javascripts/wechat/controllers/discussion.js b/public/javascripts/wechat/controllers/discussion.js index 60bfb3ee3..6a755be11 100644 --- a/public/javascripts/wechat/controllers/discussion.js +++ b/public/javascripts/wechat/controllers/discussion.js @@ -5,6 +5,7 @@ app.controller('DiscussionController', ['$scope', '$http', '$routeParams', 'auth scope: $scope, type: 'messages', replyType: 'Message', + urlName: 'discussion', loadCallback: function(data){ console.log(data.data); diff --git a/public/javascripts/wechat/controllers/homework.js b/public/javascripts/wechat/controllers/homework.js index 2898fc27f..89dbe14bb 100644 --- a/public/javascripts/wechat/controllers/homework.js +++ b/public/javascripts/wechat/controllers/homework.js @@ -5,6 +5,7 @@ app.controller('HomeworkController', ['$scope', '$http', '$routeParams', 'auth', scope: $scope, type: 'whomeworks', replyType: 'HomeworkCommon', + urlName: 'homework', loadCallback: function(data){ console.log(data.data); diff --git a/public/javascripts/wechat/controllers/invite_code.js b/public/javascripts/wechat/controllers/invite_code.js index db8b99ae7..867c9bce4 100644 --- a/public/javascripts/wechat/controllers/invite_code.js +++ b/public/javascripts/wechat/controllers/invite_code.js @@ -14,8 +14,11 @@ app.controller('InviteCodeController', ['$scope','$http', '$routeParams','config vm.course = response.data.data; var desc = "班级邀请:"+vm.course.name+" 班级"; + var link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d" + + "&redirect_uri=https://test.forge.trustie.net/wechat/user_activities?id="+vm.course.id+ + "&response_type=code&scope=snsapi_base&state=invite_code&connect_redirect=1#wechat_redirect"; - common.wxConfig("",desc,""); + common.wxConfig("",desc,"",link); // wx.ready(function(){ // wx.onMenuShareTimeline({ diff --git a/public/javascripts/wechat/controllers/issue.js b/public/javascripts/wechat/controllers/issue.js index ae0cc4450..91938cb7e 100644 --- a/public/javascripts/wechat/controllers/issue.js +++ b/public/javascripts/wechat/controllers/issue.js @@ -5,6 +5,7 @@ app.controller('IssueController', ['$scope', '$http', '$routeParams', 'auth', 'c scope: $scope, type: 'issues', replyType: 'Issue', + urlName: 'issues', loadCallback: function(data){ console.log(data); $scope.issue = data.data; diff --git a/public/javascripts/wechat/controllers/journals.js b/public/javascripts/wechat/controllers/journals.js index 23f3b908b..3825dc86e 100644 --- a/public/javascripts/wechat/controllers/journals.js +++ b/public/javascripts/wechat/controllers/journals.js @@ -4,6 +4,7 @@ app.controller('JournalsController', ['$scope', '$http', '$routeParams', 'auth', scope: $scope, type: 'journal_for_messages', replyType: 'JournalsForMessage', + urlName: 'journal_for_message', loadCallback: function(data){ console.log(data.data); diff --git a/public/javascripts/wechat/controllers/project_invite_code.js b/public/javascripts/wechat/controllers/project_invite_code.js index dea2e9d64..e82bb44a8 100644 --- a/public/javascripts/wechat/controllers/project_invite_code.js +++ b/public/javascripts/wechat/controllers/project_invite_code.js @@ -15,7 +15,11 @@ app.controller('ProjectInviteCodeController', ['$scope','$http', '$routeParams', var desc = "项目邀请:"+vm.project.name+" 项目"; - common.wxConfig("",desc,""); + var link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d" + + "&redirect_uri=https://test.forge.trustie.net/wechat/user_activities?id="+vm.project.id+ + "&response_type=code&scope=snsapi_base&state=project_invite_code&connect_redirect=1#wechat_redirect"; + + common.wxConfig("",desc,"",link); // wx.ready(function(){ // wx.onMenuShareTimeline({ diff --git a/public/javascripts/wechat/others/factory.js b/public/javascripts/wechat/others/factory.js index 4af20c452..ad42eb27c 100644 --- a/public/javascripts/wechat/others/factory.js +++ b/public/javascripts/wechat/others/factory.js @@ -238,7 +238,23 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$loc console.log("desc = "+desc); console.log("imgUrl= "+imgUrl); - wxConfig(title,desc,imgUrl); + var link = ""; + + 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); @@ -345,7 +361,7 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$loc }; - var wxConfig = function(title,desc,imgUrl){ + var wxConfig = function(title,desc,imgUrl,link){ if(title == null || title == ""){ title = 'Trustie创新实践平台'; @@ -362,7 +378,7 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$loc wx.ready(function(){ wx.onMenuShareTimeline({ title: title, // 分享标题 -// link: 'http://www.trustie.net/', // 分享链接 + link: link, // 分享链接 imgUrl: imgUrl, // 分享图标 success: function () { console.log("share successed."); @@ -375,7 +391,7 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$loc wx.onMenuShareAppMessage({ title: title, // 分享标题 desc: desc, // 分享描述 -// link: '', // 分享链接 + link: link, // 分享链接 // imgUrl: '', // 分享图标 imgUrl: imgUrl, // 分享图标 // type: '', // 分享类型,music、video或link,不填默认为link diff --git a/public/javascripts/wechat/others/routes.js b/public/javascripts/wechat/others/routes.js index 70d1491f4..7b4a0320b 100644 --- a/public/javascripts/wechat/others/routes.js +++ b/public/javascripts/wechat/others/routes.js @@ -23,13 +23,13 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', func controller: 'RegController' }) .when('/activites', makeRoute('activities.html', 'ActivityController')) - .when('/issues/:id', makeRoute('issue_detail.html', 'IssueController')) - .when('/project_discussion/:id', makeRoute('project_discussion.html', 'DiscussionController')) - .when('/homework/:id', makeRoute('homework_detail.html', 'HomeworkController')) - .when('/course_notice/:id', makeRoute('course_notice.html', 'CourseNoticeController')) - .when('/course_discussion/:id', makeRoute('course_discussion.html', 'DiscussionController')) - .when('/journal_for_message/:id', makeRoute('jour_message_detail.html', 'JournalsController')) - .when('/blog_comment/:id', makeRoute('blog_detail.html', 'BlogController')) + .when('/issues', makeRoute('issue_detail.html', 'IssueController')) + .when('/project_discussion', makeRoute('project_discussion.html', 'DiscussionController')) + .when('/homework', makeRoute('homework_detail.html', 'HomeworkController')) + .when('/course_notice', makeRoute('course_notice.html', 'CourseNoticeController')) + .when('/course_discussion', makeRoute('course_discussion.html', 'DiscussionController')) + .when('/journal_for_message', makeRoute('jour_message_detail.html', 'JournalsController')) + .when('/blog_comment', makeRoute('blog_detail.html', 'BlogController')) .when('/class', makeRoute('class.html', 'ClassController')) .when('/new_class', makeRoute('new_class.html', 'NewClassController')) .when('/edit_class', makeRoute('edit_class.html', 'EditClassController'))