"use strict";
const common_vendor = require("../../../common/vendor.js");
if (!Array) {
  const _easycom_su_popup2 = common_vendor.resolveComponent("su-popup");
  _easycom_su_popup2();
}
const _easycom_su_popup = () => "../../ui/su-popup/su-popup.js";
if (!Math) {
  _easycom_su_popup();
}
const _sfc_main = {
  __name: "s-points-pop",
  props: {
    modelValue: {
      // 优惠劵列表
      type: Object,
      default() {
      }
    },
    show: {
      type: Boolean,
      default: false
    },
    currentMemberPoints: {
      type: Number,
      default: 0
    },
    currentTotalPrice: {
      type: Number,
      default: 0
    },
    currentDeliveryPrice: {
      type: Number,
      default: 0
    }
  },
  emits: ["confirm", "close"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emits = __emit;
    const state = common_vendor.reactive({
      points: 0,
      disabled: false
    });
    const currentOrderMemberPoints = common_vendor.computed(() => {
      return parseFloat(props.currentMemberPoints);
    });
    const currentOrderTotalPrice = common_vendor.computed(() => {
      return parseFloat(props.currentTotalPrice);
    });
    const currentOrderDeliveryPrice = common_vendor.computed(() => {
      return parseFloat(props.currentDeliveryPrice);
    });
    const canUesPoint = common_vendor.computed(() => {
      if (!currentOrderTotalPrice.value)
        return currentOrderTotalPrice.value;
      return (currentOrderTotalPrice.value - 0.01 - currentOrderDeliveryPrice.value).toFixed(2);
    });
    common_vendor.watchEffect(() => {
      if (state.points > currentOrderMemberPoints.value) {
        common_vendor.nextTick$1(() => {
          state.points = currentOrderMemberPoints.value;
        });
      }
      if (state.points > canUesPoint.value) {
        common_vendor.nextTick$1(() => {
          state.points = canUesPoint.value;
        });
      }
      if (canUesPoint.value == 0 || canUesPoint.value < 0) {
        state.disabled = true;
      }
      if (canUesPoint.value > 0) {
        state.disabled = false;
      }
    });
    const onConfirm = () => {
      emits("confirm", state.points);
    };
    return (_ctx, _cache) => {
      return {
        a: state.disabled,
        b: state.points,
        c: common_vendor.o(common_vendor.m(($event) => state.points = $event.detail.value, {
          number: true
        })),
        d: common_vendor.t(__props.currentMemberPoints),
        e: common_vendor.t(currentOrderTotalPrice.value),
        f: common_vendor.t(canUesPoint.value),
        g: common_vendor.o(($event) => {
          state.points = 0;
          emits("confirm", state.points);
        }),
        h: common_vendor.o(onConfirm),
        i: common_vendor.o(($event) => emits("close")),
        j: common_vendor.p({
          show: __props.show,
          type: "bottom",
          round: "10",
          showClose: true,
          backgroundColor: "#ffffff"
        })
      };
    };
  }
};
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-8dbeaa2a"], ["__file", "D:/zx/mall-front-app/sheep/components/s-points-pop/s-points-pop.vue"]]);
wx.createComponent(Component);
