"use strict"; const common_vendor = require("../../common/vendor.js"); const api_system_customer = require("../../api/system/customer.js"); const ErpTabBar = () => "../../components/erp-tab-bar.js"; const ErpNavBar = () => "../../components/erp-nav-bar.js"; const _sfc_main = { components: { ErpNavBar, ErpTabBar }, data() { return { isLoggedIn: false, authorizedClients: [], selectedModels: [] }; }, computed: { totalCount() { return this.selectedModels.reduce((sum, item) => sum + parseInt(item.count || 0), 0); } }, onLoad() { common_vendor.index.$on("add_order_item", (data) => { this.selectedModels.push(data); common_vendor.index.showToast({ title: "添加成功", icon: "success" }); }); common_vendor.index.$on("update_order_item", (res) => { if (res.index > -1) { this.$set(this.selectedModels, res.index, res.data); common_vendor.index.showToast({ title: "修改成功", icon: "success" }); } }); }, onShow() { this.checkLoginStatus(); }, onUnload() { common_vendor.index.$off("add_order_item"); common_vendor.index.$off("update_order_item"); }, methods: { async checkLoginStatus() { const token = common_vendor.index.getStorageSync("token"); if (!token) { this.isLoggedIn = false; this.authorizedClients = []; return; } try { await api_system_customer.getMyInfo(); this.isLoggedIn = true; this.loadAuthorizedClients(); } catch (e) { common_vendor.index.removeStorageSync("token"); common_vendor.index.removeStorageSync("isLogin"); this.isLoggedIn = false; this.authorizedClients = []; } }, loadAuthorizedClients() { const clients = common_vendor.index.getStorageSync("authorizedClients"); this.authorizedClients = clients || []; }, goToLogin() { common_vendor.index.reLaunch({ url: "/pages/login/index" }); }, contactAdmin() { common_vendor.index.showModal({ title: "联系管理员", content: "管理员电话:138-0000-0000", showCancel: false, confirmColor: "#C1001C" }); }, goToAddModel() { common_vendor.index.navigateTo({ url: "/pages/order/add-model/index" }); }, editItem(index, item) { common_vendor.index.navigateTo({ url: `/pages/order/edit-model/index?index=${index}&data=${encodeURIComponent(JSON.stringify(item))}` }); }, removeItem(index) { const self = this; common_vendor.index.showModal({ title: "提示", content: "确定移除该型号吗?", success: (res) => { if (res.confirm) { self.selectedModels.splice(index, 1); } } }); }, submitFinalOrder() { if (this.selectedModels.length === 0) return; common_vendor.index.showLoading({ title: "正在提交结果", mask: true }); setTimeout(() => { common_vendor.index.hideLoading(); common_vendor.index.navigateTo({ url: "/pages/order/success/index" }); }, 1500); } } }; if (!Array) { const _component_erp_nav_bar = common_vendor.resolveComponent("erp-nav-bar"); const _component_erp_tab_bar = common_vendor.resolveComponent("erp-tab-bar"); (_component_erp_nav_bar + _component_erp_tab_bar)(); } function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return common_vendor.e({ a: common_vendor.p({ title: "ERP 下单", ["show-back"]: false }), b: !$data.isLoggedIn }, !$data.isLoggedIn ? { c: common_vendor.o((...args) => $options.goToLogin && $options.goToLogin(...args), "93") } : $data.authorizedClients.length === 0 ? { e: common_vendor.o((...args) => $options.contactAdmin && $options.contactAdmin(...args), "e2") } : common_vendor.e({ f: $data.selectedModels.length > 0 }, $data.selectedModels.length > 0 ? {} : {}, { g: $data.selectedModels.length > 0 }, $data.selectedModels.length > 0 ? { h: common_vendor.f($data.selectedModels, (item, index, i0) => { return { a: common_vendor.o(($event) => $options.removeItem(index), index), b: common_vendor.t(item.type), c: common_vendor.t(item.count), d: common_vendor.t(item.surfaceName), e: index, f: common_vendor.o(($event) => $options.editItem(index, item), index) }; }) } : { i: common_vendor.o((...args) => $options.goToAddModel && $options.goToAddModel(...args), "7a") }, { j: $data.selectedModels.length > 0 }, $data.selectedModels.length > 0 ? { k: common_vendor.o((...args) => $options.goToAddModel && $options.goToAddModel(...args), "6d") } : {}, { l: $data.selectedModels.length > 0 }, $data.selectedModels.length > 0 ? { m: common_vendor.t($data.selectedModels.length), n: common_vendor.t($options.totalCount), o: $data.selectedModels.length === 0, p: common_vendor.o((...args) => $options.submitFinalOrder && $options.submitFinalOrder(...args), "7e") } : {}), { d: $data.authorizedClients.length === 0, q: common_vendor.p({ active: "order" }) }); } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-17a44f9d"]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/order/index.js.map