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
c593d6d9
Commit
c593d6d9
authored
Jul 06, 2016
by
陈家荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
62287ecf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
1 deletion
+27
-1
util.js
app/utils/util.js
+27
-1
No files found.
app/utils/util.js
View file @
c593d6d9
...
...
@@ -3,6 +3,15 @@
var
_
=
require
(
'lodash'
);
var
loadUserLevel
=
require
(
'./loadUserLevel'
);
var
async
=
require
(
'async'
);
var
request
=
require
(
'request'
);
var
env
=
process
.
env
.
NODE_ENV
;
var
API_ADDRESS
=
'http://rest.wxpai.cn'
;
if
(
env
==
'sandbox'
)
{
API_ADDRESS
=
'http://rest.wxpai.cn'
;
}
else
if
(
env
==
'production'
)
{
API_ADDRESS
=
'https://rest.wxpai.cn'
;
}
exports
.
loadLevel
=
function
(
ent_code
,
items
,
callback
){
var
openIds
=
[];
...
...
@@ -27,7 +36,7 @@ exports.loadLevel=function(ent_code,items,callback){
var
tasks
=
[];
_
.
forEach
(
openIds
,
function
(
open_id
)
{
tasks
.
push
(
function
(
cont
){
load
UserLevel
.
load
LevelFromAPI
(
ent_code
,
open_id
,
cont
);
loadLevelFromAPI
(
ent_code
,
open_id
,
cont
);
});
});
async
.
parallel
(
tasks
,
function
(
err
,
results
){
...
...
@@ -111,4 +120,21 @@ exports.loadLevelByUser=function(ent_code,items,callback){
}
return
callback
&&
callback
();
});
};
function
loadLevelFromAPI
(
ent_code
,
open_id
,
callback
){
if
(
!
ent_code
||
!
open_id
){
return
callback
&&
callback
(
null
,
null
);
}
var
url
=
API_ADDRESS
+
'/v1.0/internal/member/exp/byopenid?openId='
+
open_id
+
'&entCode='
+
ent_code
;
request
.
get
({
url
:
url
,
json
:
{}
},
function
(
e
,
r
,
body
)
{
if
(
e
)
{
console
.
log
(
e
)
}
return
callback
&&
callback
(
null
,(
body
&&
body
.
data
)
||
null
);
});
};
\ No newline at end of file
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