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
bbbf4b7b
Commit
bbbf4b7b
authored
Apr 22, 2015
by
陈志良
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分享 回退
parent
d5f3c817
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
178 additions
and
1 deletion
+178
-1
forumShare.js
app/controllers/mobile/forumShare.js
+178
-1
No files found.
app/controllers/mobile/forumShare.js
View file @
bbbf4b7b
...
...
@@ -17,8 +17,8 @@ module.exports = function(app) {
app
.
use
(
'/v1/forum'
,
router
);
};
function
write
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
ent_code
)
{
link
=
config
.
service
+
link
+
"&mid="
+
mid
;
res
.
writeHead
(
200
,
{
'Content-Type'
:
'text/javascript'
,
'Cache-Control'
:
'no-cache'
,
...
...
@@ -74,3 +74,180 @@ function getWX(res, title, desc, link, imgUrl, mid,ent_code, id,type,forumThread
}
//微信分享接口
router
.
get
(
'/:ent_code/share.js'
,
function
(
req
,
res
,
next
)
{
var
rs
=
{};
var
type
=
req
.
query
.
type
;
var
id
=
req
.
query
.
id
;
var
uId
=
req
.
session
.
mobileForumUser
.
userId
;
var
mid
=
0
;
if
(
req
.
session
.
openUser
&&
req
.
session
.
openUser
.
mid
)
{
mid
=
req
.
session
.
openUser
.
mid
;
}
var
ent_code
=
req
.
params
.
ent_code
;
var
link
=
'/app/forum/'
+
ent_code
+
'/index?pageUrl='
;
if
(
type
)
{
//板块微信接口
if
(
type
===
'Info'
)
{
then
(
function
(
cont
)
{
forumShareConfigService
.
getByKey
(
ent_code
,
'share'
,
function
(
err
,
result
)
{
console
.
log
(
err
);
var
title
=
''
,
desc
=
''
,
imgUrl
=
''
;
if
(
result
)
{
result
=
result
.
meta_value
;
for
(
var
i
=
0
;
i
<
result
.
length
;
i
++
)
{
if
(
result
[
i
].
type
===
'info'
)
{
title
=
result
[
i
].
title
;
desc
=
result
[
i
].
desc
;
imgUrl
=
result
[
i
].
imgUrl
;
}
}
if
(
id
)
{
link
=
link
+
'index&infoId='
+
id
;
}
else
{
link
=
link
+
'index'
;
}
link
=
link
+
'&uId='
+
uId
;
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
ent_code
,
id
,
type
,
null
);
}
else
{
cont
(
err
);
}
});
}).
fail
(
function
(
cont
,
err
)
{
console
.
error
(
err
);
res
.
json
({
result
:
false
,
code
:
'10002'
});
});
}
else
if
(
!
id
)
{
console
.
error
(
"ID不能为空"
);
res
.
json
({
message
:
'ID不能为空'
,
result
:
false
,
code
:
'10002'
});
}
else
if
(
type
===
'Thread'
)
{
then
(
function
(
cont
)
{
//获得文章
forumThreadService
.
getById
(
id
,
function
(
err
,
result
)
{
if
(
result
)
{
cont
(
null
,
result
);
}
else
{
cont
(
err
);
}
});
}).
then
(
function
(
cont
,
result
)
{
//如果没有share值则用默认值
if
(
!
result
.
share
||
result
.
share_type
==
1
)
{
forumShareConfigService
.
getByKey
(
ent_code
,
'share'
,
function
(
err
,
sc
)
{
var
title
=
''
,
desc
=
''
,
imgUrl
=
''
;
if
(
sc
)
{
if
(
result
.
type
===
1
||
(
result
.
type
===
2
&&
result
.
level
===
2
))
{
link
=
link
+
'thread&infoId='
+
result
.
info
+
'&ent_code='
+
ent_code
+
'&id='
+
result
.
_id
;
}
else
if
(
result
.
type
===
2
&&
result
.
level
===
1
)
{
link
=
link
+
'topicList&infoId='
+
result
.
info
+
'&ent_code='
+
ent_code
+
'&id='
+
result
.
_id
;
}
else
if
(
result
.
type
===
3
)
{
link
=
link
+
'photoList&infoId='
+
result
.
info
+
'&ent_code='
+
ent_code
+
'&id='
+
result
.
_id
;
}
//1、文章 2、话题 3、照片墙
sc
=
sc
.
meta_value
;
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
;
}
}
else
if
(
result
.
type
===
2
&&
result
.
level
===
1
)
{
if
(
sc
[
i
].
type
===
'topic'
)
{
title
=
sc
[
i
].
title
;
desc
=
sc
[
i
].
desc
;
imgUrl
=
sc
[
i
].
imgUrl
;
}
}
else
if
(
result
.
type
===
3
)
{
if
(
sc
[
i
].
type
===
'photo'
)
{
title
=
sc
[
i
].
title
;
desc
=
sc
[
i
].
desc
;
imgUrl
=
sc
[
i
].
imgUrl
;
}
}
}
link
=
link
+
'&uId='
+
uId
;
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
ent_code
,
result
.
_id
,
type
,
result
);
}
else
{
cont
(
err
);
}
});
}
else
{
//如果有分享设置,则返回分享设置
forumShareService
.
getById
(
result
.
share
,
function
(
err
,
forumShare
)
{
//1、文章 2、话题 3、照片墙
if
(
result
.
type
===
1
||
(
result
.
type
===
2
&&
result
.
level
===
2
))
{
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
+
'topicList&infoId='
+
result
.
info
+
'&ent_code='
+
ent_code
+
'&id='
+
result
.
_id
;
//key = 'topic';
}
else
if
(
result
.
type
===
3
)
{
link
=
link
+
'photoList&infoId='
+
result
.
info
+
'&ent_code='
+
ent_code
+
'&id='
+
result
.
_id
;
//key = 'photo';
}
link
=
link
+
'&uId='
+
uId
;
getWX
(
res
,
forumShare
.
title
,
forumShare
.
description
,
link
,
forumShare
.
icon
,
mid
,
ent_code
,
result
.
_id
,
type
,
result
);
});
}
}).
fail
(
function
(
cont
,
err
)
{
console
.
error
(
err
);
res
.
json
({
result
:
false
,
code
:
'10002'
});
});
}
}
else
{
res
.
json
({
result
:
false
,
code
:
'10002'
});
}
});
//微信分享接口
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
();
});
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