fix(special-zone): 修复白名单弹窗checkbox未显示问题并添加专区小程序码功能

- 修复 UserSelectModal 弹窗中复选框不显示的根因,正确传入 selection-type="checkbox"
- 新增后台接口获取专区小程序码图片流,支持正式/体验/开发版环境
- 管理后台专区列表新增二维码按钮,弹窗展示对应专区小程序码
- 小程序端支持扫码参数 scene 解析,实现扫码直接进入专区页面
- 优化二维码弹窗组件,支持切换小程序版本并动态加载二维码
- 重新构建前端及后端服务,确保新功能生效和兼容原有业务逻辑
This commit is contained in:
2026-08-17 02:39:52 +08:00
parent f986efce8c
commit d458115da9
4 changed files with 146 additions and 2 deletions
+28
View File
@@ -182,3 +182,31 @@ export async function checkSectionPermission(sectionIds: number[]) {
}
return Promise.reject(new Error(res.data.message));
}
/**
* 获取专区小程序码(图片流),返回可用于 <img src> 的 objectURL
* @param id 专区ID
* @param envVersion release(正式版) / trial(体验版) / develop(开发版)
*/
export async function getSectionQrcode(
id: number,
envVersion: string = 'release'
): Promise<string> {
const res = await request.get(
MODULES_API_URL + '/shop/shop-home-section/' + id + '/qrcode',
{ responseType: 'blob', params: { envVersion } } as any
);
const blob = res.data as Blob;
// 微信/后端出错时会返回 JSON 而非图片,这里解析出错误信息
if (blob && blob.type && blob.type.indexOf('image') === -1) {
let msg = '生成小程序码失败';
try {
const json = JSON.parse(await blob.text());
if (json && json.error) msg = json.error;
} catch (e) {
/* 忽略解析失败 */
}
return Promise.reject(new Error(msg));
}
return window.URL.createObjectURL(blob);
}