Files
persionalBrand/apps/miniapp/pages/services/index.js
T

35 lines
897 B
JavaScript

const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
Page({
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 });
},
});