Commit 7596abfc authored by 刘文胜's avatar 刘文胜

1111

parent 0bb11017
...@@ -16,6 +16,8 @@ var forumThreadService = require('../../service/forumThreadService'), ...@@ -16,6 +16,8 @@ var forumThreadService = require('../../service/forumThreadService'),
// forumLimitActionRefService = require('../../service/forumLimitActionRefService'), // forumLimitActionRefService = require('../../service/forumLimitActionRefService'),
forumLimitOperationService = require('../../service/forumLimitOperationService'); forumLimitOperationService = require('../../service/forumLimitOperationService');
var redis=global.redis;
module.exports = function(app) { module.exports = function(app) {
app.use('/v1/forum', router); app.use('/v1/forum', router);
}; };
...@@ -304,39 +306,71 @@ router.get('/sharev2.js', function(req, res, next) { ...@@ -304,39 +306,71 @@ router.get('/sharev2.js', function(req, res, next) {
var title = '',desc = '',imgUrl = ''; var title = '',desc = '',imgUrl = '';
if(type && type === 'index'){ if(type && type === 'index'){
then.parallel([ var key = ent_code + 'forum_share_index_info';
function(cont){ var expire = 60 * 60;
//type为index时的,默认link redis.get(key, function(error, share){
link = config.service + '/app/forum/' + ent_code + '/mediashequn'+'?uId='+uId; if(share){//有缓存
request.get({url:config.rest_api+'/v1.0/internal/forum/config/enter/byentcode?entCode='+ent_code,body:{},json:true}, function (e, r, result) { try{
if(result.data){ share = JSON.parse(share);
if(result.data.indexOf('?') === -1){ title=share.title;
link = result.data + '?uId='+ uId; desc=share.desc;
}else{ link=share.linkUrl;
link = result.data + '&uId='+ uId; imgUrl=share.imgUrl;
} if(link.indexOf('?') === -1){
link = link + '?uId='+ uId;
}else{
link = link + '&uId='+ uId;
} }
cont(); }catch(err){
}); console.log(err);
},function(cont){ }
request.get({url:config.rest_api+'/v1.0/internal/forum/config/share/byentcode?entCode='+ent_code,body:{},json:true}, function (e, r, result) { getWXV2(res, title, desc, link, imgUrl, mid,ent_code, id,type,null,true);
if(result.data){ }else{
try{ then.parallel([
var obj = JSON.parse(result.data); function(cont){
title = obj.shareTitle || ''; //type为index时的,默认link
desc = obj.shareDescription || ''; link = config.service + '/app/forum/' + ent_code + '/mediashequn'
imgUrl = obj.sharePictureUrl || ''; request.get({url:config.rest_api+'/v1.0/internal/forum/config/enter/byentcode?entCode='+ent_code,body:{},json:true}, function (e, r, result) {
}catch(err){ if(result.data){
console.log(err); link = result.data;
} }
cont();
});
},function(cont){
request.get({url:config.rest_api+'/v1.0/internal/forum/config/share/byentcode?entCode='+ent_code,body:{},json:true}, function (e, r, result) {
if(result.data){
try{
var obj = JSON.parse(result.data);
title = obj.shareTitle || '';
desc = obj.shareDescription || '';
imgUrl = obj.sharePictureUrl || '';
}catch(err){
console.log(err);
}
}
cont();
});
} }
cont(); ]).then(function(cont, datas) {
//放入redis缓存
redis.set(key,JSON.stringify({
title:title,
desc:desc,
linkUrl:link,
imgUrl:imgUrl
}),function(){
redis.expire(key, expire);
});
if(link.indexOf('?') === -1){
link = link + '?uId='+ uId;
}else{
link = link + '&uId='+ uId;
}
getWXV2(res, title, desc, link, imgUrl, mid,ent_code, id,type,null,true);
}).fail(function(cont, err) {
res.json(_.assign({result:false},returnCode.WRONG_PARAM));
}); });
} }
]).then(function(cont, datas) {
getWXV2(res, title, desc, link, imgUrl, mid,ent_code, id,type,null,true);
}).fail(function(cont, err) {
res.json(_.assign({result:false},returnCode.WRONG_PARAM));
}); });
}else{ }else{
//板块微信接口 //板块微信接口
......
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