vue-license-plate
Version:
1 lines • 7.8 kB
JavaScript
(function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports["licensePlate"]=e():t["licensePlate"]=e()})("undefined"!==typeof self?self:this,(function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s="fb15")}({6961:function(t,e,i){},8875:function(t,e,i){var n,r,o;(function(i,s){r=[],n=s,o="function"===typeof n?n.apply(e,r):n,void 0===o||(t.exports=o)})("undefined"!==typeof self&&self,(function(){function t(){var e=Object.getOwnPropertyDescriptor(document,"currentScript");if(!e&&"currentScript"in document&&document.currentScript)return document.currentScript;if(e&&e.get!==t&&document.currentScript)return document.currentScript;try{throw new Error}catch(f){var i,n,r,o=/.*at [^(]*\((.*):(.+):(.+)\)$/gi,s=/@([^@]*):(\d+):(\d+)\s*$/gi,a=o.exec(f.stack)||s.exec(f.stack),c=a&&a[1]||!1,u=a&&a[2]||!1,l=document.location.href.replace(document.location.hash,""),d=document.getElementsByTagName("script");c===l&&(i=document.documentElement.outerHTML,n=new RegExp("(?:[^\\n]+?\\n){0,"+(u-2)+"}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*","i"),r=i.replace(n,"$1").trim());for(var p=0;p<d.length;p++){if("interactive"===d[p].readyState)return d[p];if(d[p].src===c)return d[p];if(c===l&&d[p].innerHTML&&d[p].innerHTML.trim()===r)return d[p]}return null}}return t}))},"890f":function(t,e,i){"use strict";i("ebf3")},ebf3:function(t,e,i){},fb15:function(t,e,i){"use strict";if(i.r(e),"undefined"!==typeof window){var n=window.document.currentScript,r=i("8875");n=r(),"currentScript"in document||Object.defineProperty(document,"currentScript",{get:r});var o=n&&n.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);o&&(i.p=o[1])}var s=function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("div",{staticClass:"license-plate_container"},[i("div",{on:{click:t.onSlotClick}},[t._t("default",[i("div",{staticClass:"input_container"},t._l(t.licensePlateLength,(function(e,n){return i("div",{key:e+"_"+t.inputValue[n],staticClass:"input_box",class:t.activeIndex==n?"active":"",style:{borderWidth:t.borderWidth+"px",borderRadius:t.borderRadius+"px",borderColor:""+(t.activeIndex==n?t.borderActiveColor:t.borderColor)},on:{click:function(e){return e.stopPropagation(),t.inputClick(n)}}},[t.inputValue[n]?i("div",{staticClass:"button",style:{borderRadius:t.borderRadius+"px",fontSize:t.fontSize+"px",color:t.fontColor}},[t._v(t._s(t.inputValue[n]))]):t._e()])})),0)])],2),i("transition",{attrs:{name:"keyboard"}},[t.visible?i("div",{staticClass:"keyboard_container"},[i("div",{staticClass:"keyboard_header",on:{click:function(e){return e.stopPropagation(),t.visibleClick(e)}}},[i("i",{staticClass:"iconfont icon-jianpan"})]),i("div",{staticClass:"keyboard_body"},[0==t.activeIndex?i("div",{staticClass:"province_list"},t._l(t.provinceList,(function(e){return i("div",{key:e,staticClass:"key_wrapper",on:{click:function(i){return t.btnClick(e)}}},[i("div",{staticClass:"button"},[t._v(" "+t._s(e)+" ")])])})),0):t._e(),0!=t.activeIndex?i("div",{staticClass:"number_list"},t._l(t.numberList,(function(e,n){return i("div",{key:e,staticClass:"numer_wapper",on:{click:function(i){return t.btnClick(e,1==t.activeIndex)}}},[i("div",{staticClass:"button",class:1==t.activeIndex&&n<10?"disabled":""},[t._v(" "+t._s(e)+" ")])])})),0):t._e(),0!=t.activeIndex?i("div",{staticClass:"number_list"},[t._l(t.letterList,(function(e){return i("div",{key:e,staticClass:"numer_wapper",on:{click:function(i){return t.btnClick(e,"O"==e&&t.activeIndex>1)}}},[i("div",{staticClass:"button",class:"O"==e&&t.activeIndex>1?"disabled":""},[t._v(" "+t._s(e)+" ")])])})),i("div",{staticClass:"numer_wapper delete",on:{click:t.delClick}},[i("div",{staticClass:"button img"},[i("i",{staticClass:"iconfont icon-backspace"})])])],2):t._e()])]):t._e()])],1)},a=[];i("6961");const c=/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳使领]$/;var u={name:"LicensePlate",props:{value:String,autoShow:{type:Boolean,default:!1},borderColor:{type:String,default:"#79aef3"},borderActiveColor:{type:String,default:"#330aec"},borderRadius:{type:Number,default:6},borderWidth:{type:Number,default:1},fontColor:{type:String,default:"#333333"},fontSize:{type:Number,default:16}},components:{},model:{prop:"value",event:"update"},data(){return{licensePlateLength:8,provinceList:["京","津","渝","沪","冀","晋","辽","吉","黑","苏","浙","皖","闽","赣","鲁","豫","鄂","湘","粤","琼","川","贵","云","陕","甘","青","蒙","桂","宁","新","藏","临"],numberList:[0,1,2,3,4,5,6,7,8,9,"警"],letterList:["Q","W","E","R","T","Y","U","O","P","港","澳","A","S","D","F","G","H","J","K","L","挂","学","Z","X","C","V","B","N","M","领"],activeIndex:-1,inputValue:["","","","","","","",""],visible:!1}},computed:{licensePlate(){return this.value}},watch:{value(){this.initLicensePlate()}},async created(){},async mounted(){this.initLicensePlate(),this.autoShow&&(this.activeIndex=0,this.visible=!0)},methods:{initLicensePlate(){this.value&&c.test(this.value)&&(this.inputValue=this.value.split(""))},onSlotClick(){let t=this.inputValue.filter(t=>t).length;this.activeIndex=0==t?0:t-1,this.visible||(this.visible=!0)},inputClick(t){this.activeIndex=t,this.visible||(this.visible=!0)},btnClick(t,e){if(e)return!1;this.$set(this.inputValue,this.activeIndex,""+t),this.activeIndex++,this.activeIndex>7&&(this.visible=!1),this.change()},delClick(){this.inputValue[this.activeIndex]?this.$set(this.inputValue,this.activeIndex,""):(this.$set(this.inputValue,this.activeIndex-1,""),this.activeIndex--),this.change()},visibleClick(){this.visible=!1},change(){let t=this.inputValue.join(""),e=c.test(t);this.$emit("change",{array:this.inputValue.filter(t=>""!==t),value:t,pass:e}),this.$emit("update",t)}},filters:{}},l=u;i("890f");function d(t,e,i,n,r,o,s,a){var c,u="function"===typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=i,u._compiled=!0),n&&(u.functional=!0),o&&(u._scopeId="data-v-"+o),s?(c=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"===typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),r&&r.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(s)},u._ssrRegister=c):r&&(c=a?function(){r.call(this,(u.functional?this.parent:this).$root.$options.shadowRoot)}:r),c)if(u.functional){u._injectStyles=c;var l=u.render;u.render=function(t,e){return c.call(e),l(t,e)}}else{var d=u.beforeCreate;u.beforeCreate=d?[].concat(d,c):[c]}return{exports:t,options:u}}var p=d(l,s,a,!1,null,"650f7a5e",null),f=p.exports;f.install=function(t){t.component(f.name,f)};var v=f;const h=[v],b=function(t){b.installed||h.map(e=>t.component(e.name,e))};"undefined"!==typeof window&&window.Vue&&b(window.Vue);var m={install:b,LicensePlate:v};e["default"]=m}})}));