Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
ydLife
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sweet Zhang
ydLife
Commits
d0173023
Commit
d0173023
authored
Apr 20, 2021
by
sunchao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取微信个人信息接口调试
parent
2a70ae39
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
5 deletions
+88
-5
src/app/my/article-detail/article-detail.component.html
+1
-0
src/app/my/article-detail/article-detail.component.ts
+57
-4
src/app/my/my-routing.module.ts
+1
-1
src/app/my/my.service.ts
+29
-0
No files found.
src/app/my/article-detail/article-detail.component.html
View file @
d0173023
...
...
@@ -21,5 +21,6 @@
</div>
</div>
</div>
<div
#
payForm
hidden
></div>
src/app/my/article-detail/article-detail.component.ts
View file @
d0173023
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
Component
,
OnInit
,
ElementRef
,
ViewChild
}
from
'@angular/core'
;
import
{
MyService
}
from
'../../my/my.service'
;
import
{
LifeCommonService
}
from
'../../common/life-common.service'
;
@
Component
({
selector
:
'ydlife-article-detail'
,
...
...
@@ -6,12 +8,63 @@ import { Component, OnInit } from '@angular/core';
styleUrls
:
[
'./article-detail.component.scss'
]
})
export
class
ArticleDetailComponent
implements
OnInit
{
@
ViewChild
(
'payForm'
)
payForm
:
ElementRef
;
articleInfo
:
any
;
constructor
()
{
}
lifeCustomerInfo
:
any
;
paymentForm
:
any
;
customerId
:
number
;
constructor
(
private
myService
:
MyService
,
public
lifeCommonService
:
LifeCommonService
)
{
}
ngOnInit
()
{
this
.
articleInfo
=
JSON
.
parse
(
sessionStorage
.
getItem
(
'articleInfo'
))
console
.
log
(
this
.
articleInfo
)
this
.
articleInfo
=
JSON
.
parse
(
sessionStorage
.
getItem
(
'articleInfo'
));
this
.
lifeCustomerInfo
=
JSON
.
parse
(
localStorage
.
getItem
(
'lifeCustomerInfo'
))?
JSON
.
parse
(
localStorage
.
getItem
(
'lifeCustomerInfo'
)):
null
;
if
(
this
.
lifeCustomerInfo
){
this
.
customerId
=
JSON
.
parse
(
localStorage
.
getItem
(
'lifeCustomerInfo'
))[
'customerId'
]
}
else
{
this
.
customerId
=
null
;
}
if
(
this
.
lifeCommonService
.
checkDeviceType
()
==
'3'
&&
!
this
.
customerId
)
{
this
.
getWxUserInfo
();
}
}
// 从后台获取到获取微信code的URL
getWxUserInfo
()
{
this
.
myService
.
getWxUserInfo
(
this
.
customerId
).
subscribe
(
res
=>
{
if
(
res
[
'success'
])
{
this
.
paymentForm
=
res
[
'data'
].
paymentForm
;
alert
(
res
[
'data'
][
'userInfo'
]);
this
.
getOrPost
(
this
.
paymentForm
.
action
,
this
.
paymentForm
.
param
,
this
.
paymentForm
.
charset
,
this
.
paymentForm
.
actionType
)
}
})
}
// 判断是get请求还是post请求进行支付请求
getOrPost
(
action
,
params
,
charset
,
actionType
)
{
let
url
=
''
;
let
paramHTML
=
''
;
let
hiddenContent
=
''
;
if
(
actionType
.
toLowerCase
()
===
'get'
)
{
url
=
action
;
if
(
params
)
{
for
(
let
i
=
0
;
i
<
params
.
length
;
i
++
)
{
url
+=
'&'
+
params
[
i
].
name
+
'='
+
params
[
i
].
value
;
}
}
window
.
location
.
href
=
url
;
}
else
if
(
actionType
.
toLowerCase
()
===
'post'
)
{
if
(
params
)
{
for
(
let
i
=
0
;
i
<
params
.
length
;
i
++
)
{
paramHTML
+=
'<input type="text" value="'
+
params
[
i
].
value
+
'" name="'
+
params
[
i
].
name
+
'" hidden>'
}
}
hiddenContent
+=
'<form action="'
+
action
+
'"method="post" accept-charset="'
+
charset
+
'" onsubmit="document.charset=
\'
'
+
charset
+
'
\'
;">'
+
paramHTML
+
'<button type="submit" id="submit" hidden></button>'
+
'</form>'
;
this
.
payForm
.
nativeElement
.
innerHTML
=
hiddenContent
;
document
.
getElementById
(
'submit'
).
click
();
}
}
}
src/app/my/my-routing.module.ts
View file @
d0173023
...
...
@@ -107,7 +107,7 @@ const myRoutes: Routes = [
{
path
:
'suggestion'
,
component
:
SuggestionComponent
,
data
:
[{
title
:
'问题反馈'
}],
canActivate
:[
AuthGuard
]},
{
path
:
'historical_rank'
,
component
:
HistoricalRankComponent
,
canActivate
:
[
AuthGuard
]
},
{
path
:
'team_area'
,
component
:
TeamAreaPanelComponent
,
canActivate
:
[
AuthGuard
]},
{
path
:
'article'
,
component
:
ArticleComponent
,
canActivate
:[
AuthGuard
]
},
{
path
:
'article'
,
component
:
ArticleComponent
},
{
path
:
'articleDetail'
,
component
:
ArticleDetailComponent
}
];
...
...
src/app/my/my.service.ts
View file @
d0173023
...
...
@@ -606,4 +606,33 @@ export class MyService {
return
res
;
});
}
/**
* 获取微信用户的详细信息
*/
getWxUserInfo
(
customerId
)
{
const
url
=
this
.
API
+
'/getWxUserInfo'
;
const
cs
=
{
customerId
:
customerId
};
return
this
.
http
.
post
(
url
,
cs
).
pipe
((
res
)
=>
{
return
res
;
});
}
//保存文章code
articleShareCodeSave
(
param
){
const
url
=
this
.
ydapi
+
'/practitionerArticle/articleShareCodeSave'
;
return
this
.
http
.
post
(
url
,
JSON
.
stringify
(
param
)).
pipe
((
res
)
=>
{
return
res
;
});
}
//保存客户痕迹
articleTrackSave
(
param
){
const
url
=
this
.
ydapi
+
'/practitionerArticle/articleTrackSave'
;
return
this
.
http
.
post
(
url
,
JSON
.
stringify
(
param
)).
pipe
((
res
)
=>
{
return
res
;
});
}
}
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