48 lines
1.6 KiB
JavaScript
48 lines
1.6 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const common_http = require("../../common/http.js");
|
|
const TYPE_MAP = { cash: "现金", bank: "银行", alipay: "支付宝", wechat: "微信", other: "其他" };
|
|
const _sfc_main = {
|
|
data() {
|
|
return { accounts: [] };
|
|
},
|
|
async onLoad() {
|
|
try {
|
|
const res = await common_http.get("/api/accounts");
|
|
this.accounts = Array.isArray(res) ? res : (res == null ? void 0 : res.list) || [];
|
|
} catch (e) {
|
|
common_vendor.index.showToast({ title: "加载失败", icon: "none" });
|
|
}
|
|
},
|
|
methods: {
|
|
select(a) {
|
|
const opener = getCurrentPages()[getCurrentPages().length - 2];
|
|
if (opener && opener.$vm) {
|
|
opener.$vm.selectedAccountId = a.id;
|
|
opener.$vm.selectedAccountName = a.name;
|
|
}
|
|
common_vendor.index.navigateBack();
|
|
},
|
|
typeLabel(t) {
|
|
return TYPE_MAP[t] || t;
|
|
}
|
|
}
|
|
};
|
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
return {
|
|
a: common_vendor.f($data.accounts, (a, k0, i0) => {
|
|
var _a;
|
|
return {
|
|
a: common_vendor.t(a.name),
|
|
b: common_vendor.t($options.typeLabel(a.type)),
|
|
c: common_vendor.t(((_a = a.balance) == null ? void 0 : _a.toFixed) ? a.balance.toFixed(2) : a.balance),
|
|
d: a.id,
|
|
e: common_vendor.o(($event) => $options.select(a), a.id)
|
|
};
|
|
})
|
|
};
|
|
}
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/account/select.js.map
|