Global

Methods

dateFormat1(value) → {*}

日期格式化 时间规则: 今天显示:xx:xx 昨天显示:昨天 xx:xx 一周内显示:星期x xx:xx 一年内显示:xx月xx日 xx:xx 更早日期显示:xx年xx月xx日 xx:xx
Parameters:
Name Type Description
value * 时间戳,单位s
Source:
Returns:
格式化后的日期
Type
*

dateFormat2(dateTimeStamp) → {*}

日期格式化 时间规则: 小于一分钟显示:刚刚 1分钟-60分钟内显示:xx分钟前 大于60分钟显示:xx小时前 昨天显示:昨天 xx:xx 更早日期显示:xx-xx-xx xx:xx
Parameters:
Name Type Description
dateTimeStamp * 时间戳,单位s
Source:
Returns:
格式化后的日期
Type
*

elDateFormat(time, type) → {number|string|null}

获取饿了么框架时间选择器时间戳
Parameters:
Name Type Default Description
time * 时间
type * 0 类型 默认值 0 0 开始时间 1 结束时间
Source:
Returns:
时间戳
Type
number | string | null

exportXls(data, name, callBack)

删除对象里面value值为null的键值对
Parameters:
Name Type Default Description
data * 接口返回的blob数据
name * jtools excel名称
callBack * 导出成功/失败回调 回调返回{type:fail/success} fail情况下 返回{ type: "fail", code, msg }
Source:

getBrowserModel() → {string}

获取浏览器类型和版本
Source:
Returns:
Type
string
Example
getBrowserModel() => "Chrome:70.0.3538.102"

getDefaultHeader(userId)

获取默认头像
Parameters:
Name Type Description
userId *
Source:

getDeviceModel() → {string}

获取手机操作系统类型
Source:
Returns:
ios android
Type
string

getImgBase64(url) → {Promise}

获取图片的base64 url
Parameters:
Name Type Description
url string 图片url
Source:
Returns:
图片base64信息
Type
Promise

getThumbnails(opts) → {string}

图像处理获取缩略图
Parameters:
Name Type Description
opts Object 参数对象
Properties
Name Type Description
src string 处理源路径
type string 处理类型 2:图片 4:视频
payload string 负载参数: https://help.aliyun.com/document_detail/44688.html?spm=a2c4g.11186623.6.1148.4d7d176cZS0ozx
ifSelf boolean 返回源路径
ossdomain string 图片对应的oss域名
Source:
Returns:
处理后的图片路径
Type
string

handleEmoji(str, type) → {string}

处理emoji,用于把用utf16编码的字符转换成实体字符
Parameters:
Name Type Default Description
str string 需要编译/解析的字符串
type string encode encode 编译 decode 转义
Source:
Returns:
编译/解析后的字符串
Type
string
Example
handleEmoji("😃", "encode") => "😃"
handleEmoji("😊", "decode") => "😊"

handleParam(obj) → {object}

删除对象里面value值为null的键值对
Parameters:
Name Type Description
obj * 需要处理的参数
Source:
Returns:
返回结果
Type
object

handleText(str, type) → {string}

处理文本,客户端无法识别h5的br标签和空格符,因此需要处理br标签为\n和空格符为 ''
Parameters:
Name Type Default Description
str string 需要编译/转义的字符串
type string encode encode 编译 decode 转义
Source:
Returns:
编译/转义后的字符串
Type
string
Example
handleText("<br>&nbsp;&lt;&gt;", "encode") => "\n <>"
handleText("\n <>", "decode") => "<br>&nbsp;&lt;&gt;"

isEmoji(value) → {boolean}

检查是否是emoji表情
Parameters:
Name Type Description
value * 正则校验变量
Source:
Returns:
正则校验结果 true: 是emoji表情 false: 不是emoji表情
Type
boolean

isIDCard(idcard) → {boolean}

校验十八位身份证号码
Parameters:
Name Type Description
idcard * 身份证号码
Source:
Returns:
验证结果true/false
Type
boolean

isMobile(value) → {boolean}

检查是否为正确手机号 1开头11位数字
Parameters:
Name Type Description
value * 正则校验变量
Source:
Returns:
正则校验结果
Type
boolean

isSpecialChar(value) → {boolean}

检查是否为特殊字符
Parameters:
Name Type Description
value string 正则校验的变量
Author:
  • pengyong
Source:
Returns:
正则校验结果 true: 是特殊字符 false: 不是特殊字符
Type
boolean