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.
yanzong/public/assets/index.0d19d98b.js

2 lines
22 KiB

11 months ago
import{o as e,c as t,w as o,a as s,k as l,n as a,m as i,f as n,i as r,I as u,r as c,t as d,v as m,e as p,x as h,b as f,F as g,d as y,g as b,l as C,j as k}from"./index-4ddb689d.js";import{_ as S}from"./_plugin-vue_export-helper.1b428a4d.js";const N={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 T,I={};const x=S({name:"GoodsSkuPopup",components:{NumberBox:S(N,[["render",function(c,d,m,p,h,f){const g=r,y=u;return e(),t(g,{class:"number-box"},{default:o((()=>[s(g,{class:l(["u-icon-minus",{"u-icon-disabled":m.disabled||h.inputVal<=m.min}]),style:a({background:m.bgColor,height:m.inputHeight+"rpx",color:m.color,fontSize:m.size+"rpx",minHeight:"1