808 lines
27 KiB
Vue
808 lines
27 KiB
Vue
<template>
|
||
<ciy-header title="通用函数"></ciy-header>
|
||
<view>
|
||
<view class="ciy-card">
|
||
<view class="title">页面通用变量</view>
|
||
<view class="right"></view>
|
||
<view class="content">
|
||
<ciy-textmore maskbg="var(--bg2)">
|
||
<view>混入的常用页面变量,可直接使用。</view>
|
||
<view class="prp">opn</view>
|
||
<view class="tip">
|
||
页面传参<br />
|
||
如果有upid,自动保存。
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="prp">pagepost</view>
|
||
<view class="tip">
|
||
页面参数与搜索项整合<br />
|
||
非ref响应式。
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="prp">me</view>
|
||
<view class="tip">
|
||
用户登录后信息<br />
|
||
addtimes: 注册时间戳<br/>
|
||
icon: 头像<br/>
|
||
id: 用户ID<br/>
|
||
mobile: 手机号<br/>
|
||
name: 昵称<br/>
|
||
needpass: 是否需改密码<br/>
|
||
upid: 推荐人ID<br/>
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="prp">g</view>
|
||
<view class="tip">
|
||
本地字典数据,登录前无该数据。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="prp">init</view>
|
||
<view class="tip">
|
||
一般Ajax请求后更新,无需页面响应式定义。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="prp">jsnurl</view>
|
||
<view class="tip">
|
||
微服务集群url。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="prp">srv</view>
|
||
<view class="tip">
|
||
默认微服务集群码。<br />
|
||
默认: t
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="prp">version</view>
|
||
<view class="tip">
|
||
版本号。
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="prp">header_statusbar_height</view>
|
||
<view class="tip">
|
||
顶部系统栏高度。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="prp">header_title_height</view>
|
||
<view class="tip">
|
||
标题栏高度。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="prp">header_title_margin</view>
|
||
<view class="tip">
|
||
胶囊左右留白。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="prp">footer_safe_height</view>
|
||
<view class="tip">
|
||
底部安全高度。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="prp">meta</view>
|
||
<view class="tip">
|
||
page-meta配置项。<br />
|
||
用于暗黑模式和敬老模式。<br />
|
||
</view>
|
||
</ciy-textmore>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="ciy-card">
|
||
<view class="title">app函数库</view>
|
||
<view class="right">app.methods.*</view>
|
||
<view class="content">
|
||
<ciy-textmore maskbg="var(--bg2)">
|
||
<view>仅在app中调用</view>
|
||
<view class="fun">getpage(idx)</view>
|
||
<view class="tip">
|
||
获取当前/上页页面句柄<br />
|
||
参数: 0 当前页,1 上一页<br />
|
||
返回: 句柄 或 null<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">setuserstorage({me,storage,pnttrack})</view>
|
||
<view class="tip">
|
||
保存用户信息、字典缓存、积分埋点<br />
|
||
参数: {个人信息,字典,积分埋点}<br />
|
||
返回: {me,g}<br />
|
||
保存到localstorage: me,g,_pnttrack<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">appupdate(plat, cb)</view>
|
||
<view class="tip">
|
||
自动版本更新<br />
|
||
APP调用login.getappver<br/>
|
||
小程序调用各自函数<br/>
|
||
有新版本则下载更新后重启。<br />
|
||
参数: <br />
|
||
plat: 更新目标 all全部,app只APP<br />
|
||
cb: 可选更新的回调函数,需async,返回true更新<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">connectbt(devup, devtype, devid)</view>
|
||
<view class="tip">
|
||
连接蓝牙设备<br />
|
||
参数: 设备标识,设备类型,设备ID<br />
|
||
返回: 无<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">new CiyWebSocket(addr)</view>
|
||
<view class="tip">
|
||
websocket客户端类<br />
|
||
实现断线尝试重连<br />
|
||
初始化: addr网址<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">async app.alert(txt)</view>
|
||
<view class="tip">
|
||
系统默认的alert效果<br />
|
||
参数: 内容文本<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">async app.toast(txt, icon)</view>
|
||
<view class="tip">
|
||
系统默认的toast效果<br />
|
||
参数: 内容文本,图标<br />
|
||
</view>
|
||
</ciy-textmore>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="ciy-card">
|
||
<view class="title">app & page函数库</view>
|
||
<view class="right"></view>
|
||
<view class="content">
|
||
<view>app.xx()或this.xx()均能调用,用法相同。</view>
|
||
<ciy-textmore maskbg="var(--bg2)">
|
||
<view class="fun">async getme()</view>
|
||
<view class="tip">
|
||
返回登录后的数据。<br />
|
||
未登录返回{me:0}。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">async callfunc({srv, func, cache, cachekey, loadhide, loadtxt, data})</view>
|
||
<view class="tip">
|
||
服务端Ajax API请求,header带上token。<br />
|
||
自动保存新token,无感续期。<br />
|
||
参数: <br />
|
||
srv: 指定微服务集群代码,在jsnurl配置<br />
|
||
func: 调用函数。<br />
|
||
http开头,指向到外部位置。<br />
|
||
包含?,jsnurl本地服务器下任意位置。<br />
|
||
否则,jsnurl+jsnajax+[类名.函数名]。<br />
|
||
cache: 0不缓存 >0 超过秒数请求<br />
|
||
cachekey: 指定缓存名,一般参数区分用。默认f_[func]<br />
|
||
loadhide: true隐藏加载中显示<br />
|
||
loadtxt: 设置加载中显示文本,默认:加载中<br />
|
||
data: post数据对象<br />
|
||
返回: json<br />
|
||
返回错误: {errmsg, ...}<br />
|
||
返回成功: {code:1, ...}<br />
|
||
如果code=2, 自动拉起重新登录页面<br />
|
||
如果header带token re, 通知app刷新用户信息及字典等。<br />
|
||
系统定时调用login.restorage,保持本地与服务器数据一致。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">lang(code)</view>
|
||
<view class="tip">
|
||
多语言翻译<br />
|
||
参数: code key<br />
|
||
返回: 翻译后文本<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">uperr(type, msg)</view>
|
||
<view class="tip">
|
||
捕获错误并加入上传队列<br />
|
||
参数: 错误分类码、错误描述、附带数据<br />
|
||
系统后台定时上传,错误队列。<br />
|
||
错误数据先保存到本地,等待下次或再次进入上报,防止崩溃丢失关键错误数据。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">json_parse(str)</view>
|
||
<view class="tip">
|
||
将字符串转JSON,能过滤调试数据<br />
|
||
返回: object 或 null<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">json_string(obj)</view>
|
||
<view class="tip">
|
||
将JSON转字符串<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">getstorage(key, def)</view>
|
||
<view class="tip">
|
||
获取localstorage值,自动json反序列化<br />
|
||
返回: object 或 string 或 def<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">setstorage(key, val)</view>
|
||
<view class="tip">
|
||
写入localstorage值,自动json序列化<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">clearstorage()</view>
|
||
<view class="tip">
|
||
清空所有localstorage<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">removestorage(key)</view>
|
||
<view class="tip">
|
||
删除localstorage中一个key对<br />
|
||
</view>
|
||
</ciy-textmore>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="ciy-card">
|
||
<view class="title">page函数库</view>
|
||
<view class="right">页面功能</view>
|
||
<view class="content">
|
||
<view>跳转到、打开、拨打、动画等。</view>
|
||
<ciy-textmore maskbg="var(--bg2)">
|
||
<view class="fun">async gourl(url)</view>
|
||
<view class="tip">
|
||
跳转到其他页面。<br />
|
||
http前缀,跳转到web页面<br />
|
||
! 前缀,跳转到原型图页面,menuid|tag<br />
|
||
* 前缀,alert提示语<br />
|
||
$ 前缀,先检查登录状态再内部跳转<br />
|
||
其他,跳转内部页面,支持switchTab
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">goweb(url, name)</view>
|
||
<view class="tip">
|
||
跳转到web页面,携带token。<br />
|
||
参数: 链接、标题<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">goloc(lat, lng)</view>
|
||
<view class="tip">
|
||
跳转到地图指定位置<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">gophone(phone)</view>
|
||
<view class="tip">
|
||
拨打指定电话,调取系统电话拨打页面<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">goani(opn, cb, othcb)</view>
|
||
<view class="tip">
|
||
元素动画播放<br />
|
||
参数: {anis,init}、export回调、hide等回调<br />
|
||
anis支持string和array
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">copyboard(str)</view>
|
||
<view class="tip">
|
||
将str拷贝到剪贴板<br />
|
||
</view>
|
||
</ciy-textmore>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="ciy-card">
|
||
<view class="title">page函数库</view>
|
||
<view class="right">变量转换</view>
|
||
<view class="content">
|
||
<view>类型判断、字典换算、转码等。</view>
|
||
<ciy-textmore maskbg="var(--bg2)">
|
||
<view class="fun">isfloat0(num)</view>
|
||
<view class="tip">
|
||
判断是否为0,防止浮点数问题。<br />
|
||
尽量不要使用浮点数。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">isarray(val)</view>
|
||
<view class="tip">
|
||
变量类型是否是 object array<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">isobject(val)</view>
|
||
<view class="tip">
|
||
变量类型是否是 object object<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">islocalmedia(file)</view>
|
||
<view class="tip">
|
||
变量文件名是否是本地文件(微信)<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">isimg(file)</view>
|
||
<view class="tip">
|
||
判断扩展名是否图片类型,jpg,gif,png<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">isvideo(file)</view>
|
||
<view class="tip">
|
||
判断扩展名是否视频类型,mp3,mp4<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">file_ext(file)</view>
|
||
<view class="tip">
|
||
返回文件扩展名(大写),不带点。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">file_stor(url)</view>
|
||
<view class="tip">
|
||
将url转成绝对url,用于cdn分散文件存储。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">hasstr(str, find)</view>
|
||
<view class="tip">
|
||
在str中是否包含find<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">ccode(arr, value, field, nonestr)</view>
|
||
<view class="tip">
|
||
在字典数组中找到id对应对象的field值<br />
|
||
arr: 字典数组<br />
|
||
value: 待匹配值<br />
|
||
field: 输出字段,默认name。_obj返回本身<br />
|
||
nonestr: 未匹配到返回的字符串<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">scode(arr, ids, field)</view>
|
||
<view class="tip">
|
||
在字典数组中找到ids字符串对应对象的field值数组<br />
|
||
arr: 字典数组<br />
|
||
ids: 逗号分隔的字符串<br />
|
||
field: 输出字段,不填则返回对象<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">mcode(arr, value, field)</view>
|
||
<view class="tip">
|
||
在字典数组中找到value对应的对象,追溯上级。<br />
|
||
arr: 字典数组<br />
|
||
value: 待匹配值<br />
|
||
field: 输出字段,不填则返回对象<br />
|
||
返回: array
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">bcode(arr, value, field)</view>
|
||
<view class="tip">
|
||
在字典数组中找到value按位对应的对象。<br />
|
||
arr: 字典数组<br />
|
||
value: 待匹配int值<br />
|
||
field: 输出字段,不填则返回对象<br />
|
||
返回: array
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">enbase64(str)</view>
|
||
<view class="tip">
|
||
将str转成base64格式。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">svg2bg(svg)</view>
|
||
<view class="tip">
|
||
将svg转成base64格式的url(data:image...),backgroundImage语法。<br />
|
||
</view>
|
||
</ciy-textmore>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="ciy-card">
|
||
<view class="title">page函数库</view>
|
||
<view class="right">变量显示</view>
|
||
<view class="content">
|
||
<view>变量可视化转换。</view>
|
||
<ciy-textmore maskbg="var(--bg2)">
|
||
<view class="fun">topad0(num, length)</view>
|
||
<view class="tip">
|
||
数字前面不足位补0。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">tonumtho(num)</view>
|
||
<view class="tip">
|
||
整数部分千分位显示。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">tonumdec(num, showzero, len)</view>
|
||
<view class="tip">
|
||
小数部分显示<br />
|
||
showzero,是否保留.00,全0小数。<br />
|
||
len,保留位数。
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">tostr(val)</view>
|
||
<view class="tip">
|
||
将字符串转换成可见,替换了双引号。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">toint(val)</view>
|
||
<view class="tip">
|
||
将字符串转换成整数。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">tofloat(val)</view>
|
||
<view class="tip">
|
||
将字符串转换成浮点。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">tostamp(val)</view>
|
||
<view class="tip">
|
||
将字符串转换成时间戳。<br />
|
||
val=0或无,则返回当前时间<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">todatetime(time, format, nostr)</view>
|
||
<view class="tip">
|
||
将时间戳转换成可显示。<br />
|
||
nostr: 时间戳为0时返回的字符串。<br />
|
||
format: 输出格式:<br />
|
||
默认: YYYY-MM-DD HH:nn<br />
|
||
id: DDHHnn<br />
|
||
H: YYYY-MM-DD HH<br />
|
||
d: YYYY-MM-DD<br />
|
||
D: YYYY年MM月DD日<br />
|
||
x: MM-DD<br />
|
||
m: YYYY-MM<br />
|
||
n: YYYY-M<br />
|
||
y: YYYY<br />
|
||
M: YYYY年MM月<br />
|
||
i: HH:nn<br />
|
||
s: YYYY-MM-DD HH:nn:ss<br />
|
||
st: MM-DD HH:nn<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">tofix(num, length=4)</view>
|
||
<view class="tip">
|
||
将数字转换成合适的可显示小数。<br />
|
||
length<0,小数点保留n位,全0则不显示。<br />
|
||
length>0,小数点保留n位,不去0。<br />
|
||
length=0,按数长保留,尽量少的位数显示。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">tounit(ori)</view>
|
||
<view class="tip">
|
||
将三级单位,unit字符串转换成可显示文字。<br />
|
||
如: 瓶|12|盒。显示成 1盒=12瓶
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">tocyc(ori)</view>
|
||
<view class="tip">
|
||
将周期,cyc字符串转换成可显示文字。<br />
|
||
如: -1,1个月。86400,1天。60,1分钟
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">tomsk(ori, pstr)</view>
|
||
<view class="tip">
|
||
文字遮罩,将未加密字符串转换成部分显示。<br />
|
||
如: pstr=###
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">totimespan(time, bestr, zero, before)</view>
|
||
<view class="tip">
|
||
将时间转成 xx天后/xx小时前。<br />
|
||
time: 时间戳<br />
|
||
bestr: 后缀文字<br />
|
||
zero: 小于60秒显示文字。默认: 刚刚<br />
|
||
before: true过去时间,false未来时间<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">totimesec(time, bestr, zero, before)</view>
|
||
<view class="tip">
|
||
将时间转成 xx天后/xx小时前。<br />
|
||
time: 时间戳<br />
|
||
bestr: 后缀文字<br />
|
||
zero: 小于60秒显示文字。默认: 刚刚<br />
|
||
before: true过去时间,false未来时间<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">totimepoint(time, bsecond)</view>
|
||
<view class="tip">
|
||
将[1,86400]数字转成 HH:ii[:ss]<br />
|
||
例: 1 = 0:0:0,86400 = 23:59:59<br />
|
||
time: 按秒的数字<br />
|
||
bsecond: 是否包含秒<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">todayage(time, noday)</view>
|
||
<view class="tip">
|
||
返回日/月龄天数。<br />
|
||
time: 时间戳<br />
|
||
noday: true只显示月份,否则月份+天数<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">tobr(txt, autohtml)</view>
|
||
<view class="tip">
|
||
将txt中\n转成<br/><br />
|
||
如果autohtml != true,则替换<><br />
|
||
</view>
|
||
</ciy-textmore>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="ciy-card">
|
||
<view class="title">page函数库</view>
|
||
<view class="right">功能设置</view>
|
||
<view class="content">
|
||
<view>交互设置功能。</view>
|
||
<ciy-textmore maskbg="var(--bg2)">
|
||
<view class="fun">pagenoscroll(bool)</view>
|
||
<view class="tip">
|
||
页面是否允许滚动。<br />
|
||
true不允许,false允许。
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">settheme(theme)</view>
|
||
<view class="tip">
|
||
设置暗黑模式。<br />
|
||
theme支持dark/light/空。空为切换。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">setfont(font)</view>
|
||
<view class="tip">
|
||
设置敬老模式,字体大小。<br />
|
||
font支持def/lg较大/xl很大/xxl极大。
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">executepnt(pntid, post)</view>
|
||
<view class="tip">
|
||
触发积分埋点。<br />
|
||
pntid为埋点ID,post为上传的辅助数据。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">setTabbar(nameobj)</view>
|
||
<view class="tip">
|
||
设置底部导航栏。<br />
|
||
object为局部替换。<br />
|
||
array为全部替换。<br />
|
||
</view>
|
||
</ciy-textmore>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="ciy-card">
|
||
<view class="title">page函数库</view>
|
||
<view class="right">组件函数</view>
|
||
<view class="content">
|
||
<view>快捷调用组件,确保每个页面都有该组件。</view>
|
||
<ciy-textmore maskbg="var(--bg2)">
|
||
<view class="fun">async getauth(must)</view>
|
||
<view class="tip">
|
||
获取用户信息,未登录调起登录界面。<br />
|
||
true强制打开登录页,false微信自动登录。<br />
|
||
<button class="btn" @tap="gourl('../comview/auth')">转到</button>
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">async scanqr()</view>
|
||
<view class="tip">
|
||
扫二维码。<br />
|
||
返回{type,code}。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">async popmenu(opn)</view>
|
||
<view class="tip">
|
||
弹出上拉菜单。<br />
|
||
<button class="btn" @tap="gourl('../comview/popmenu')">转到</button>
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">async toast(opn)</view>
|
||
<view class="tip">
|
||
toast提示。<br />
|
||
<button class="btn" @tap="gourl('../comview/toast')">转到</button>
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">async alert(opn, btns)</view>
|
||
<view class="tip">
|
||
alert弹出框。<br />
|
||
<button class="btn" @tap="gourl('../comview/alert')">转到</button>
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">async askmsg(opn, btns)</view>
|
||
<view class="tip">
|
||
alert弹出询问框。<br />
|
||
返回btn信息。
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">async inputmsg(opn, btns)</view>
|
||
<view class="tip">
|
||
alert弹出询问框。<br />
|
||
返回{text:xxx,btn:btn信息}。
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">async sleep(ms)</view>
|
||
<view class="tip">
|
||
延迟毫秒数,一定要await等待。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">async load_ciydict(url)</view>
|
||
<view class="tip">
|
||
动态获取静态字典。<br />
|
||
</view>
|
||
</ciy-textmore>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="ciy-card">
|
||
<view class="title">page函数库</view>
|
||
<view class="right">数据处理</view>
|
||
<view class="content">
|
||
<view>解析转换数据、匹配数据。</view>
|
||
<ciy-textmore maskbg="var(--bg2)">
|
||
<view class="fun">shareparam(opn)</view>
|
||
<view class="tip">
|
||
分享链接转换,type=message从首页跳转。<br />
|
||
type: message用户,timeline朋友圈。<br />
|
||
title: 转发标题。<br />
|
||
img: 图片绝对链接,无则当前页面截图。<br />
|
||
query: 无需upid的参数{}。<br />
|
||
path: message下,当前页面route。<br />
|
||
特别的,在message下,支持3秒内异步,需自行实现。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">getstrparam(str, split='|')</view>
|
||
<view class="tip">
|
||
将简易字符串解析成object。<br />
|
||
一般在系统配置等场景使用。<br />
|
||
例如: key1=val&key2=val<br />
|
||
返回: {key1,key2}。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">urlparam()</view>
|
||
<view class="tip">
|
||
解析url?部分转成object,urldecode转码。<br />
|
||
例如: /main?key1=val&key2=val<br />
|
||
返回: {key1,key2}。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">arrayfind(arr, val, field)</view>
|
||
<view class="tip">
|
||
从数组中匹配值。返回index。<br />
|
||
找到arr[{field=val}]的index。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">objdeepmerge(src, desc, btop)</view>
|
||
<view class="tip">
|
||
object深度合并。<br />
|
||
将desc数据并入src中,并返回<br />
|
||
自动避开ciy_静态字典,自动处理带id的数组。<br />
|
||
btop:true, 新数据插入到顶部。
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">objclone(obj)</view>
|
||
<view class="tip">
|
||
object深度复制。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">str2date(str)</view>
|
||
<view class="tip">
|
||
字符串yyyy-mm-dd hh:ii:ss转new Date。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">bin2hex(bin)</view>
|
||
<view class="tip">
|
||
bin转hex字符串。<br />
|
||
例如: Ab转成4162<br />
|
||
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">hex2bin(hex)</view>
|
||
<view class="tip">
|
||
hex字符串转bin。<br />
|
||
例如: 4162转成Ab
|
||
</view>
|
||
</ciy-textmore>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="ciy-card">
|
||
<view class="title">page函数库</view>
|
||
<view class="right">其他函数</view>
|
||
<view class="content">
|
||
<ciy-textmore maskbg="var(--bg2)">
|
||
<view class="fun">style2obj(style)</view>
|
||
<view class="tip">
|
||
将style属性转换成object。<br/>
|
||
如果style是object直接返回。<br/>
|
||
如果是字符串,则驼峰处理后返回<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">nopower(mepower, power)</view>
|
||
<view class="tip">
|
||
权限检查,判断是否无权限。<br />
|
||
mepower: 用户拥有的权限。<br />
|
||
power: 目标权限。<br />
|
||
权限是字符串拼接,多个权限用.分隔。<br />
|
||
.*. 超级管理员。<br />
|
||
权限组成: 单字母+相关id+子权限代码<br/>
|
||
单字母: p PC端,m移动端,x扩展。<br />
|
||
相关id: 端取menu.id,扩展取power.id。<br />
|
||
子权限代码: 自定义,页内不重复。<br />
|
||
例: mepower = .p500a.p500d.p402.<br/>
|
||
power = p402a,则有权限。
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">getroute()</view>
|
||
<view class="tip">
|
||
获取当前页面路由,多端兼容。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">com_getpage()</view>
|
||
<view class="tip">
|
||
组件中获取页面句柄。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">async com_gethdft()</view>
|
||
<view class="tip">
|
||
组件中获取页面标题栏/导航栏高度(px)。<br />
|
||
返回: {headerheight, footerheight}
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">async getrefs()</view>
|
||
<view class="tip">
|
||
<text class="kbd">getrefsSync</text>同步函数<br/>
|
||
获取页面组件句柄。<br />
|
||
页面未准备好,则延时0.1s再获取一次。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">async getrect()</view>
|
||
<view class="tip">
|
||
获取元素尺寸。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">async file_upload1(file, opn)</view>
|
||
<view class="tip">
|
||
上传单个文件。<br />
|
||
支持本地服务器和S3云存储,由于备案原因,S3需服务器中转。<br/>
|
||
file: {} 或 文件位置<br/>
|
||
name: 文件名<br/>
|
||
tempFilePath/path: 文件位置<br/>
|
||
size: 文件大小bytes<br/>
|
||
opn: <button class="btn sm" @tap="gourl('../comform/upload')">参考</button><br/>
|
||
返回上传后路径
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">async file_uploads(files, opn, fn)</view>
|
||
<view class="tip">
|
||
上传多个文件。<br />
|
||
支持本地服务器和S3云存储,由于备案原因,S3需服务器中转。<br/>
|
||
files: [{},{}...]<br/>
|
||
name: 文件名<br/>
|
||
tempFilePath/path: 文件位置<br/>
|
||
size: 文件大小bytes<br/>
|
||
opn: <button class="btn sm" @tap="gourl('../comform/upload')">参考</button><br/>
|
||
fn: {success, fail, progress} 回调函数集合<br/>
|
||
success(上传后路径, file)。<br />
|
||
fail(错误文本, file, xhr)。<br />
|
||
progress(百分比,file)。<br />
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">async go_load(obj, act)</view>
|
||
<view class="tip">
|
||
将异步资源加载同步化。<br />
|
||
act为特例,如exec。<br />
|
||
默认处理onload,onerror事件
|
||
</view>
|
||
<view class="hr"></view>
|
||
<view class="fun">async go/goe(promise)</view>
|
||
<view class="tip">
|
||
模仿golang错误处理机制。<br/>
|
||
将异步函数中err部分转成返回值。<br />
|
||
go可带一个参数。<br />
|
||
goe不带任何参数,更方便处理。<br />
|
||
</view>
|
||
</ciy-textmore>
|
||
</view>
|
||
</view>
|
||
<view class="hr"></view>
|
||
|
||
</view>
|
||
</template>
|
||
|
||
<style>
|
||
@import '@/pages/demo/zdemo.css';
|
||
</style>
|
||
|
||
<script>
|
||
import zmixin from '@/pages/demo/zmixin.js';
|
||
export default {
|
||
data() {
|
||
return {
|
||
sys: {}
|
||
}
|
||
},
|
||
onLoad() {
|
||
},
|
||
methods: {}
|
||
}
|
||
</script> |