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

1111

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