"use strict";
const common_vendor = require("../../../common/vendor.js");
const utils_file = require("../../../utils/file.js");
const _sfc_main = {
  __name: "BottomActionBar",
  props: {
    // 购物车数据列表
    cartList: {
      type: Array,
      default: () => []
    }
  },
  emits: ["coupon-click", "cart-click", "order-click"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const totalQuantity = common_vendor.computed(() => {
      return props.cartList.reduce((sum, item) => {
        return sum + (item.quantity || 0);
      }, 0);
    });
    const totalPrice = 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 handleCouponClick = () => {
      emit("coupon-click");
    };
    const handleCartClick = () => {
      emit("cart-click");
    };
    const handleOrderClick = () => {
      if (totalQuantity.value === 0)
        return;
      emit("order-click", {
        cartList: props.cartList,
        totalPrice: totalPrice.value,
        totalQuantity: totalQuantity.value
      });
    };
    return (_ctx, _cache) => {
      return {
        a: common_vendor.unref(utils_file.getFileUrl)("img/icon/shopBtn1.png"),
        b: common_vendor.unref(utils_file.getFileUrl)("img/icon/coupon.png"),
        c: common_vendor.o(handleCouponClick),
        d: common_vendor.unref(utils_file.getFileUrl)("img/icon/shopBtn2.png"),
        e: common_vendor.unref(utils_file.getFileUrl)("img/icon/shoppingCart.png"),
        f: common_vendor.t(totalQuantity.value),
        g: common_vendor.t(formatPrice(totalPrice.value)),
        h: common_vendor.o(handleCartClick),
        i: common_vendor.o(handleOrderClick)
      };
    };
  }
};
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-65412fc8"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/pages/orderFood/components/BottomActionBar.js.map
