| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- "use strict";
- const common_vendor = require("../../../common/vendor.js");
- const utils_file = require("../../../utils/file.js");
- const utils_utils = require("../../../utils/utils.js");
- const _sfc_main = {
- __name: "FoodCard",
- props: {
- food: {
- type: Object,
- required: true,
- default: () => ({
- id: null,
- name: "",
- price: 0,
- desc: "",
- image: "",
- tags: [],
- monthlySales: 0,
- quantity: 0
- })
- }
- },
- emits: ["increase", "decrease"],
- setup(__props, { emit: __emit }) {
- const props = __props;
- const emit = __emit;
- const handleFoodClick = () => {
- utils_utils.go("/pages/foodDetail/index");
- };
- const handleIncrease = () => {
- if (props.food.quantity >= 99)
- return;
- emit("increase", props.food);
- };
- const handleDecrease = () => {
- if (props.food.quantity > 0) {
- emit("decrease", props.food);
- }
- };
- const getPriceMain = (price) => {
- if (!price)
- return "0";
- const priceStr = String(price);
- const dotIndex = priceStr.indexOf(".");
- return dotIndex > -1 ? priceStr.substring(0, dotIndex) : priceStr;
- };
- const getPriceDecimal = (price) => {
- if (!price)
- return "";
- const priceStr = String(price);
- const dotIndex = priceStr.indexOf(".");
- return dotIndex > -1 ? priceStr.substring(dotIndex + 1) : "";
- };
- return (_ctx, _cache) => {
- return common_vendor.e({
- a: __props.food.image,
- b: common_vendor.o(handleFoodClick),
- c: common_vendor.t(__props.food.name),
- d: common_vendor.t(getPriceMain(__props.food.price)),
- e: getPriceDecimal(__props.food.price)
- }, getPriceDecimal(__props.food.price) ? {
- f: common_vendor.t(getPriceDecimal(__props.food.price))
- } : {}, {
- g: common_vendor.t(__props.food.desc),
- h: common_vendor.f(__props.food.tags, (tag, tagIndex, i0) => {
- return {
- a: common_vendor.t(tag.text),
- b: tagIndex,
- c: common_vendor.n(tag.type)
- };
- }),
- i: common_vendor.unref(utils_file.getFileUrl)("img/icon/star.png"),
- j: common_vendor.t(__props.food.monthlySales || 0),
- k: common_vendor.unref(utils_file.getFileUrl)("img/icon/reduce1.png"),
- l: __props.food.quantity == 0,
- m: common_vendor.unref(utils_file.getFileUrl)("img/icon/reduce2.png"),
- n: __props.food.quantity != 0,
- o: __props.food.quantity === 0 ? 1 : "",
- p: common_vendor.o(handleDecrease),
- q: common_vendor.t(__props.food.quantity || 0),
- r: common_vendor.unref(utils_file.getFileUrl)("img/icon/add2.png"),
- s: __props.food.quantity < 99,
- t: common_vendor.unref(utils_file.getFileUrl)("img/icon/add1.png"),
- v: __props.food.quantity >= 99,
- w: common_vendor.o(handleIncrease)
- });
- };
- }
- };
- const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-9fc46e58"]]);
- wx.createComponent(Component);
- //# sourceMappingURL=../../../../.sourcemap/mp-weixin/pages/orderFood/components/FoodCard.js.map
|