Commit d046aa8e authored by 刘文胜's avatar 刘文胜

社区分享

parent ab6de49e
......@@ -3,6 +3,7 @@ var express = require('express'),
router = express.Router(),
_ = require('lodash'),
then = require('thenjs'),
request=require('request'),
mongoose = require('mongoose');
var forumThreadService = require('../../service/forumThreadService'),
......@@ -236,10 +237,14 @@ router.get('/:ent_code/share/singlemessage', function(req, res, next) {
}
});
});
function getWXV2(res, title, desc, link, imgUrl, mid,ent_code, id,type,forumThread) {
function getWXV2(res, title, desc, link, imgUrl, mid,ent_code, id,type,forumThread,fullurl) {
//['{板块名称}','{文章标题}','{话题名称}','{照片墙标题}'];
//share_type:是否使用默认设置:1使用默认分享设置 2.使用自己的分享设置
if(fullurl){
link = link + "&mid=" + mid;
}else{
link = config.service + link + "&mid=" + mid;
}
if(type==="Info") {
forumInfoService.getInfoById(id, function(err, forumInfo) {
......@@ -298,6 +303,42 @@ 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;
}
}
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();
});
}
]).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{
//板块微信接口
if(!type || !id){
console.error('请求参数错误')
......@@ -400,4 +441,5 @@ router.get('/sharev2.js', function(req, res, next) {
res.json(_.assign({result:false},returnCode.WRONG_PARAM));
});
}
}
});
\ No newline at end of file
......@@ -9,6 +9,7 @@ var config = {
app: {
name: 'pisns-forum-api'
},
rest_api:'http://localhost:8080',
service:'http://localhost',
port: 3011,
mongodb: {
......@@ -38,6 +39,7 @@ var config = {
app: {
name: 'pisns-forum-api'
},
rest_api:'http://rest.wxpai.cn',
service:'http://sandbox.wxpai.cn',
port: 3011,
mongodb: {
......@@ -67,6 +69,7 @@ var config = {
app: {
name: 'pisns-forum-api'
},
rest_api:'https://rest.wxpai.cn',
service:'http://piplus.wxpai.cn',
port: 3011,
......
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