You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
27 KiB
2 lines
27 KiB
11 months ago
|
import{h as e}from"./color.813a9497.js";import{o as t,c as o,w as s,a as l,j as a,n as i,l as n,f as r,i as u,I as c,r as d,t as p,u as m,e as g,v as h,b as f,F as y,d as b,g as k,k as C,S}from"./index-ae8bbb19.js";import{A as N}from"./ActiveStatus.281bae5f.js";import{_ as T}from"./_plugin-vue_export-helper.1b428a4d.js";const I={name:"NumberBox",emits:["update:modelValue","input","change","blur","plus","minus"],props:{value:{type:Number,default:1},modelValue:{type:Number,default:1},bgColor:{type:String,default:"#FFFFFF"},min:{type:Number,default:0},max:{type:Number,default:99999},step:{type:Number,default:1},stepFirst:{type:Number,default:0},stepStrictly:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},size:{type:[Number,String],default:26},color:{type:String,default:"#323233"},inputWidth:{type:[Number,String],default:80},inputHeight:{type:[Number,String],default:50},index:{type:[Number,String],default:""},disabledInput:{type:Boolean,default:!1},cursorSpacing:{type:[Number,String],default:100},longPress:{type:Boolean,default:!0},pressTime:{type:[Number,String],default:250},positiveInteger:{type:Boolean,default:!0}},watch:{valueCom(e,t){this.changeFromInner||(this.inputVal=e,this.$nextTick((function(){this.changeFromInner=!1})))},inputVal(e,t){if(""==e)return;let o=0;o=this.isNumber(e)&&e>=this.min&&e<=this.max?e:t,this.positiveInteger&&(e<0||-1!==String(e).indexOf("."))&&(o=t,this.$nextTick((()=>{this.inputVal=t}))),this.handleChange(o,"change")},min(e){void 0!==e&&""!=e&&this.valueCom<e&&(this.$emit("input",e),this.$emit("update:modelValue",e))},max(e){void 0!==e&&""!=e&&this.valueCom>e&&(this.$emit("input",e),this.$emit("update:modelValue",e))}},data:()=>({inputVal:1,timer:null,changeFromInner:!1,innerChangeTimer:null,showInput:!1}),created(){this.inputVal=Number(this.valueCom)},computed:{valueCom(){return this.modelValue},getCursorSpacing(){return Number(uni.upx2px(this.cursorSpacing))}},methods:{emptyClick(){},btnTouchStart(e){this[e](),this.longPress&&(clearInterval(this.timer),this.timer=null,this.timer=setInterval((()=>{this[e]()}),this.pressTime))},clearTimer(){this.$nextTick((()=>{clearInterval(this.timer),this.timer=null}))},minus(){this.computeVal("minus")},plus(){this.computeVal("plus")},calcPlus(e,t){let o,s,l;try{s=e.toString().split(".")[1].length}catch(a){s=0}try{l=t.toString().split(".")[1].length}catch(a){l=0}return o=Math.pow(10,Math.max(s,l)),((e*o+t*o)/o).toFixed(s>=l?s:l)},calcMinus(e,t){let o,s,l;try{s=e.toString().split(".")[1].length}catch(a){s=0}try{l=t.toString().split(".")[1].length}catch(a){l=0}return o=Math.pow(10,Math.max(s,l)),((e*o-t*o)/o).toFixed(s>=l?s:l)},computeVal(e){if(uni.hideKeyboard(),this.disabled)return;let t=0;if("minus"===e?t=this.stepFirst>0&&this.inputVal==this.stepFirst?this.min:this.calcMinus(this.inputVal,this.step):"plus"===e&&(t=this.stepFirst>0&&this.inputVal<this.stepFirst?this.stepFirst:this.calcPlus(this.inputVal,this.step)),this.stepStrictly){let e=t%this.step;e>0&&(t-=e)}t>this.max?t=this.max:t<this.min&&(t=this.min),this.inputVal=t,this.handleChange(t,e)},onBlur(e){let t=0,o=e.detail.value;if(/(^\d+$)/.test(o)&&0!=o[0]||(t=this.min),t=+o,this.stepFirst>0&&this.inputVal<this.stepFirst&&this.inputVal>0&&(t=this.stepFirst),this.stepStrictly){let e=t%this.step;e>0&&(t-=e)}t>this.max?t=this.max:t<this.min&&(t=this.min),this.$nextTick((()=>{this.inputVal=t})),this.handleChange(t,"blur")},handleChange(e,t){this.disabled||(this.innerChangeTimer&&(clearTimeout(this.innerChangeTimer),this.innerChangeTimer=null),this.changeFromInner=!0,this.innerChangeTimer=setTimeout((()=>{this.changeFromInner=!1}),150),this.$emit("input",Number(e)),this.$emit("update:modelValue",Number(e)),this.$emit(t,{value:Number(e),index:this.index}))},isNumber:e=>/^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(e)}};var x,_={};const v=T({components:{GoodsSkuPopup:T({name:"GoodsSkuPopup",components:{NumberBox:T(I,[["render",function(e,d,p,m,g,h){const f=u,y=c;return t(),o(f,{class:"number-box"},{default:s((()=>[l(f,{class:a(["u-icon-minus",{"u-icon-disabled":p.disabled||g.inputVal<=p.m
|