feat: 收口多品牌与模板构建基础

This commit is contained in:
que01 committed 2026-09-25 02:55:46 +08:00
1 parent 0425a1c672
commit 77224ea51f
317 files changed
+11290 -1158

No files matched your search

+9 -3
View File
@@ -1,11 +1,17 @@
const config = require("./config");
function withBrandContext(path, options) {
if (options.includeBrand === false || !path.startsWith("/public/")) return path;
const requiresBrandContext =
path.startsWith("/public/") || path.startsWith("/customer/session/wechat");
if (options.includeBrand === false || !requiresBrandContext) return path;
const separator = path.includes("?") ? "&" : "?";
return path + separator + "brandSlug=" + encodeURIComponent(config.brandSlug);
}
function customerTokenKey() {
return "customerToken:" + config.brandSlug;
}
function request(path, options = {}) {
return new Promise((resolve, reject) => {
const requestPath = withBrandContext(path, options);
@@ -25,11 +31,11 @@ function request(path, options = {}) {
}
function customerRequest(path, options = {}) {
const token = wx.getStorageSync("customerToken");
const token = wx.getStorageSync(customerTokenKey());
return request(path, {
...options,
header: { ...(options.header || {}), Authorization: "Bearer " + token },
});
}
module.exports = { request, customerRequest };
module.exports = { request, customerRequest, customerTokenKey };