This commit is contained in:
wong
2025-12-18 10:50:50 +08:00
parent 1cb7903e37
commit 1a345fff79

View File

@@ -37,7 +37,7 @@ class PosterWeChatMiniProgram extends Controller
// 生成小程序码,存客宝-操盘手调用
public function generateMiniProgramCodeWithScene($taskId = '')
public function generateMiniProgramCodeWithScene($taskId = '', $channelId = 0)
{
if (empty($taskId)) {
@@ -48,8 +48,19 @@ class PosterWeChatMiniProgram extends Controller
try {
$app = Factory::miniProgram($this->config);
// scene参数长度限制为32位
//$scene = 'taskId=' . $taskId;
$scene = sprintf("%s", $taskId);
// 如果提供了channelId格式为taskId,channelId
// 如果没有channelId格式为taskId
if (!empty($channelId) && $channelId > 0) {
$scene = sprintf("%s,%s", $taskId, $channelId);
} else {
$scene = sprintf("%s", $taskId);
}
// 确保scene长度不超过32位
if (strlen($scene) > 32) {
$scene = substr($scene, 0, 32);
}
// 调用接口生成小程序码
$response = $app->app_code->getUnlimit($scene, [
'page' => 'pages/poster/index2', // 必须是已经发布的小程序页面