feat: 收口多品牌与模板构建基础
This commit is contained in:
1 parent
0425a1c672
commit
77224ea51f
317 files changed
+11290
-1158
No files matched your search
@@ -1,4 +1,5 @@
|
||||
const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
|
||||
const config = require("../../utils/config");
|
||||
Page({
|
||||
data: {
|
||||
loading: false,
|
||||
@@ -7,28 +8,64 @@ Page({
|
||||
filtered: [],
|
||||
modules: [],
|
||||
theme: {},
|
||||
category: "全部",
|
||||
brand: {},
|
||||
presentation: {},
|
||||
category: "all",
|
||||
categories: [],
|
||||
pageRenderer: "",
|
||||
loadedBrandSlug: "",
|
||||
templateKey: "",
|
||||
navigation: [],
|
||||
},
|
||||
onLoad() {
|
||||
loadWorkspaceWithFallback().then((workspace) => {
|
||||
const items = workspace.offerings || [];
|
||||
this.setData({
|
||||
offerings: items,
|
||||
filtered: items,
|
||||
modules: workspace.modules || [],
|
||||
theme: workspace.theme || {},
|
||||
});
|
||||
});
|
||||
this.loadWorkspace();
|
||||
},
|
||||
onShow() {
|
||||
if (this.data.loadedBrandSlug && this.data.loadedBrandSlug !== config.brandSlug) {
|
||||
this.loadWorkspace();
|
||||
}
|
||||
},
|
||||
loadWorkspace() {
|
||||
loadWorkspaceWithFallback()
|
||||
.then((workspace) => {
|
||||
const items = workspace.offerings || [];
|
||||
this.setData({
|
||||
offerings: items,
|
||||
filtered: items,
|
||||
categories: [
|
||||
{ key: "all", label: "全部" },
|
||||
...Array.from(new Set(items.map((item) => item.category).filter(Boolean))).map(
|
||||
(key) => ({
|
||||
key,
|
||||
label: key,
|
||||
}),
|
||||
),
|
||||
],
|
||||
modules: workspace.modules || [],
|
||||
theme: workspace.theme || {},
|
||||
brand: workspace.brand || {},
|
||||
presentation: workspace.brand?.visualPresentation?.offerings || {},
|
||||
brand: workspace.brand || {},
|
||||
pageRenderer: workspace.pageRenderers?.offerings || "",
|
||||
loadedBrandSlug: config.brandSlug,
|
||||
templateKey: workspace.visualTemplate?.key || "",
|
||||
navigation: workspace.navigation || [],
|
||||
});
|
||||
})
|
||||
.catch((error) => this.setData({ error: error.message }));
|
||||
},
|
||||
switchCategory(e) {
|
||||
const category = e.currentTarget.dataset.category;
|
||||
const items = this.data.offerings || [];
|
||||
this.setData({
|
||||
category,
|
||||
filtered: category === "全部" ? items : items.filter((item) => item.category === category),
|
||||
filtered: category === "all" ? items : items.filter((item) => item.category === category),
|
||||
});
|
||||
},
|
||||
open(e) {
|
||||
wx.navigateTo({ url: "/pages/offering/detail?id=" + e.currentTarget.dataset.id });
|
||||
},
|
||||
inquire() {
|
||||
wx.navigateTo({ url: "/pages/inquiry/index" });
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user