Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
goods
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
goods
Commits
db9688ec
Commit
db9688ec
authored
Sep 28, 2021
by
jianghaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:修改
parent
128a59c3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
0 deletions
+48
-0
User.php
application/modules/User/controllers/User.php
+8
-0
UserService.php
application/services/user/UserService.php
+40
-0
No files found.
application/modules/User/controllers/User.php
View file @
db9688ec
...
@@ -48,6 +48,14 @@ class UserController extends Base
...
@@ -48,6 +48,14 @@ class UserController extends Base
$this
->
success
(
$userInfo
);
$this
->
success
(
$userInfo
);
}
}
public
function
generate_url_linkAction
()
{
$params
=
$this
->
params
;
$user
=
UserService
::
generateUrllink
(
$params
);
$userInfo
[
'result'
]
=
$user
;
$this
->
success
(
$userInfo
);
}
}
}
\ No newline at end of file
application/services/user/UserService.php
View file @
db9688ec
...
@@ -279,6 +279,46 @@ class UserService
...
@@ -279,6 +279,46 @@ class UserService
return
$update
;
return
$update
;
}
}
public
static
function
generateUrllink
()
{
//请求接口,获取用户openid
$generateUrl
=
'https://api.weixin.qq.com/wxa/generate_urllink?access_token='
.
self
::
getAccessToken
();
$params
=
[
'access_token'
=>
self
::
getAccessToken
(),
];
$params
=
[
"path"
=>
"/pages/product-info/index"
,
"query"
=>
"marketing_id=10000107&from=square"
,
"is_expire"
=>
true
,
"expire_type"
=>
1
,
"expire_interval"
=>
10
,
];
$response
=
(
new
Request
())
->
post
(
$generateUrl
,
$params
,
5000
,
'json'
);
$jsoninfo
=
$response
[
'response'
];
return
$jsoninfo
;
}
/**
* 获取accessToken
* @return mixed
*/
public
static
function
getAccessToken
()
{
$appid
=
\Yaf\Registry
::
get
(
'config'
)
->
wechat
->
appid
;
$appsecret
=
\Yaf\Registry
::
get
(
'config'
)
->
wechat
->
secret
;
$url
=
"https://api.weixin.qq.com/cgi-bin/token"
;
$params
=
[
'grant_type'
=>
'client_credential'
,
'appid'
=>
$appid
,
'secret'
=>
$appsecret
,
];
$response
=
(
new
Request
())
->
get
(
$url
,
$params
);
$jsoninfo
=
$response
[
'response'
];
$accessToken
=
$jsoninfo
[
"access_token"
];
return
$accessToken
;
}
private
static
function
generate3rdSession
(
$openid
)
{
private
static
function
generate3rdSession
(
$openid
)
{
return
md5
(
mt_rand
()
.
$openid
);
return
md5
(
mt_rand
()
.
$openid
);
}
}
...
...
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