diff --git a/public/javascripts/wechat/controllers/invite_code.js b/public/javascripts/wechat/controllers/invite_code.js index 53fcd3d87..db8b99ae7 100644 --- a/public/javascripts/wechat/controllers/invite_code.js +++ b/public/javascripts/wechat/controllers/invite_code.js @@ -15,7 +15,7 @@ app.controller('InviteCodeController', ['$scope','$http', '$routeParams','config var desc = "班级邀请:"+vm.course.name+" 班级"; - common.wxConfig(desc,""); + common.wxConfig("",desc,""); // wx.ready(function(){ // wx.onMenuShareTimeline({ diff --git a/public/javascripts/wechat/controllers/project_invite_code.js b/public/javascripts/wechat/controllers/project_invite_code.js index 39a4c1aaf..dea2e9d64 100644 --- a/public/javascripts/wechat/controllers/project_invite_code.js +++ b/public/javascripts/wechat/controllers/project_invite_code.js @@ -15,7 +15,7 @@ app.controller('ProjectInviteCodeController', ['$scope','$http', '$routeParams', var desc = "项目邀请:"+vm.project.name+" 项目"; - common.wxConfig(desc,""); + common.wxConfig("",desc,""); // wx.ready(function(){ // wx.onMenuShareTimeline({ diff --git a/public/javascripts/wechat/others/factory.js b/public/javascripts/wechat/others/factory.js index 9fa8d09aa..5e5e6d4bf 100644 --- a/public/javascripts/wechat/others/factory.js +++ b/public/javascripts/wechat/others/factory.js @@ -201,8 +201,8 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx', func var loadData = function(id,replytype,page){ loadCommonData(id, args.type,replytype,page).then(function successCallback(response) { console.log(response.data); - - var tmptile = "动态"; + //--------------分享内容定制------------- + var tmptile = "分享动态"; var imgUrl = ""; if(response.data.data.title){ @@ -221,11 +221,25 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx', func imgUrl = window.g_localhost+response.data.data.author.img_url; } - var desc = tmpname+":"+tmptile; + 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); - wxConfig(desc); + wxConfig(title,desc,imgUrl); + + //--------------分享内容定制------------- args.loadCallback(response.data); }, function errorCallback(response) { }); @@ -330,7 +344,15 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx', func }; - var wxConfig = function(desc,imgUrl){ + var wxConfig = function(title,desc,imgUrl){ + + if(title == null || title == ""){ + title = 'Trustie创新实践平台'; + } + + if(desc == null || desc == ""){ + desc = 'Trustie创新实践平台'; + } if(imgUrl == null || imgUrl == ""){ imgUrl = 'http://www.trustie.net/images/logo2.png'; @@ -338,7 +360,7 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx', func wx.ready(function(){ wx.onMenuShareTimeline({ - title: 'Trustie创新实践平台', // 分享标题 + title: title, // 分享标题 // link: 'http://www.trustie.net/', // 分享链接 imgUrl: imgUrl, // 分享图标 success: function () { @@ -350,7 +372,7 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx', func }); wx.onMenuShareAppMessage({ - title: 'Trustie创新实践平台', // 分享标题 + title: title, // 分享标题 desc: desc, // 分享描述 // link: '', // 分享链接 // imgUrl: '', // 分享图标