312
This commit is contained in:
parent
9541224f46
commit
408c17af6c
|
|
@ -222,13 +222,35 @@
|
||||||
console.log("v.scene:", v.scene);
|
console.log("v.scene:", v.scene);
|
||||||
console.log("当前存储的 pid:", uni.getStorageSync("pid"));
|
console.log("当前存储的 pid:", uni.getStorageSync("pid"));
|
||||||
|
|
||||||
|
// 处理普通分享链接的 pid 参数
|
||||||
if (v.pid) {
|
if (v.pid) {
|
||||||
console.log("设置 pid 到 storage:", v.pid);
|
console.log("设置 pid 到 storage:", v.pid);
|
||||||
uni.setStorageSync("pid", v.pid);
|
uni.setStorageSync("pid", v.pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理小程序码的 scene 参数
|
||||||
|
// scene 格式为 "pid=25498",需要解析
|
||||||
if (v.scene) {
|
if (v.scene) {
|
||||||
console.log("设置 scene 作为 pid 到 storage:", v.scene);
|
console.log("收到 scene 参数:", v.scene);
|
||||||
uni.setStorageSync("pid", v.scene);
|
// scene 参数会被 encodeURIComponent 编码,需要解码
|
||||||
|
const decodedScene = decodeURIComponent(v.scene);
|
||||||
|
console.log("解码后的 scene:", decodedScene);
|
||||||
|
|
||||||
|
// 解析 scene 参数,格式为 "pid=xxx"
|
||||||
|
const sceneParams = {};
|
||||||
|
decodedScene.split('&').forEach(item => {
|
||||||
|
const [key, value] = item.split('=');
|
||||||
|
if (key && value) {
|
||||||
|
sceneParams[key] = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log("解析后的 scene 参数:", JSON.stringify(sceneParams));
|
||||||
|
|
||||||
|
// 如果 scene 中包含 pid,设置到 storage
|
||||||
|
if (sceneParams.pid) {
|
||||||
|
console.log("从 scene 中提取 pid:", sceneParams.pid);
|
||||||
|
uni.setStorageSync("pid", sceneParams.pid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("设置后存储的 pid:", uni.getStorageSync("pid"));
|
console.log("设置后存储的 pid:", uni.getStorageSync("pid"));
|
||||||
|
|
|
||||||
|
|
@ -87,8 +87,10 @@ public class PosterService : IPosterService
|
||||||
if (platform.Equals("MP-WEIXIN", StringComparison.OrdinalIgnoreCase))
|
if (platform.Equals("MP-WEIXIN", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
// 小程序:调用微信API生成小程序码
|
// 小程序:调用微信API生成小程序码
|
||||||
|
// 注意:未发布的小程序不能指定page参数,否则会报错41030
|
||||||
|
// scene参数会在小程序onLoad中通过options.scene获取
|
||||||
var scene = $"pid={userId}";
|
var scene = $"pid={userId}";
|
||||||
qrCodeBytes = await _wechatService.GetWxaCodeUnlimitAsync(scene, "pages/shouye/index", posterConfig.QrCodeSize ?? DefaultQrCodeSize);
|
qrCodeBytes = await _wechatService.GetWxaCodeUnlimitAsync(scene, null, posterConfig.QrCodeSize ?? DefaultQrCodeSize);
|
||||||
if (qrCodeBytes == null)
|
if (qrCodeBytes == null)
|
||||||
{
|
{
|
||||||
return new PosterResult { Success = false, Message = "生成小程序码失败" };
|
return new PosterResult { Success = false, Message = "生成小程序码失败" };
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user