常用正则表达式
校验数字的表达式12345678910111213141516171819数字:^[0-9]*$n位的数字:^\d{n}$至少n位的数字:^\d{n,}$m-n位的数字:^\d{m,n}$零和非零开头的数字:^(0|[1-9][0-9]*)$非零开头的最多带两位小数的数字:^([1-9][0-9]*)+(.[0-9]{1,2})?$带1-2位小数的正数或负数:^(\-)?\d+(\.\d{1,2})?$正数、负数、和小数:^(\-|\+)?\d+(\.\d+)?$有两位小数的正实数:^[0-9]+(.[0-9]{2})?$有1~3位小数的正实数:^[0-9]+(.[0-9]{1,3})?$非零的正整数:^[1-9]\d*$ 或 ^([1-9][0-9]*){1,3}$ 或 ^\+?[1-9][0-9]*$非零的负整数:^\-[1-9][]0-9"*$ 或 ^-[1-9]\d*$非负整数:^\d+$ 或 ^[1-9]\d ...
获取微信小程序OpenId
基本参数
获取appid及secret
获取登录凭证code
登陆你的微信小程序在开发设置里面可以直接看到appid和secret获取登录凭证
12345678910111213141516171819//获取openiduni.login({ success: res => { var code=res.code;//登录凭证 if(code) { uni.request({ url: that.apiRoot + '/Fly_Fp/Fly_Fp_ApplyFor/getuseropenid', method: 'POST', data: { ...that.auth, data: res.code }, success: (res) => { //openid var openId = res.data; } }) } } ...
上传/读取不规则数据的Excel
上传文件
定义一个文件选择器隐藏和一个导入按钮
12<a id="lr_import" class="btn btn-default"><i class="fa fa-sign-in"></i> 导入</a><input id="filed" name="filed" type="file" style="display:none" accept=".xls,.xlsx">
重新定义一个导入按钮的目的在于便于添加额外逻辑 例如:选择不同的模板向后台传参
12345678910111213141516171819202122232425262728293031323334353637383940414243//导入 $("#lr_import").click(function () { ...