Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pisns-forum-api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
scrmGroup
pisns-forum-api
Commits
ade03469
Commit
ade03469
authored
Apr 16, 2015
by
陈志良
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分享 推送积分
parent
824a0fba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
12 deletions
+44
-12
forumShare.js
app/controllers/mobile/forumShare.js
+19
-5
httpService.js
app/service/httpService.js
+25
-7
No files found.
app/controllers/mobile/forumShare.js
View file @
ade03469
...
@@ -9,6 +9,7 @@ var forumThreadService = require('../../service/forumThreadService');
...
@@ -9,6 +9,7 @@ var forumThreadService = require('../../service/forumThreadService');
var
forumShareConfigService
=
require
(
'../../service/forumShareConfigService'
);
var
forumShareConfigService
=
require
(
'../../service/forumShareConfigService'
);
var
forumShareService
=
require
(
'../../service/forumShareService'
);
var
forumShareService
=
require
(
'../../service/forumShareService'
);
var
config
=
require
(
'../../../config/config'
);
var
config
=
require
(
'../../../config/config'
);
var
httpService
=
require
(
'../../service/httpService'
);
var
then
=
require
(
'thenjs'
);
var
then
=
require
(
'thenjs'
);
//var forumInfoService = require('../../service/forumInfoService');
//var forumInfoService = require('../../service/forumInfoService');
...
@@ -16,7 +17,7 @@ module.exports = function(app) {
...
@@ -16,7 +17,7 @@ module.exports = function(app) {
app
.
use
(
'/v1/forum'
,
router
);
app
.
use
(
'/v1/forum'
,
router
);
};
};
function
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
)
{
function
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
ent_code
)
{
link
=
config
.
service
+
link
+
"&mid="
+
mid
;
link
=
config
.
service
+
link
+
"&mid="
+
mid
;
res
.
writeHead
(
200
,
{
res
.
writeHead
(
200
,
{
'Content-Type'
:
'text/javascript'
,
'Content-Type'
:
'text/javascript'
,
...
@@ -31,7 +32,11 @@ function getWX(res, title, desc, link, imgUrl, mid) {
...
@@ -31,7 +32,11 @@ function getWX(res, title, desc, link, imgUrl, mid) {
// imgUrl = 'http://dev.fs.wxpai.cn/upload/100001_2015410_1428671539587_40.jpg',
// imgUrl = 'http://dev.fs.wxpai.cn/upload/100001_2015410_1428671539587_40.jpg',
// desc = '测试描述';
// desc = '测试描述';
// var string = '';
// 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 () { '
+
'}'
+
' });'
var
success
=
'$.ajax({'
+
'type:
\'
GET
\'
,'
+
'url:
\'
/v1/forum/'
+
ent_code
+
'/timeline
\'
'
+
'});'
;
var
string
=
'wx.onMenuShareTimeline({'
+
'
\
"title
\
":
\
"'
+
title
+
'
\
",'
+
'
\
"link
\
":
\
"'
+
link
+
'
\
",'
+
'
\
"imgUrl
\
":
\
"'
+
imgUrl
+
'
\
", '
+
'success: function(){'
+
success
+
'},'
+
'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.ready(function(){'
+
string
+
'});'
);
res
.
write
(
'wx.error(function(res){console.log(res);});'
);
res
.
write
(
'wx.error(function(res){console.log(res);});'
);
...
@@ -73,7 +78,7 @@ router.get('/:ent_code/share.js', function(req, res, next) {
...
@@ -73,7 +78,7 @@ router.get('/:ent_code/share.js', function(req, res, next) {
}
else
{
}
else
{
link
=
link
+
'index'
;
link
=
link
+
'index'
;
}
}
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
);
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
ent_code
);
}
else
{
}
else
{
cont
(
err
);
cont
(
err
);
}
}
...
@@ -159,7 +164,7 @@ router.get('/:ent_code/share.js', function(req, res, next) {
...
@@ -159,7 +164,7 @@ router.get('/:ent_code/share.js', function(req, res, next) {
}
}
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
);
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
ent_code
);
}
else
{
}
else
{
cont
(
err
);
cont
(
err
);
}
}
...
@@ -181,7 +186,7 @@ router.get('/:ent_code/share.js', function(req, res, next) {
...
@@ -181,7 +186,7 @@ router.get('/:ent_code/share.js', function(req, res, next) {
//key = 'photo';
//key = 'photo';
}
}
getWX
(
res
,
forumShare
.
title
,
forumShare
.
description
,
link
,
forumShare
.
icon
,
mid
);
getWX
(
res
,
forumShare
.
title
,
forumShare
.
description
,
link
,
forumShare
.
icon
,
mid
,
ent_code
);
});
});
}
}
}).
fail
(
function
(
cont
,
err
)
{
}).
fail
(
function
(
cont
,
err
)
{
...
@@ -199,3 +204,12 @@ router.get('/:ent_code/share.js', function(req, res, next) {
...
@@ -199,3 +204,12 @@ router.get('/:ent_code/share.js', function(req, res, next) {
});
});
}
}
});
});
//微信分享接口
router
.
get
(
'/:ent_code/timeline'
,
function
(
req
,
res
,
next
)
{
var
mid
=
req
.
session
.
openUser
.
mid
,
action
=
'share_timeline'
,
ent_code
=
req
.
session
.
user
.
ent_code
;
httpService
.
sendRequest
(
ent_code
,
mid
,
action
);
res
.
status
(
200
).
end
();
});
app/service/httpService.js
View file @
ade03469
...
@@ -2,10 +2,28 @@
...
@@ -2,10 +2,28 @@
// var request=require('request');
// var request=require('request');
// var REMOTE_URL='http://127.0.0.1:3011/admin/forum/http/receive';
// var REMOTE_URL='http://127.0.0.1:3011/admin/forum/http/receive';
var
ACTION_KEY
=
{
exports
.
sendRequest
=
function
(
ent_code
,
uid
,
tid
,
action
){
'post'
:
'FORUM_THREAD_POST'
,
// var url=REMOTE_URL+'?ent_code='+ent_code+'&uid='+uid+'&tid='+tid+'&action='+action;
'share'
:
'FORUM_THREAD_SHARE'
,
// request.get({url:url}, function (e, r, body) {
'share_timeline'
:
'FORUM_THREAD_SHARE_TIMELINE'
,
'comment'
:
'FORUM_THREAD_COMMENT'
,
// });
'praise'
:
'FORUM_THREAD_PRAISE '
};
}
\ No newline at end of file
exports
.
sendRequest
=
function
(
ent_code
,
mid
,
action
,
messageid
,
integral
,
exp
){
var
obj
=
{
tag
:
'member'
,
key
:
'forum'
,
action
:
ACTION_KEY
[
action
],
mid
:
mid
,
entcode
:
ent_code
,
messageid
:
messageid
||
''
,
integral
:
integral
||
0
,
exp
:
exp
||
0
};
console
.
log
(
obj
);
redis
.
lpush
(
'adapter-redis-to-ons'
,
JSON
.
stringify
(
obj
),
function
(
err
,
reply
){
if
(
err
)
{
console
.
error
(
err
);
}
});
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment