huangye-parking/miniapp/unpackage/dist/dev/mp-weixin/pages/points/detail.js
2026-03-03 23:31:28 +08:00

107 lines
3.6 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const api_points = require("../../api/points.js");
const api_store = require("../../api/store.js");
const NavBar = () => "../../components/NavBar.js";
const _sfc_main = {
components: { NavBar },
data() {
return {
loading: false,
currentType: "all",
currentStoreId: "",
currentStoreName: "全部门店",
storeOptions: [{ label: "全部门店", value: "" }],
records: []
};
},
onLoad() {
this.loadStores();
this.loadRecords();
},
methods: {
/** 加载门店列表用于筛选 */
async loadStores() {
try {
const res = await api_store.getStores();
const stores = res.data || res || [];
this.storeOptions = [
{ label: "全部门店", value: "" },
...stores.map((s) => ({ label: s.name, value: s.id }))
];
} catch (err) {
common_vendor.index.__f__("error", "at pages/points/detail.vue:82", "加载门店列表失败:", err);
}
},
/** 加载积分明细 */
async loadRecords() {
this.loading = true;
try {
const params = {};
if (this.currentType !== "all")
params.type = this.currentType;
if (this.currentStoreId)
params.storeId = this.currentStoreId;
const res = await api_points.getRecords(params);
this.records = res.data || res || [];
} catch (err) {
common_vendor.index.__f__("error", "at pages/points/detail.vue:96", "加载积分明细失败:", err);
} finally {
this.loading = false;
}
},
/** 切换类型标签 */
switchType(type) {
this.currentType = type;
this.loadRecords();
},
/** 门店筛选变更 */
onStoreChange(e) {
const idx = e.detail.value;
const option = this.storeOptions[idx];
this.currentStoreId = option.value;
this.currentStoreName = option.label;
this.loadRecords();
}
}
};
if (!Array) {
const _component_NavBar = common_vendor.resolveComponent("NavBar");
_component_NavBar();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: common_vendor.p({
title: "积分明细"
}),
b: $data.currentType === "all" ? 1 : "",
c: common_vendor.o(($event) => $options.switchType("all")),
d: $data.currentType === "income" ? 1 : "",
e: common_vendor.o(($event) => $options.switchType("income")),
f: $data.currentType === "expense" ? 1 : "",
g: common_vendor.o(($event) => $options.switchType("expense")),
h: common_vendor.t($data.currentStoreName),
i: $data.storeOptions,
j: common_vendor.o((...args) => $options.onStoreChange && $options.onStoreChange(...args)),
k: common_vendor.f($data.records, (record, k0, i0) => {
return common_vendor.e({
a: common_vendor.t(record.reason),
b: common_vendor.t(record.storeName),
c: common_vendor.t(record.createdAt),
d: record.couponName
}, record.couponName ? {
e: common_vendor.t(record.couponName)
} : {}, {
f: common_vendor.t(record.amount > 0 ? "+" : ""),
g: common_vendor.t(record.amount),
h: common_vendor.n(record.amount > 0 ? "income" : "expense"),
i: record.id
});
}),
l: !$data.records.length && !$data.loading
}, !$data.records.length && !$data.loading ? {} : {});
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-69825305"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/points/detail.js.map