refactor: 清理小程序静态行业数据引用
This commit is contained in:
1 parent
947e6d1ac3
commit
bfa24d48d0
4 files changed
+145
-39
No files matched your search
@@ -1,8 +1,34 @@
|
||||
const { offerings } = require("../../utils/linjing-data");
|
||||
const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
|
||||
Page({
|
||||
data: { loading: false, error: "", offerings, filtered: offerings, modules: [], theme: {}, category: "全部" },
|
||||
onLoad() { loadWorkspaceWithFallback().then((workspace) => { const items = workspace.offerings || offerings; this.setData({ offerings: items, filtered: items, modules: workspace.modules || [], theme: workspace.theme || {} }); }); },
|
||||
switchCategory(e) { const category = e.currentTarget.dataset.category; const items = this.data.offerings || offerings; this.setData({ category, filtered: category === "全部" ? items : items.filter((item) => item.category === category) }); },
|
||||
open(e) { wx.navigateTo({ url: "/pages/offering/detail?id=" + e.currentTarget.dataset.id }); },
|
||||
data: {
|
||||
loading: false,
|
||||
error: "",
|
||||
offerings: [],
|
||||
filtered: [],
|
||||
modules: [],
|
||||
theme: {},
|
||||
category: "全部",
|
||||
},
|
||||
onLoad() {
|
||||
loadWorkspaceWithFallback().then((workspace) => {
|
||||
const items = workspace.offerings || [];
|
||||
this.setData({
|
||||
offerings: items,
|
||||
filtered: items,
|
||||
modules: workspace.modules || [],
|
||||
theme: workspace.theme || {},
|
||||
});
|
||||
});
|
||||
},
|
||||
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),
|
||||
});
|
||||
},
|
||||
open(e) {
|
||||
wx.navigateTo({ url: "/pages/offering/detail?id=" + e.currentTarget.dataset.id });
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user