26 lines
1.1 KiB
JavaScript
26 lines
1.1 KiB
JavaScript
/** 下单前确认真实配置模块;本地 DCIM 与转售 DCIM 使用不同配置组件,不能仅看商品名。 */
|
|
function e(e) {
|
|
let t = typeof e.module == `string` ? e.module.trim() : ``,
|
|
n = typeof e.res_module == `string` ? e.res_module.trim() : ``;
|
|
if (t === `mf_dcim`) return `mf_dcim`;
|
|
if (t === `remf_dcim` || (!t && n === `mf_dcim`)) return `remf_dcim`;
|
|
}
|
|
// 已知非 mf_cloud 模块可直接使用;缺失/含糊时读取配置接口,取不到模块就明确失败。
|
|
async function t(t, n) {
|
|
let r = typeof n.module == `string` ? n.module.trim() : ``,
|
|
i = e(n);
|
|
if (i) return i;
|
|
if (r && r !== `mf_cloud`) return r;
|
|
let a = await t.get(`/product/${n.id}/config_option`),
|
|
o = typeof a?.module == `string` ? a.module.trim() : ``,
|
|
s =
|
|
e({
|
|
module: o,
|
|
res_module: typeof a?.res_module == `string` ? a.res_module.trim() : ``,
|
|
}) || (!r && n.res_module === `mf_dcim` ? `remf_dcim` : void 0);
|
|
if (s) return s;
|
|
if (!o) throw Error(`商品配置类型加载失败,请重试`);
|
|
return o;
|
|
}
|
|
export { t };
|