Commit 9f314d69 authored by 邓军's avatar 邓军

微信接口调整参数

parent c6affd53
......@@ -16,7 +16,7 @@ module.exports = function(app) {
app.use('/v1/forum', router);
};
function getWX(res, title, desc, link, imgUrl,mid) {
function getWX(res, title, desc, link, imgUrl, mid) {
link = config.service + link + "&mid=" + mid;
res.writeHead(200, {
'Content-Type': 'text/javascript',
......@@ -27,26 +27,11 @@ function getWX(res, title, desc, link, imgUrl,mid) {
// result.jsApiList = jsApiList;
res.write('$(function(){');
// var title = type+'类型分享',
// link = 'http://sandbox.wxpai.cn/app/aubywx/100041',
// imgUrl = 'http://dev.fs.wxpai.cn/upload/100001_2015410_1428671539587_40.jpg',
// desc = '测试描述';
// var string = '';
var string = 'wx.onMenuShareTimeline({' + '\"title\": \"' + title + '\",'
+ '\"link\":\"' + link + '\",'
+ '\"imgUrl\": \"' + imgUrl + '\", '
+ 'success: function(){},'
+ 'cancel: function () {}'
+ ' });'
+ ' wx.onMenuShareAppMessage({'
+ '\"title\": \"' + title + '\", '
+ '\"desc\": \"' + desc + '\", '
+ '\"link\":\"' + link + '\", '
+ '\"imgUrl\": \"' + imgUrl + '\", '
+ '\"type\":\'\' ,'
+ '\"dataUrl\": \'\', '
+ 'success: function(){},'
+ 'cancel: function () { '
+ '}' + ' });'
// link = 'http://sandbox.wxpai.cn/app/aubywx/100041',
// imgUrl = 'http://dev.fs.wxpai.cn/upload/100001_2015410_1428671539587_40.jpg',
// desc = '测试描述';
// var string = '';
var string = 'wx.onMenuShareTimeline({' + '\"title\": \"' + title + '\",' + '\"link\":\"' + link + '\",' + '\"imgUrl\": \"' + imgUrl + '\", ' + 'success: function(){},' + 'cancel: function () {}' + ' });' + ' wx.onMenuShareAppMessage({' + '\"title\": \"' + title + '\", ' + '\"desc\": \"' + desc + '\", ' + '\"link\":\"' + link + '\", ' + '\"imgUrl\": \"' + imgUrl + '\", ' + '\"type\":\'\' ,' + '\"dataUrl\": \'\', ' + 'success: function(){},' + 'cancel: function () { ' + '}' + ' });'
res.write('wx.ready(function(){' + string + '});');
res.write('wx.error(function(res){console.log(res);});');
......@@ -61,7 +46,7 @@ router.get('/:ent_code/share.js', function(req, res, next) {
var id = req.query.id;
var mid = req.session.openUser.mid || 0;
var ent_code = req.params.ent_code;
var link = '/app/forum/' + ent_code +'/index/';
var link = '/app/forum/' + ent_code + '/index?pageUrl=';
if (type) {
//板块微信接口
if (type === 'Info') {
......@@ -81,8 +66,8 @@ router.get('/:ent_code/share.js', function(req, res, next) {
imgUrl = result[i].meta_value;
}
}
link = link + 'index.html?infoId=' + id;
getWX(res, title,desc, link, imgUrl,mid);
link = link + 'index&infoId=' + id;
getWX(res, title, desc, link, imgUrl, mid);
} else {
cont(err);
}
......@@ -123,16 +108,16 @@ router.get('/:ent_code/share.js', function(req, res, next) {
if (sc) {
var key = '';
//1、文章 2、话题 3、照片墙
if (result.type === 1 || (result.type === 2 && result.level === 2)) {
link = link + 'main.html?infoId=' + result.info + '&ent_code=' + ent_code + '&id=' + result._id;
link = link + 'thread&infoId=' + result.info + '&ent_code=' + ent_code + '&id=' + result._id;
key = 'article';
} else if (result.type === 2 && result.level === 1) {
link = link + 'hot_topic.html?infoId=' + result.info + '&ent_code=' + ent_code + '&id=' + result._id;
link = link + 'topicList&infoId=' + result.info + '&ent_code=' + ent_code + '&id=' + result._id;
key = 'topic';
} else if (result.type === 3) {
link = link + 'photo.html?infoId=' + result.info + '&ent_code=' + ent_code + '&id=' + result._id;
link = link + 'photoList&infoId=' + result.info + '&ent_code=' + ent_code + '&id=' + result._id;
key = 'photo';
}
......@@ -145,7 +130,7 @@ router.get('/:ent_code/share.js', function(req, res, next) {
imgUrl = sc[i].meta_value;
}
}
getWX(res, title, desc, link, imgUrl,mid);
getWX(res, title, desc, link, imgUrl, mid);
} else {
cont(err);
}
......@@ -154,20 +139,20 @@ router.get('/:ent_code/share.js', function(req, res, next) {
//如果有分享设置,则返回分享设置
forumShareService.getById(result.share, function(err, forumShare) {
//1、文章 2、话题 3、照片墙
if (result.type === 1 || (result.type === 2 && result.level === 2)) {
link = link + 'main.html?infoId=' + result.info + '&ent_code=' + ent_code + '&id=' + result._id;
// key = 'article';
link = link + 'thread&infoId=' + result.info + '&ent_code=' + ent_code + '&id=' + result._id;
//key = 'article';
} else if (result.type === 2 && result.level === 1) {
link = link + 'hot_topic.html?infoId=' + result.info + '&ent_code=' + ent_code + '&id=' + result._id;
//key = 'topic';
link = link + 'topicList&infoId=' + result.info + '&ent_code=' + ent_code + '&id=' + result._id;
//key = 'topic';
} else if (result.type === 3) {
link = link + 'photo.html?infoId=' + result.info + '&ent_code=' + ent_code + '&id=' + result._id;
link = link + 'photoList&infoId=' + result.info + '&ent_code=' + ent_code + '&id=' + result._id;
//key = 'photo';
}
getWX(res, forumShare.title, forumShare.description, link, forumShare.icon,mid);
getWX(res, forumShare.title, forumShare.description, link, forumShare.icon, mid);
});
}
}).fail(function(cont, err) {
......
......@@ -4,10 +4,10 @@ var ForumShareConfig = mongoose.model('ForumShareConfig');
var async=require('async');
//创建配置信息
exports.createForumShareConfig=function(entity,callback){
var forumShareConfig = new ForumShareConfig(entity);
forumShareConfig.save(function(err, forumShareConfig) {
//批量创建配置信息
exports.create=function(entity,callback){
//var forumShareConfig = new ForumShareConfig(entity);
ForumShareConfig.create(entity,function(err, forumShareConfig) {
if (err) {
console.error(err);
callback(err,null);
......
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