acdr-ui/dist/dev/mp-weixin/sheep/ui/su-number-box/su-number-box.js.map

1 line
8.6 KiB
Plaintext
Raw Normal View History

2024-09-19 07:20:14 +08:00
{"version":3,"file":"su-number-box.js","sources":["../../../../../../src/sheep/ui/su-number-box/su-number-box.vue","../../../../../../uniComponent:/RDovQXBwL1dvcmsvYWRkci9hY2RyLXVpL3NyYy9zaGVlcC91aS9zdS1udW1iZXItYm94L3N1LW51bWJlci1ib3gudnVl"],"sourcesContent":["<template>\r\n <view class=\"uni-numbox\">\r\n <!-- <view @click=\"_calcValue('minus')\" class=\"uni-numbox__minus uni-numbox-btns\" :style=\"{ background }\"> -->\r\n <!-- <text class=\"uni-numbox--text\" :class=\"{ 'uni-numbox--disabled': inputValue <= min || disabled }\"\r\n\t\t\t\t:style=\"{ color }\">\r\n\t\t\t\t-\r\n\t\t\t</text> -->\r\n <text\r\n class=\"cicon-move-round\"\r\n :class=\"{\r\n 'uni-numbox--disabled': inputValue <= min || disabled,\r\n 'groupon-btn': activity === 'groupon',\r\n 'seckill-btn': activity === 'seckill',\r\n }\"\r\n @click=\"_calcValue('minus')\"\r\n ></text>\r\n <!-- </view> -->\r\n <input\r\n :disabled=\"disabled\"\r\n @focus=\"_onFocus\"\r\n @blur=\"_onBlur\"\r\n class=\"uni-numbox__value\"\r\n type=\"number\"\r\n v-model=\"inputValue\"\r\n :style=\"{ color }\"\r\n />\r\n <!-- <view @click=\"_calcValue('plus')\" class=\"uni-numbox__plus uni-numbox-btns\">\r\n\t\t\t<text class=\"uni-numbox--text\" :class=\"{ 'uni-numbox--disabled': inputValue >= max || disabled }\">+</text>\r\n\t\t</view> -->\r\n <text\r\n class=\"cicon-add-round\"\r\n :class=\"{\r\n 'uni-numbox--disabled': inputValue >= max || disabled,\r\n 'groupon-btn': activity === 'groupon',\r\n 'seckill-btn': activity === 'seckill',\r\n }\"\r\n @click=\"_calcValue('plus')\"\r\n ></text>\r\n </view>\r\n</template>\r\n<script>\r\n/**\r\n * NumberBox 数字输入框\r\n * @description 带加减按钮的数字输入框\r\n * @tutorial https://ext.dcloud.net.cn/plugin?id=31\r\n * @property {Number} value 输入框当前值\r\n * @property {Number} min 最小值\r\n * @property {Number} max 最大值\r\n * @property {Number} step 每次点击改变的间隔大小\r\n * @property {String} background 背景色\r\n * @property {String} color 字体颜色(前景色)\r\n * @property {Boolean} disabled = [true|false] 是否为禁用状态\r\n * @event {Function} change 输入框值改变时触发的事件,参数为输入框当前的 value\r\n * @event {Function} focus 输入框聚焦时触发的事件,参数为 event 对象\r\n * @event {Function} blur 输入框失焦时触发的事件,参数为 event 对象\r\n */\r\n\r\nexport default {\r\n name: 'UniNumberBox',\r\n emits: ['change', 'input', 'update:modelValue', 'blur', 'focus'],\r\n props: {\r\n value: {\r\n type: [Number, String],\r\n default: 1,\r\n },\r\n modelValue: {\r\n type: [Number, String],\r\n default: 1,\r\n },\r\n min: {\r\n type: Number,\r\n default: 0,\r\n },\r\n max: {\r\n type: Number,\r\n default: 100,\r\n },\r\n step: {\r\n type: Number,\r\n default: 1,\r\n },\r\n background: {\r\n type: String,\r\n default: '#f5f5f5',\r\n },\r\n color: {\r\n type: String,\r\n default: '#333',\r\n },\r\n disabled: {\r\n type: Boolean,\r\n default: false,\r\n },\r\n activity: {\r\n type: String,\r\n default: 'none',\r\n },\r\n },\r\n data() {\r\n return {\r\n inputValue: 0,\r\n }\r\n },\r\n watch: {\r\n value(val) {\r\n this.inputValue = +val\r\n },\r\n modelValue(val) {\r\n this.inputValue = +val\r\n },\r\n },\r\n created() {\r\n if (this.value === 1) {\r\n this.inputValue = +this.modelValue\r\n }\r\n if (this.modelValue === 1) {\r\n this.inputValue = +this.value\r\n }\r\n },\r\n methods: {\r\n _calcValue(type) {\r\n if (this.disabled) {\r\n return\r\n }\r\n const scale = this._getDecimalScale()\r\n let value = this.inputValue * scale\r\n const step = this.step * scale\r\n if (type === 'minus') {\r\n value -= step\r\n