分销提交

This commit is contained in:
wong
2025-12-18 16:23:01 +08:00
parent 66c8623138
commit 2f00ee176b
3 changed files with 334 additions and 14 deletions

View File

@@ -993,20 +993,13 @@ class ChannelController extends BaseController
]);
}
// 生成登录token只包含公司ID有效期1小时
// 用户扫码后需要自己输入手机号和密码
$tokenData = [
'companyId' => $companyId,
'expireTime' => time() + 3600 // 1小时后过期
];
$token = base64_encode(json_encode($tokenData));
if ($type === 'h5') {
// 生成H5登录二维码
$h5BaseUrl = Env::get('rpc.H5_FORM_URL', 'https://h5.ckb.quwanzhi.com/#');
$h5BaseUrl = rtrim($h5BaseUrl, '/');
// H5登录页面路径需要根据实际项目调整
$h5Url = $h5BaseUrl . '/pages/channel/login?token=' . urlencode($token);
// 登录入口只需要携带 companyId 参数
$h5Url = $h5BaseUrl . '/pages/channel/login?companyId=' . urlencode($companyId);
// 生成二维码
$qrCode = new QrCode($h5Url);
@@ -1042,8 +1035,11 @@ class ChannelController extends BaseController
$app = Factory::miniProgram($miniProgramConfig);
// scene参数长度限制为32位使用token的MD5值
$scene = substr(md5($token), 0, 32);
// scene 参数直接使用 companyId字符串并确保长度不超过32
$scene = (string)$companyId;
if (strlen($scene) > 32) {
$scene = substr($scene, 0, 32);
}
// 调用接口生成小程序码
// 小程序登录页面路径,需要根据实际项目调整
@@ -1064,8 +1060,7 @@ class ChannelController extends BaseController
'data' => [
'type' => 'miniprogram',
'qrCode' => $imgBase64,
'scene' => $scene,
'token' => $token
'scene' => $scene
]
]);
}