From 17c98eb9fea027f5c0c28f8e34d16a5ba50d2813 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Thu, 4 Aug 2016 09:08:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=88=86=E4=BA=AB=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/project.rb | 2 +- app/services/courses_service.rb | 22 ++++++--- app/services/projects_service.rb | 2 +- .../wechat/controllers/invite_code.js | 45 +++++++++++------ .../wechat/controllers/project_invite_code.js | 49 +++++++++++++------ public/javascripts/wechat/others/factory.js | 32 +++++++++++- 6 files changed, 113 insertions(+), 39 deletions(-) diff --git a/app/api/mobile/entities/project.rb b/app/api/mobile/entities/project.rb index 55ab67be2..073f7cd0f 100644 --- a/app/api/mobile/entities/project.rb +++ b/app/api/mobile/entities/project.rb @@ -5,7 +5,7 @@ module Mobile expose :id expose :user_id expose :invite_code - # expose :qrcode + expose :qrcode expose :can_setting, if: lambda { |instance, options| options[:user] } do |instance, options| current_user = options[:user] diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index ccae53b45..e0455022f 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -101,12 +101,22 @@ class CoursesService gender = m.user.user_extensions.gender.nil? ? 0 : m.user.user_extensions.gender work_unit = get_user_work_unit m.user location = get_user_location m.user - users << {:id => m.user.id, :img_url => img_url, :nickname => m.user.login, :gender => gender, - :work_unit => work_unit, :mail => m.user.mail, :location => location, - role_name: m.roles.first.name, - name: m.user.show_name, - roles_id: m.roles[0].id, - :brief_introduction => m.user.user_extensions.brief_introduction,:realname=>m.user.realname} + + role_ids = [] + m.roles.each do |r| + role_ids << r.id + end + + #双重身份 学生列表中不显示 + unless (params[:role] == '2' && role_ids.length >= 2) + users << {:id => m.user.id, :img_url => img_url, :nickname => m.user.login, :gender => gender, + :work_unit => work_unit, :mail => m.user.mail, :location => location, + role_name: m.roles.first.name, + name: m.user.show_name, + roles_id: role_ids.include?(7) ? 7 : (role_ids.include?(9) ? 9 : 10 ), + :brief_introduction => m.user.user_extensions.brief_introduction,:realname=>m.user.realname} + end + end users end diff --git a/app/services/projects_service.rb b/app/services/projects_service.rb index 2df36eb5e..e732571c5 100644 --- a/app/services/projects_service.rb +++ b/app/services/projects_service.rb @@ -17,7 +17,7 @@ class ProjectsService def show_project(params,current_user) project = Project.find(params[:id]) project.generate_invite_code - # project.generate_qrcode + project.generate_qrcode project end diff --git a/public/javascripts/wechat/controllers/invite_code.js b/public/javascripts/wechat/controllers/invite_code.js index 0467dee5d..5b144cafd 100644 --- a/public/javascripts/wechat/controllers/invite_code.js +++ b/public/javascripts/wechat/controllers/invite_code.js @@ -6,26 +6,43 @@ app.controller('InviteCodeController', ['$scope','$http', '$routeParams','config','auth','wx', function($scope, $http, $routeParams, config, auth, wx){ var vm = $scope; - wx.ready(function(){ - wx.onMenuShareTimeline({ - title: '定制的标题', // 分享标题 - link: 'http://wechat.trustie.net/', // 分享链接 - imgUrl: 'http://wechat.trustie.net/images/logo2.png', // 分享图标 - success: function () { - console.log("share successed."); - }, - cancel: function () { - console.log("share canceled."); - } - }); - }); - vm.course = {}; var courseid = $routeParams.id; $http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then( function(response){ console.log(response.data); vm.course = response.data.data; + + var desc = "班级邀请:"+vm.course.name+" 班级"; + + wx.ready(function(){ + wx.onMenuShareTimeline({ + title: 'Trustie创新实践平台', // 分享标题 +// link: 'http://www.trustie.net/', // 分享链接 + imgUrl: 'http://www.trustie.net/images/logo2.png', // 分享图标 + success: function () { + console.log("share successed."); + }, + cancel: function () { + console.log("share canceled."); + } + }); + + wx.onMenuShareAppMessage({ + title: 'Trustie创新实践平台', // 分享标题 + desc: desc, // 分享描述 +// link: '', // 分享链接 +// imgUrl: '', // 分享图标 +// type: '', // 分享类型,music、video或link,不填默认为link +// dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空 + success: function () { + // 用户确认分享后执行的回调函数 + }, + cancel: function () { + // 用户取消分享后执行的回调函数 + } + }); + }); } ); diff --git a/public/javascripts/wechat/controllers/project_invite_code.js b/public/javascripts/wechat/controllers/project_invite_code.js index eb3032650..6586c7f24 100644 --- a/public/javascripts/wechat/controllers/project_invite_code.js +++ b/public/javascripts/wechat/controllers/project_invite_code.js @@ -3,7 +3,7 @@ */ -app.controller('ProjectInviteCodeController', ['$scope','$http', '$routeParams','config','auth', function($scope, $http, $routeParams, config, auth){ +app.controller('ProjectInviteCodeController', ['$scope','$http', '$routeParams','config','auth','wx', function($scope, $http, $routeParams, config, auth,wx){ var vm = $scope; vm.project = {}; @@ -12,23 +12,40 @@ app.controller('ProjectInviteCodeController', ['$scope','$http', '$routeParams', function(response){ console.log(response.data); vm.project = response.data.data; + + var desc = "项目邀请:"+vm.project.name+" 项目"; + + wx.ready(function(){ + wx.onMenuShareTimeline({ + title: 'Trustie创新实践平台', // 分享标题 +// link: 'http://www.trustie.net/', // 分享链接 + imgUrl: 'http://www.trustie.net/images/logo2.png', // 分享图标 + success: function () { + console.log("share successed."); + }, + cancel: function () { + console.log("share canceled."); + } + }); + + wx.onMenuShareAppMessage({ + title: 'Trustie创新实践平台', // 分享标题 + desc: desc, // 分享描述 +// link: '', // 分享链接 +// imgUrl: '', // 分享图标 +// type: '', // 分享类型,music、video或link,不填默认为link +// dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空 + success: function () { + // 用户确认分享后执行的回调函数 + }, + cancel: function () { + // 用户取消分享后执行的回调函数 + } + }); + }); } ); - vm.share = function(){ - window.WeixinJSBridge.invoke('sendAppMessage',{ - 'appid': 'wxf694495398c7d470', // 公众号appID - 'type': 'link', // 非必填,music,vido或link,默认为link。 - 'data_url': '', // 非必填,连接地址,如音乐的mp3数据地址,供内置播放器使用 - 'img_url': 'http://pnewsapp.tc.qq.com/newsapp_bt/0/9963967/640', // 缩略图地址 - 'img_height':370, // 缩略图高度 - 'img_width':550, // 缩略图宽度 - 'link':'http://view.inews.qq.com/a/WXN2013101101385701', // 链接地址 - 'desc':'desc', // 描述 - 'title':'title' // 标题 - },function(res){ - //alert(res.err_msg); - }); - } + }]); diff --git a/public/javascripts/wechat/others/factory.js b/public/javascripts/wechat/others/factory.js index 6e110a6ea..3c2b6ca45 100644 --- a/public/javascripts/wechat/others/factory.js +++ b/public/javascripts/wechat/others/factory.js @@ -93,7 +93,7 @@ app.factory('rms', function(){ return {save: save, get: get}; }); -app.factory('common', ['$http', 'auth', '$routeParams','rms','config', function($http, auth, $routeParams,rms,config){ +app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx', function($http, auth, $routeParams,rms,config,wx){ var addCommonReply = function(id, type, data, cb){ if(!data.comment || data.comment.length<=0){ @@ -200,6 +200,36 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config', function( args.scope.formData = {comment: ''}; var loadData = function(id,replytype,page){ loadCommonData(id, args.type,replytype,page).then(function successCallback(response) { + var desc = response.data.user.realname+":"+response.data.title; + wx.ready(function(){ + wx.onMenuShareTimeline({ + title: 'Trustie创新实践平台', // 分享标题 +// link: 'http://www.trustie.net/', // 分享链接 + imgUrl: 'http://www.trustie.net/images/logo2.png', // 分享图标 + success: function () { + console.log("share successed."); + }, + cancel: function () { + console.log("share canceled."); + } + }); + + wx.onMenuShareAppMessage({ + title: 'Trustie创新实践平台', // 分享标题 + desc: desc, // 分享描述 +// link: '', // 分享链接 +// imgUrl: '', // 分享图标 +// type: '', // 分享类型,music、video或link,不填默认为link +// dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空 + success: function () { + // 用户确认分享后执行的回调函数 + }, + cancel: function () { + // 用户取消分享后执行的回调函数 + } + }); + }); + args.loadCallback(response.data); }, function errorCallback(response) { });