"use strict"; const common_vendor = require("../../../common/vendor.js"); const utils_file = require("../../../utils/file.js"); if (!Math) { BasicModal(); } const BasicModal = () => "../../../components/Modal/BasicModal.js"; const _sfc_main = { __name: "CartModal", props: { open: { type: Boolean, default: false }, cartList: { type: Array, default: () => [] }, discountAmount: { type: Number, default: 0 }, showCouponSection: { type: Boolean, default: true } }, emits: ["update:open", "increase", "decrease", "clear", "coupon-click", "order-click", "close"], setup(__props, { emit: __emit }) { const props = __props; const emit = __emit; const getOpen = common_vendor.computed({ get: () => props.open, set: (val) => emit("update:open", val) }); common_vendor.computed(() => { return props.cartList.reduce((sum, item) => { return sum + (item.quantity || 0); }, 0); }); common_vendor.computed(() => { return props.cartList.reduce((sum, item) => { const quantity = item.quantity || 0; const price = item.price || 0; return sum + quantity * price; }, 0); }); const formatPrice = (price) => { return Math.round(price).toFixed(0); }; const handleIncrease = (item) => { if (item.quantity >= 99) return; emit("increase", item); }; const handleDecrease = (item) => { if (item && item.quantity > 0) { emit("decrease", item); } }; const handleClear = () => { common_vendor.index.showModal({ title: "提示", content: "确定要清空购物车吗?", success: (res) => { if (res.confirm) { emit("clear"); } } }); }; const handleCouponClick = () => { emit("coupon-click"); }; return (_ctx, _cache) => { return common_vendor.e({ a: __props.cartList.length > 0 }, __props.cartList.length > 0 ? { b: common_vendor.o(handleClear) } : {}, { c: common_vendor.f(__props.cartList, (item, index, i0) => { return common_vendor.e({ a: item.image, b: common_vendor.t(item.name), c: item.tags && item.tags.length > 0 }, item.tags && item.tags.length > 0 ? { d: common_vendor.f(item.tags, (tag, tagIndex, i1) => { return { a: common_vendor.t(tag.text), b: tagIndex, c: common_vendor.n(tag.type) }; }) } : {}, { e: common_vendor.t(formatPrice(item.price)), f: item.quantity == 0, g: item.quantity != 0, h: item.quantity === 0 ? 1 : "", i: common_vendor.o(($event) => handleDecrease(item), item.id || index), j: common_vendor.t(item.quantity || 0), k: item.quantity < 99, l: item.quantity >= 99, m: common_vendor.o(($event) => handleIncrease(item), item.id || index), n: item.id || index }); }), d: common_vendor.unref(utils_file.getFileUrl)("img/icon/reduce1.png"), e: common_vendor.unref(utils_file.getFileUrl)("img/icon/reduce2.png"), f: common_vendor.unref(utils_file.getFileUrl)("img/icon/add2.png"), g: common_vendor.unref(utils_file.getFileUrl)("img/icon/add1.png"), h: __props.showCouponSection }, __props.showCouponSection ? common_vendor.e({ i: __props.discountAmount > 0 }, __props.discountAmount > 0 ? { j: common_vendor.t(formatPrice(__props.discountAmount)) } : {}, { k: common_vendor.o(handleCouponClick) }) : {}, { l: common_vendor.o(($event) => getOpen.value = $event), m: common_vendor.p({ type: "bottom", isMack: true, open: getOpen.value }) }); }; } }; const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1091c94b"]]); wx.createComponent(Component); //# sourceMappingURL=../../../../.sourcemap/mp-weixin/pages/orderFood/components/CartModal.js.map