Commit 35b61279 authored by 刘文胜's avatar 刘文胜

板块个性化分享

parent 185b5f20
...@@ -93,33 +93,49 @@ router.get('/:ent_code/share.js', function(req, res, next) { ...@@ -93,33 +93,49 @@ router.get('/:ent_code/share.js', function(req, res, next) {
//分享记录对象 //分享记录对象
share_log.type = 2; share_log.type = 2;
share_log.info = id; share_log.info = id;
//查询板块默认分享设置
forumShareConfigService.getByKey(ent_code, 'share', function(err, result) { forumInfoService.getInfoById(id, function(err, forumInfo) {
if(err){ if (err) {
console.error(err); console.error(err);
res.json(_.assign({result:false},returnCode.BUSY)); res.json(_.assign({result:false},returnCode.BUSY));
}else{ return;
var title = '',desc = '',imgUrl = ''; }
if (result) { if(forumInfo.share_type == 1){
//匹配板块默认分享设置 var shareInfo = forumInfo.share || {};
result = result.meta_value; var title = shareInfo.title || '',desc = shareInfo.desc || '',imgUrl = shareInfo.imgUrl || '';
_.forEach(result,function(e){ link = link + 'index&infoId='+ id+'&uId='+uId;
if (e.type === 'info') { getWX(res, title, desc, link, imgUrl, mid,ent_code, id,type,null);
title = e.title; return;
desc = e.desc; }
imgUrl = e.imgUrl; //默认分享设置 //查询板块默认分享设置
return; forumShareConfigService.getByKey(ent_code, 'share', function(err, result) {
} if(err){
}); console.error(err);
link = link + 'index&infoId='+ id+'&uId='+uId; res.json(_.assign({result:false},returnCode.BUSY));
getWX(res, title, desc, link, imgUrl, mid,ent_code, id,type,null);
}else{ }else{
//没找到板块默认分享设置 var title = '',desc = '',imgUrl = '';
console.error('info默认分享设置不存在'); if (result) {
res.json(_.assign({result:false},returnCode.DATA_NOTEXITS)); //匹配板块默认分享设置
result = result.meta_value;
_.forEach(result,function(e){
if (e.type === 'info') {
title = e.title;
desc = e.desc;
imgUrl = e.imgUrl;
return;
}
});
link = link + 'index&infoId='+ id+'&uId='+uId;
getWX(res, title, desc, link, imgUrl, mid,ent_code, id,type,null);
}else{
//没找到板块默认分享设置
console.error('info默认分享设置不存在');
res.json(_.assign({result:false},returnCode.DATA_NOTEXITS));
}
} }
} });
}); });
}else if (type === 'Thread') { }else if (type === 'Thread') {
share_log.type = 3; share_log.type = 3;
share_log.thread = id; share_log.thread = id;
......
...@@ -41,7 +41,15 @@ var ForumInfoSchema = new Schema({ ...@@ -41,7 +41,15 @@ var ForumInfoSchema = new Schema({
type: Number, type: Number,
require: true, require: true,
default: 1 default: 1
}, },
share_type:{//分享类型,1自定义,0和其它为默认
type: Number,
default: 0
},
share:{//desc title imgUrl
type: Object,
default:{}
},
created: { created: {
type: Date, type: Date,
required: true, required: true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment