Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
5
51business
Project
Project
Details
Activity
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
方斌
51business
Commits
a149c56e
Commit
a149c56e
authored
Oct 15, 2019
by
李尚科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
c9c15ad4
Pipeline
#14951
passed with stage
in 7 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
7 deletions
+61
-7
home.js
app/controller/credit/home.js
+4
-2
wechat.js
app/controller/gjj/wechat.js
+55
-4
credit.js
app/router/credit.js
+1
-0
config.local.js
config/config.local.js
+1
-1
No files found.
app/controller/credit/home.js
View file @
a149c56e
...
@@ -15,9 +15,11 @@ class HomeController extends Controller {
...
@@ -15,9 +15,11 @@ class HomeController extends Controller {
async
test
()
{
async
test
()
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
stream1
=
await
ctx
.
getFileStream
();
const
orderSn
=
await
ctx
.
query
.
sn
;
const
yys_report_data
=
await
ctx
.
service
.
credit
.
yys
.
getData
(
orderSn
);
//拉取报告数据
// const stream1 = await ctx.getFileStream();
// await pump(stream, writeStream);
// await pump(stream, writeStream);
ctx
.
success
(
stream1
);
ctx
.
success
(
yys_report_data
);
}
}
}
}
...
...
app/controller/gjj/wechat.js
View file @
a149c56e
'use strict'
;
'use strict'
;
const
Controller
=
require
(
'egg'
).
Controller
;
const
Controller
=
require
(
'egg'
).
Controller
;
const
WECHAT_CODE_URL
=
'https://open.weixin.qq.com/connect/oauth2/authorize'
;
const
WECHAT_AUTH
=
'https://api.weixin.qq.com/sns/oauth2/access_token'
;
const
WECHAT_APPID
=
''
;
const
WECHAT_SECRET
=
''
;
const
NO_GJJ_PAGE
=
'https://www.baidu.com'
;
const
GJJ_DETAIL_PAGE
=
'https:www.jianbing.com'
;
class
WechatController
extends
Controller
{
class
WechatController
extends
Controller
{
async
oauthLogin
()
{
async
oauthLogin
()
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
result
=
{};
const
code
=
ctx
.
query
.
code
;
ctx
.
success
(
result
);
if
(
!
code
||
code
.
length
===
0
)
{
const
target_url
=
WECHAT_CODE_URL
+
`?appid=
${
WECHAT_APPID
}
&redirect_uri=
${
encodeURIComponent
(
`https://p.jianbing.com/51ucenter/api/user/oauth?business_url=
${
encodeURIComponent
(
business_url
)}
&login_url=
${
encodeURIComponent
(
login_url
)}
&appid=
${
appid
}
&`
)}
&response_type=code&scope=snsapi_base&state=gjjquery#wechat_redirect`
;
ctx
.
redirect
(
target_url
);
}
const
url
=
`
${
WECHAT_AUTH
}
?appid=
${
WECHAT_APPID
}
&secret=
${
WECHAT_SECRET
}
&code=
${
code
}
&grant_type=authorization_code`
const
result
=
await
ctx
.
helper
.
send_request
(
url
,
{},
{
method
:
'GET'
});
if
(
result
.
status
!==
200
)
{
ctx
.
failed
(
'获取openid失败'
);
}
const
wx_ret
=
result
.
data
;
if
(
!
wx_ret
.
openid
)
{
ctx
.
failed
(
'获取openid失败'
);
}
const
openid
=
wx_ret
.
openid
;
//判断是否已绑定手机号
const
user_exist_url
=
`
${
this
.
app
.
config
.
NODE_BASE_URL
}
/user_api/v1/user/is_exist/
${
openid
}
`
;
const
bind_phone_result
=
await
ctx
.
helper
.
send_request
(
user_exist_url
,
{},
{
method
:
'GET'
});
if
(
bind_phone_result
.
status
!==
200
)
{
ctx
.
redirect
(
NO_GJJ_PAGE
);
return
;
}
const
user_exist_ret
=
bind_phone_result
.
data
;
if
(
user_exist_ret
.
result
!=
'true'
)
{
//未绑定的手机号时
ctx
.
redirect
(
NO_GJJ_PAGE
);
return
;
}
const
user_id
=
user_exist_ret
.
uid
;
//判断是否有导入公积金
const
gjj_exist_url
=
`
${
this
.
app
.
config
.
NODE_BASE_URL
}
/cassandra-server/gjj/list/
${
user_id
}
`
;
const
gjj_exist_result
=
await
ctx
.
helper
.
send_request
(
gjj_exist_url
,
{},
{
method
:
'GET'
});
if
(
gjj_exist_result
.
status
!==
200
)
{
ctx
.
redirect
(
NO_GJJ_PAGE
);
return
;
}
const
gjj_exist_ret
=
gjj_exist_result
.
data
;
if
(
!
gjj_exist_ret
.
ret
||
gjj_exist_ret
.
ret
.
length
===
0
)
{
//没有导入公积金时
ctx
.
redirect
(
NO_GJJ_PAGE
);
return
;
}
const
login_params
=
{
code
:
code
,
login_type
:
'5'
,
passport
:
code
,
password
:
code
,
openid
:
openid
,
}
await
ctx
.
service
.
user
.
user_login
(
login_params
);
//用户直接登录
ctx
.
redirect
(
GJJ_DETAIL_PAGE
);
return
;
}
}
async
checkLogin
()
{
async
checkLogin
()
{
...
@@ -20,8 +71,8 @@ class WechatController extends Controller {
...
@@ -20,8 +71,8 @@ class WechatController extends Controller {
if
(
user_id
)
{
if
(
user_id
)
{
is_login
=
true
;
is_login
=
true
;
}
}
const
phone
=
await
ctx
.
helper
.
getPhoneCity
(
'15968762898'
);
ctx
.
success
({
result
:
is_login
});
ctx
.
success
({
result
:
is_login
,
phone
});
}
}
}
}
...
...
app/router/credit.js
View file @
a149c56e
...
@@ -13,6 +13,7 @@ module.exports = app => {
...
@@ -13,6 +13,7 @@ module.exports = app => {
router
.
get
(
'/home'
,
'credit.home.home'
);
//首页
router
.
get
(
'/home'
,
'credit.home.home'
);
//首页
router
.
get
(
'/test'
,
'credit.home.test'
);
//首页
//我的信用-黑名单报告
//我的信用-黑名单报告
...
...
config/config.local.js
View file @
a149c56e
...
@@ -90,7 +90,7 @@ module.exports = appInfo => {
...
@@ -90,7 +90,7 @@ module.exports = appInfo => {
// other sequelize configurations
// other sequelize configurations
dialect
:
'mysql'
,
dialect
:
'mysql'
,
host
:
'rm-bp1mnwmta5778y0d3jo.mysql.rds.aliyuncs.com'
,
host
:
'rm-bp1mnwmta5778y0d3jo.mysql.rds.aliyuncs.com'
,
database
:
'prometheus_
dev
'
,
database
:
'prometheus_
uat
'
,
username
:
'prometheus'
,
username
:
'prometheus'
,
password
:
'q9t8Ay4qIUW4sw3s25K28'
,
password
:
'q9t8Ay4qIUW4sw3s25K28'
,
port
:
3306
,
port
:
3306
,
...
...
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