| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 | "use strict";const common_vendor = require("../../../common/vendor.js");const _sfc_main = {  name: "UniNumberBox",  emits: ["change", "input", "update:modelValue", "blur", "focus"],  props: {    value: {      type: [Number, String],      default: 1    },    modelValue: {      type: [Number, String],      default: 1    },    min: {      type: Number,      default: 0    },    max: {      type: Number,      default: 100    },    step: {      type: Number,      default: 1    },    background: {      type: String,      default: "#f5f5f5"    },    color: {      type: String,      default: "#333"    },    disabled: {      type: Boolean,      default: false    },    activity: {      type: String,      default: "none"    }  },  data() {    return {      inputValue: 0    };  },  watch: {    value(val) {      this.inputValue = +val;    },    modelValue(val) {      this.inputValue = +val;    }  },  created() {    if (this.value === 1) {      this.inputValue = +this.modelValue;    }    if (this.modelValue === 1) {      this.inputValue = +this.value;    }  },  methods: {    _calcValue(type) {      if (this.disabled) {        return;      }      const scale = this._getDecimalScale();      let value = this.inputValue * scale;      let step = this.step * scale;      if (type === "minus") {        value -= step;        if (value < this.min * scale) {          return;        }        if (value > this.max * scale) {          value = this.max * scale;        }      }      if (type === "plus") {        value += step;        if (value > this.max * scale) {          return;        }        if (value < this.min * scale) {          value = this.min * scale;        }      }      this.inputValue = (value / scale).toFixed(String(scale).length - 1);      this.$emit("change", +this.inputValue);      this.$emit("input", +this.inputValue);      this.$emit("update:modelValue", +this.inputValue);    },    _getDecimalScale() {      let scale = 1;      if (~~this.step !== this.step) {        scale = Math.pow(10, String(this.step).split(".")[1].length);      }      return scale;    },    _onBlur(event) {      this.$emit("blur", event);      let value = event.detail.value;      if (!value) {        return;      }      value = +value;      if (value > this.max) {        value = this.max;      } else if (value < this.min) {        value = this.min;      }      const scale = this._getDecimalScale();      this.inputValue = value.toFixed(String(scale).length - 1);      this.$emit("change", +this.inputValue);      this.$emit("input", +this.inputValue);    },    _onFocus(event) {      this.$emit("focus", event);    }  }};function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {  return {    a: $data.inputValue <= $props.min || $props.disabled ? 1 : "",    b: $props.activity === "groupon" ? 1 : "",    c: $props.activity === "seckill" ? 1 : "",    d: common_vendor.o(($event) => $options._calcValue("minus")),    e: $props.disabled,    f: common_vendor.o((...args) => $options._onFocus && $options._onFocus(...args)),    g: common_vendor.o((...args) => $options._onBlur && $options._onBlur(...args)),    h: $props.color,    i: $data.inputValue,    j: common_vendor.o(($event) => $data.inputValue = $event.detail.value),    k: $data.inputValue >= $props.max || $props.disabled ? 1 : "",    l: $props.activity === "groupon" ? 1 : "",    m: $props.activity === "seckill" ? 1 : "",    n: common_vendor.o(($event) => $options._calcValue("plus"))  };}const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-5212235c"], ["__file", "/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-app/sheep/ui/su-number-box/su-number-box.vue"]]);wx.createComponent(Component);
 |