Constants
- isString ⇒
boolean 是不是String
- isNumber ⇒
boolean 是不是Number
- isDate ⇒
boolean 是不是Date
- isRegExp ⇒
boolean 是不是RegExp
- isArray ⇒
boolean 是不是Array
- isSymbol ⇒
boolean 是不是Symbol
- isFunction ⇒
boolean 是不是Function
- now ⇒
number 获取当前时间戳
- delay
延迟函数
Functions
- clone(target) ⇒
克隆传入的参数
- formatSecondToTime(time) ⇒
object 将秒转换成时间
- formatDate(fmt, date) ⇒
string 格式化时间
- calcAge(birthday) ⇒
object 计算年龄, 以365天为一年
- formatPrice(price, length) ⇒
string 金额格式化
- formatNumberToChina(money, needI, needY) ⇒
阿拉伯数字转换成大写汉字
- formatBankNumber(value) ⇒
将银行卡号格式化
- randomNumber(min, max) ⇒
number 返回一个区间内的随机数
- isObject(obj) ⇒
boolean 是否是对象
- isNull(obj) ⇒
boolean 是不是null
- isUndefined(obj) ⇒
boolean 是不是undefined
- isBoolean(obj) ⇒
boolean 是不是Boolean
- has(obj, key) ⇒
boolean 判断当前对象上是否有该属性
- debounce(func, wait, immediate) ⇒
object 防抖函数
- throttle(func, wait, opts) ⇒
object 节流函数
- isWeChat() ⇒
boolean 是不是微信
- isAndroid() ⇒
boolean 是不是安卓
- isIOS() ⇒
boolean 是不是苹果
- isMobile() ⇒
boolean 是不是移动端
- checkBank(number) ⇒
boolean 验证银行卡号是否正确
- checkEmail(email) ⇒
boolean 验证邮箱是否正确
- checkId(id) ⇒
string|object 检验身份证是否正确
- checkPhone(phone) ⇒
boolean 检验手机号是否正确
- weChatShare(wx, getSign, list, params)
微信分享 该方法需要自行安装依赖 weixin-js-sdk
isString ⇒ boolean
是不是String
Kind: global constant
| Param | Type |
|---|---|
| obj | \* |
isNumber ⇒ boolean
是不是Number
Kind: global constant
| Param | Type |
|---|---|
| obj | \* |
isDate ⇒ boolean
是不是Date
Kind: global constant
| Param | Type |
|---|---|
| obj | \* |
isRegExp ⇒ boolean
是不是RegExp
Kind: global constant
| Param | Type |
|---|---|
| obj | \* |
isArray ⇒ boolean
是不是Array
Kind: global constant
| Param | Type |
|---|---|
| obj | \* |
isSymbol ⇒ boolean
是不是Symbol
Kind: global constant
| Param | Type |
|---|---|
| obj | \* |
isFunction ⇒ boolean
是不是Function
Kind: global constant
| Param | Type |
|---|---|
| obj | \* |
now ⇒ number
获取当前时间戳
delay
延迟函数
Kind: global constant
| Param | Type | Description |
|---|---|---|
| func | function |
需要延迟执行的函数 |
| wait | number |
等待时间 ms |
| args | boolean |
延时函数的参数,可选 |
clone(target) ⇒
克隆传入的参数
Kind: global function
Returns: 克隆的值
| Param | Type |
|---|---|
| target | \* |
formatSecondToTime(time) ⇒ object
将秒转换成时间
Kind: global function
Returns: object - {天 days,小时 hours,分 mins,秒 seconds}
| Param | Type | Description |
|---|---|---|
| time | number |
传入剩余秒数时间 |
formatDate(fmt, date) ⇒ string
格式化时间
Kind: global function
Returns: string - 格式化时间字符串
| Param | Type | Description | |
|---|---|---|---|
| fmt | string |
格式化字符串 ‘yyyy-MM-dd hh:mm:ss q(季度) S(毫秒)’ | |
| date | date | number |
日期时间对象 | 时间戳 |
calcAge(birthday) ⇒ object
计算年龄, 以365天为一年
Kind: global function
Returns: object - 当前年龄 age, 年龄单位 unit
| Param | Type | Description |
|---|---|---|
| birthday | string | date |
出生日期 格式化的时间字符串(yyyy-MM-dd)或时间对象 |
formatPrice(price, length) ⇒ string
金额格式化
Kind: global function
Returns: string - 格式化好的字符串
eg. parseFormatNum(“123456”,1); 结果为:123,456.0
| Param | Type | Description |
|---|---|---|
| price | number | string |
金额 |
| length | number |
保留小数位 max = 4, 最多保留4位小数位 |
formatNumberToChina(money, needI, needY) ⇒
阿拉伯数字转换成大写汉字
Kind: global function
Returns: 大写的整数
| Param | Type | Description |
|---|---|---|
| money | number |
正整数 |
| needI | boolean |
是否需要 ‘整’ 字分隔 |
| needY | boolean |
是否需要 ‘圆’ |
formatBankNumber(value) ⇒
将银行卡号格式化
Kind: global function
Returns: 格式化的银行卡号码
| Param | Type | Description |
|---|---|---|
| value | string |
银行卡号码 |
randomNumber(min, max) ⇒ number
返回一个区间内的随机数
Kind: global function
Returns: number - 随机整数
| Param | Type | Description |
|---|---|---|
| min | number |
起始值 |
| max | number |
结束值 |
isObject(obj) ⇒ boolean
是否是对象
Kind: global function
| Param | Type |
|---|---|
| obj | \* |
isNull(obj) ⇒ boolean
是不是null
Kind: global function
| Param | Type |
|---|---|
| obj | \* |
isUndefined(obj) ⇒ boolean
是不是undefined
Kind: global function
| Param | Type |
|---|---|
| obj | \* |
isBoolean(obj) ⇒ boolean
是不是Boolean
Kind: global function
| Param | Type |
|---|---|
| obj | \* |
has(obj, key) ⇒ boolean
判断当前对象上是否有该属性
Kind: global function
| Param | Type |
|---|---|
| obj | object |
| key | string |
debounce(func, wait, immediate) ⇒ object
防抖函数
Kind: global function
Returns: object - 返回一个debounce的执行句柄,拥有cancel方法,执行可取消防抖
| Param | Type | Description |
|---|---|---|
| func | function |
执行函数 |
| wait | number |
等待时间 ms |
| immediate | boolean |
是否立即触发,可选,默认false |
throttle(func, wait, opts) ⇒ object
节流函数
Kind: global function
Returns: object - 返回一个throttle的执行句柄,拥有cancel方法,执行可取消节流
| Param | Type | Description |
|---|---|---|
| func | function |
执行函数 |
| wait | number |
触发间隔 ms |
| opts | object |
{first: boolean, last: boolean} 可选参数, first控制第一次是否触发,默认true;last控制最后一次是否执行,默认为true |
isWeChat() ⇒ boolean
是不是微信
isAndroid() ⇒ boolean
是不是安卓
isIOS() ⇒ boolean
是不是苹果
isMobile() ⇒ boolean
是不是移动端
checkBank(number) ⇒ boolean
验证银行卡号是否正确
Kind: global function
| Param | Type | Description |
|---|---|---|
| number | string |
银行卡号 |
checkEmail(email) ⇒ boolean
验证邮箱是否正确
Kind: global function
| Param | Type | Description |
|---|---|---|
email |
邮箱 |
checkId(id) ⇒ string | object
检验身份证是否正确
Kind: global function
Returns: string | object - 错误提示| [地区,生日,年龄,性别(1男,2女)]
| Param | Type | Description |
|---|---|---|
| id | string |
身份证号码 |
checkPhone(phone) ⇒ boolean
检验手机号是否正确
Kind: global function
| Param | Type | Description |
|---|---|---|
| phone | string |
手机号 |
weChatShare(wx, getSign, list, params)
微信分享 该方法需要自行安装依赖 weixin-js-sdk
Kind: global function
| Param | Type | Description |
|---|---|---|
| wx | object |
import wx from ‘weixin-js-sdk’ 传入这个 wx |
| getSign | function |
获取相关参数的方法或函数 需要返回的对象包含以下几个字段{appId, timestamp, signature, nonceStr}, 如果返回 false 则会中断 |
| list | array |
接口权限列表 |
| params | object |
微信分享参数 {title, desc, imgUrl, link, success} |