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
2e0696cb
Commit
2e0696cb
authored
Apr 17, 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
104 additions
and
12 deletions
+104
-12
forumShare.js
app/controllers/mobile/forumShare.js
+44
-12
forumShareConfig.js
app/controllers/mobile/forumShareConfig.js
+60
-0
No files found.
app/controllers/mobile/forumShare.js
View file @
2e0696cb
...
...
@@ -10,14 +10,13 @@ var forumShareConfigService = require('../../service/forumShareConfigService');
var
forumShareService
=
require
(
'../../service/forumShareService'
);
var
config
=
require
(
'../../../config/config'
);
var
then
=
require
(
'thenjs'
);
//
var forumInfoService = require('../../service/forumInfoService');
var
forumInfoService
=
require
(
'../../service/forumInfoService'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/v1/forum'
,
router
);
};
function
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
)
{
link
=
config
.
service
+
link
+
"&mid="
+
mid
;
function
write
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
)
{
res
.
writeHead
(
200
,
{
'Content-Type'
:
'text/javascript'
,
'Cache-Control'
:
'no-cache'
,
...
...
@@ -39,6 +38,36 @@ function getWX(res, title, desc, link, imgUrl, mid) {
res
.
end
();
}
function
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
id
,
type
,
forumThread
)
{
//['{板块名称}','{文章标题}','{话题名称}','{照片墙标题}'];
//share_type:是否使用默认设置:1使用默认分享设置 2.使用自己的分享设置
link
=
config
.
service
+
link
+
"&mid="
+
mid
;
if
(
type
===
"Info"
)
{
forumInfoService
.
getInfoById
(
id
,
function
(
err
,
forumInfo
)
{
if
(
err
||
forumInfo
<
1
)
{
console
.
error
(
"板块不存在或者发生未知错误"
);
res
.
json
({
message
:
'板块不存在或者发生未知错误'
,
result
:
false
,
code
:
'10002'
,
error
:
err
});
}
else
{
title
=
title
.
replace
(
/{板块名称}/g
,
forumInfo
.
name
);
desc
=
desc
.
replace
(
/{板块名称}/g
,
forumInfo
.
name
);
write
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
);
}
});
}
else
if
(
type
===
"Thread"
){
title
=
title
.
replace
(
/{文章标题}|{话题名称}|{照片墙标题}/g
,
forumThread
.
title
);
desc
=
desc
.
replace
(
/{文章标题}|{话题名称}|{照片墙标题}/g
,
forumThread
.
title
);
write
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
);
}
}
//微信分享接口
router
.
get
(
'/:ent_code/share.js'
,
function
(
req
,
res
,
next
)
{
var
rs
=
{};
...
...
@@ -53,9 +82,11 @@ router.get('/:ent_code/share.js', function(req, res, next) {
if
(
type
)
{
//板块微信接口
if
(
type
===
'Info'
)
{
then
(
function
(
cont
)
{
forumShareConfigService
.
getByKey
(
ent_code
,
'share'
,
function
(
err
,
result
)
{
console
.
log
(
err
);
var
title
=
''
,
desc
=
''
,
imgUrl
=
''
;
...
...
@@ -73,7 +104,8 @@ router.get('/:ent_code/share.js', function(req, res, next) {
}
else
{
link
=
link
+
'index'
;
}
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
);
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
id
,
type
,
null
);
}
else
{
cont
(
err
);
}
...
...
@@ -105,7 +137,7 @@ router.get('/:ent_code/share.js', function(req, res, next) {
}).
then
(
function
(
cont
,
result
)
{
//如果没有share值则用默认值
if
(
!
result
.
share
)
{
if
(
!
result
.
share
||
result
.
share_type
==
1
)
{
forumShareConfigService
.
getByKey
(
ent_code
,
'share'
,
function
(
err
,
sc
)
{
var
title
=
''
,
...
...
@@ -130,9 +162,9 @@ router.get('/:ent_code/share.js', function(req, res, next) {
for
(
var
i
=
0
;
i
<
sc
.
length
;
i
++
)
{
if
(
result
.
type
===
1
||
(
result
.
type
===
2
&&
result
.
level
===
2
))
{
if
(
sc
[
i
].
type
===
'article'
)
{
title
=
sc
[
i
].
title
;
desc
=
sc
[
i
].
desc
;
imgUrl
=
sc
[
i
].
imgUrl
;
...
...
@@ -147,7 +179,7 @@ router.get('/:ent_code/share.js', function(req, res, next) {
}
}
else
if
(
result
.
type
===
3
)
{
if
(
sc
[
i
].
type
===
'photo'
)
{
title
=
sc
[
i
].
title
;
desc
=
sc
[
i
].
desc
;
...
...
@@ -158,8 +190,8 @@ router.get('/:ent_code/share.js', function(req, res, next) {
}
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
);
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
result
.
_id
,
type
,
result
);
}
else
{
cont
(
err
);
}
...
...
@@ -181,7 +213,7 @@ router.get('/:ent_code/share.js', function(req, res, next) {
//key = 'photo';
}
getWX
(
res
,
forumShare
.
title
,
forumShare
.
description
,
link
,
forumShare
.
icon
,
mid
);
getWX
(
res
,
forumShare
.
title
,
forumShare
.
description
,
link
,
forumShare
.
icon
,
mid
,
result
.
_id
,
type
,
result
);
});
}
}).
fail
(
function
(
cont
,
err
)
{
...
...
app/controllers/mobile/forumShareConfig.js
0 → 100644
View file @
2e0696cb
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../../utils/returnCode'
),
_
=
require
(
'lodash'
);
var
mongoose
=
require
(
'mongoose'
);
//var forumThreadService = require('../../service/forumThreadService');
var
forumShareConfigService
=
require
(
'../../service/forumShareConfigService'
);
//var forumShareService = require('../../service/forumShareService');
//var config = require('../../../config/config');
var
then
=
require
(
'thenjs'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/v1/forum'
,
router
);
};
//type:类型(板块,照片墙等); key:类型里面的标题(title,desc等);value:值
function
getForumConfig
(
key
,
value
,
ent_code
)
{
var
forumConfig
=
{};
forumConfig
.
meta_key
=
key
;
forumConfig
.
meta_value
=
value
;
forumConfig
.
ent_code
=
ent_code
;
return
forumConfig
;
}
//批量创建默认分享设置
router
.
post
(
'/forumConfig/put'
,
function
(
req
,
res
,
next
)
{
var
model
=
req
.
body
;
var
ent_code
=
req
.
session
.
user
.
ent_code
;
model
.
ent_code
=
ent_code
;
if
(
model
.
ent_code
)
{
forumShareConfigService
.
create
(
model
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
}
});
}
else
{
res
.
json
(
returnCode
.
BUSY
);
}
});
//初始化默认分享数据
router
.
get
(
'/forumConfig/getConfig'
,
function
(
req
,
res
,
next
)
{
var
ent_code
=
req
.
session
.
user
.
ent_code
;
forumShareConfigService
.
getByKey
(
ent_code
,
req
.
query
.
meta_key
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
({
message
:
'success'
,
data
:
result
});
}
});
});
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