123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
-
- export function isMoney(money) {
- var reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/
- if (reg.test(money)) {
- return true
- } else {
- return false
- }
- }
-
- export function checkPhone(c2543fff3bfa6f144c2f06a7de6cd10c0b650cae) {
- var reg = /^1(3|4|5|6|7|8|9)\d{9}$/
- if (reg.test(c2543fff3bfa6f144c2f06a7de6cd10c0b650cae)) {
- return true
- } else {
- return false
- }
- }
- export const Debounce = (fn, t) => {
- const delay = t || 500
- let timer
- return function() {
- const args = arguments
- if (timer) {
- clearTimeout(timer)
- }
- timer = setTimeout(() => {
- timer = null
- fn.apply(this, args)
- }, delay)
- }
- }
- export const Throttle = (fn, t) => {
- let last
- let timer
- const interval = t || 500
- return function() {
- const args = arguments
- const now = +new Date()
- if (last && now - last < interval) {
- clearTimeout(timer)
- timer = setTimeout(() => {
- last = now
- fn.apply(this, args)
- }, interval)
- } else {
- last = now
- fn.apply(this, args)
- }
- }
- }
|