1 line
8.6 KiB
Plaintext
1 line
8.6 KiB
Plaintext
{"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 if (value < this.min * scale) {\r\n return\r\n }\r\n if (value > this.max * scale) {\r\n value = this.max * scale\r\n }\r\n }\r\n\r\n if (type === 'plus') {\r\n value += step\r\n if (value > this.max * scale) {\r\n return\r\n }\r\n if (value < this.min * scale) {\r\n value = this.min * scale\r\n }\r\n }\r\n\r\n this.inputValue = (value / scale).toFixed(String(scale).length - 1)\r\n this.$emit('change', +this.inputValue)\r\n // TODO vue2 兼容\r\n this.$emit('input', +this.inputValue)\r\n // TODO vue3 兼容\r\n this.$emit('update:modelValue', +this.inputValue)\r\n },\r\n _getDecimalScale() {\r\n let scale = 1\r\n // 浮点型\r\n if (~~this.step !== this.step) {\r\n scale = Math.pow(10, String(this.step).split('.')[1].length)\r\n }\r\n return scale\r\n },\r\n _onBlur(event) {\r\n this.$emit('blur', event)\r\n let value = event.detail.value\r\n if (!value) {\r\n // this.inputValue = 0;\r\n return\r\n }\r\n value = +value\r\n if (value > this.max) {\r\n value = this.max\r\n } else if (value < this.min) {\r\n value = this.min\r\n }\r\n const scale = this._getDecimalScale()\r\n this.inputValue = value.toFixed(String(scale).length - 1)\r\n this.$emit('change', +this.inputValue)\r\n this.$emit('input', +this.inputValue)\r\n },\r\n _onFocus(event) {\r\n this.$emit('focus', event)\r\n },\r\n },\r\n}\r\n</script>\r\n<style lang=\"scss\" scoped>\r\n \r\n.uni-numbox .uni-numbox--disabled {\r\n color: #c0c0c0 !important;\r\n /* #ifdef H5 */\r\n cursor: not-allowed;\r\n /* #endif */\r\n}\r\n\r\n.uni-numbox {\r\n /* #ifndef APP-NVUE */\r\n display: flex;\r\n /* #endif */\r\n align-items: center;\r\n}\r\n\r\n.uni-numbox__value {\r\n width: 74rpx;\r\n font-size: 30rpx;\r\n text-align: center;\r\n}\r\n\r\n.cicon-move-round {\r\n font-size: 44rpx;\r\n color: var(--ui-BG-Main);\r\n}\r\n\r\n.cicon-add-round {\r\n font-size: 44rpx;\r\n color: var(--ui-BG-Main);\r\n}\r\n\r\n.groupon-btn {\r\n color: #ff6000;\r\n}\r\n\r\n.seckill-btn {\r\n color: #ff5854;\r\n}\r\n</style>\r\n","import Component from 'D:/App/Work/addr/acdr-ui/src/sheep/ui/su-number-box/su-number-box.vue'\nwx.createComponent(Component)"],"names":[],"mappings":";;AAyDA,MAAK,YAAU;AAAA,EACb,MAAM;AAAA,EACN,OAAO,CAAC,UAAU,SAAS,qBAAqB,QAAQ,OAAO;AAAA,EAC/D,OAAO;AAAA,IACL,OAAO;AAAA,MACL,MAAM,CAAC,QAAQ,MAAM;AAAA,MACrB,SAAS;AAAA,IACV;AAAA,IACD,YAAY;AAAA,MACV,MAAM,CAAC,QAAQ,MAAM;AAAA,MACrB,SAAS;AAAA,IACV;AAAA,IACD,KAAK;AAAA,MACH,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACD,KAAK;AAAA,MACH,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACD,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACD,YAAY;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACD,OAAO;AAAA,MACL,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACD,UAAU;AAAA,MACR,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACD,UAAU;AAAA,MACR,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,EACF;AAAA,EACD,OAAO;AACL,WAAO;AAAA,MACL,YAAY;AAAA,IACd;AAAA,EACD;AAAA,EACD,OAAO;AAAA,IACL,MAAM,KAAK;AACT,WAAK,aAAa,CAAC;AAAA,IACpB;AAAA,IACD,WAAW,KAAK;AACd,WAAK,aAAa,CAAC;AAAA,IACpB;AAAA,EACF;AAAA,EACD,UAAU;AACR,QAAI,KAAK,UAAU,GAAG;AACpB,WAAK,aAAa,CAAC,KAAK;AAAA,IAC1B;AACA,QAAI,KAAK,eAAe,GAAG;AACzB,WAAK,aAAa,CAAC,KAAK;AAAA,IAC1B;AAAA,EACD;AAAA,EACD,SAAS;AAAA,IACP,WAAW,MAAM;AACf,UAAI,KAAK,UAAU;AACjB;AAAA,MACF;AACA,YA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