Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
loveisland
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
刘小敏
loveisland
Commits
a74f823f
Commit
a74f823f
authored
May 21, 2026
by
刘小敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化分享海报接口
parent
cff97ea7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
10 deletions
+29
-10
Wechat.php
addons/shopro/controller/third/Wechat.php
+29
-10
No files found.
addons/shopro/controller/third/Wechat.php
View file @
a74f823f
...
@@ -163,31 +163,50 @@ class Wechat extends Common
...
@@ -163,31 +163,50 @@ class Wechat extends Common
$this
->
success
(
'jssdkApi'
,
$data
);
$this
->
success
(
'jssdkApi'
,
$data
);
}
}
/**
/**
* 微信小程序码接口
* 微信小程序码接口
*/
*/
public
function
wxacode
()
public
function
wxacode
()
{
{
try
{
$mp
=
$this
->
wechat
->
getApp
();
$mp
=
$this
->
wechat
->
getApp
();
$path
=
$this
->
payload
[
'path'
];
$path
=
$this
->
payload
[
'path'
]
??
''
;
list
(
$page
,
$scene
)
=
explode
(
'?'
,
$path
);
// 验证路径
if
(
empty
(
$path
))
{
$this
->
error
(
'页面路径不能为空'
);
}
// 安全处理:使用 array_pad 确保变量存在
$parts
=
explode
(
'?'
,
$path
,
2
);
list
(
$page
,
$scene
)
=
array_pad
(
$parts
,
2
,
''
);
// 确保路径以 / 开头
if
(
$page
[
0
]
!==
'/'
)
{
$page
=
'/'
.
$page
;
}
// 根据域名或配置动态选择环境版本
$envVersion
=
'develop'
;
$content
=
$mp
->
app_code
->
getUnlimit
(
$scene
,
[
$content
=
$mp
->
app_code
->
getUnlimit
(
$scene
,
[
'page'
=>
substr
(
$page
,
1
),
'page'
=>
substr
(
$page
,
1
),
// 微信接口要求不带开头的 /
'is_hyaline'
=>
true
,
'is_hyaline'
=>
true
,
// 'env_version' => 'develop'
'env_version'
=>
$envVersion
'env_version'
=>
'release'
]);
]);
if
(
$content
instanceof
\EasyWeChat\Kernel\Http\StreamResponse
)
{
if
(
$content
instanceof
\EasyWeChat\Kernel\Http\StreamResponse
)
{
return
response
(
$content
->
getBody
(),
200
,
[
'Content-Length'
=>
strlen
(
$content
->
getBodyContents
())])
->
contentType
(
'image/png'
);
return
response
(
$content
->
getBody
(),
200
,
[
'Content-Length'
=>
strlen
(
$content
->
getBodyContents
())])
->
contentType
(
'image/png'
);
}
else
{
}
else
{
// 小程序码获取失败
// 记录详细日志
$msg
=
$content
[
'errcode'
]
??
'-'
;
$errcode
=
$content
[
'errcode'
]
??
'-'
;
$msg
.=
$content
[
'errmsg'
]
??
''
;
$errmsg
=
$content
[
'errmsg'
]
??
''
;
custom_log
(
'[微信小程序码]获取失败: page='
.
$page
.
', scene='
.
$scene
.
', env='
.
$envVersion
.
', errcode='
.
$errcode
.
', errmsg='
.
$errmsg
,
'wechat'
);
$this
->
error
(
$msg
);
$this
->
error
(
'获取小程序码失败: ['
.
$errcode
.
'] '
.
$errmsg
);
}
}
catch
(
\Exception
$e
)
{
custom_log
(
'[微信小程序码]异常: '
.
$e
->
getMessage
()
.
' | '
.
$e
->
getTraceAsString
(),
'wechat'
);
$this
->
error
(
'获取小程序码异常'
);
}
}
}
}
...
...
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