2022-06-06 js执行提示Uncaught URIError: URI malformed js执行提示Uncaught URIError: URI malformed 由于decodeURI转码时,通过%进行解析,如果字符串中存在%则会出现URI malformed解决方法将字符串中的%替换为25%就行了var str = '1%2'; if(str.indexOf('%') > -1) { str = str.replace(/%/g,'%25'); } 2022年06月06日 1,096 阅读 0 评论
2022-05-21 JQuery长按事件 JQuery长按事件 $(".text").on({ touchstart: function(e) { var oSpan = e.currentTarget.lastElementChild // 长按事件触发 timeOutEvent = setTimeout(function() { timeOutEvent = 0; console.log('你长按了'); }, 500); }, touchmove: function() { clearTimeout(timeOutEvent); timeOutEvent = 0; }, touchend: function() { clearTimeout(timeOutEvent); if (timeOutEvent != 0) { console.log('你点击了'); ... 2022年05月21日 910 阅读 0 评论
2022-05-13 Linux find|grep|sed命令基本语法 Linux find|grep|sed命令基本语法 find命令语法:find [-H] [-L] [-P] [-D debugopts] [-Olevel] [path...] [expression] [action] 说明:path... 查找路径,可以指定多个,默认为当前路径expression 查找的条件,包括根据文件名、类型、大小、修改时间等进行查找,默认查找当前路径所有文件action: 处理动作,对符合条件的文件所做的操作,默认为显示到标准输出查找条件:-name 根据文件名查找, 支持glob,即包括: *,?,[],[^],来匹配文件名例如:find /etc/ -name passwd 精确查找 find /etc/ -name '*passwd*' 匹配查找 -iname 根据文件名查找,不区分大小写 -regex pattern 使用正则表达式来匹配文件(路径) grep命令1、在当前目录中,查找后缀有 file 字样的文件中包含 test 字符串的文件,并打印出该字符串的行:grep test *file2、以递归的方式查找符合条件的文件:grep -r test *3、反向查找:grep -v tes... 2022年05月13日 969 阅读 0 评论
2022-04-04 js实现html导出为PDF文件 js实现html导出为PDF文件 html2canvas官网:http://html2canvas.hertzen.com/<?php if(!empty($_POST['datauri'])){ if(preg_match('/data:.*?;base64,/i',$_POST['datauri'])){ $datauri = base64_decode(preg_replace('/data:.*?;base64,/i','',$_POST['datauri'])); $dir = 'upload/'; if(!is_dir($dir)){ mkdir($dir); } $file = md5($_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR']).'.pdf'; try { file_put_contents($dir.$file,$datauri); $data = ['... 2022年04月04日 1,352 阅读 0 评论
2022-03-26 PHP将文件打包成zip PHP将文件打包成zip 单文件压缩<?php $zip = new ZipArchive(); $zip_filename = "img/".time().".zip"; // 指定一个压缩包地址 $zip->open($zip_filename, ZIPARCHIVE::CREATE); // 打开压缩包,没有则创建 /* 第一个参数:要打开的压缩包文件 第二个参数: ZIPARCHIVE::OVERWRITE 总是创建一个新的文件,如果指定的zip文件存在,则会覆盖掉 ZIPARCHIVE::CREATE 如果指定的zip文件不存在,则新建一个 ZIPARCHIVE::EXCL 如果指定的zip文件存在,则会报错 ZIPARCHIVE::CHECKCONS 对指定的zip执行其他一致性测试 */ $zip->addFile("img/1.jpg",basename("2.jpg")); $res = $zip->close() 多文件压缩<?php $fileLis... 2022年03月26日 1,251 阅读 0 评论
2022-03-25 PHP实现图片压缩 PHP实现图片压缩 <?php echo get_thumb('img/1.jpg'); /** * 图片压缩处理 * @param string $sFile 源图片路径 * @param int $iWidth 自定义图片宽度 * @param int $iHeight 自定义图片高度 * @param bool $format 文件格式是否为 源文件_宽度_高度.后缀 * @return string 压缩后的图片路径 */ function get_thumb($sFile, $iWidth = '', $iHeight = '', $format = false) { $suffix = ['jpg', 'png', 'jpeg', 'webp']; //判断该图片是否存在 if (!file_exists($sFile)) return $sFile; //判断图片格式(图片文件后缀) $extend = explode(".", $sFile); $attach_fileext = strtolower(... 2022年03月25日 1,343 阅读 0 评论
2022-03-02 微信小程序接入微信支付 微信小程序接入微信支付 获取openid参考微信授权登录微信小程序MD5加密(支持中文):https://zhizun.lanzouy.com/inF7G00vonmbpay.jsimport util from '../../utils/util.js' const md5 = require('../../utils/md5.js'); Page({ /** * 页面的初始数据 */ data: { id: '' }, /** * 生命周期函数--监听页面加载 */ onLoad: function () { }, submit(){ this.setData({id: 1}) this.unitedPayRequest('openid') }, /*统一支付接口*/ unitedPayRequest: function(openid){ var that = this; //统一支付签名 var accountInfo = wx.getAccountInfoSync(); ... 2022年03月02日 1,344 阅读 0 评论
2022-03-02 PHP xml和数组互转 PHP xml和数组互转 // xml转数组 function xml_array($xml){ //禁止引用外部xml实体 libxml_disable_entity_loader(true); $xmlstring = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA); $val = json_decode(json_encode($xmlstring),true); return $val; } // 数组转xml function array_xml($arr){ $xml = "<xml>"; foreach ($arr as $key=>$val){ if(is_array($val)){ $xml.="<".$key.">".array_xml($val)."</".$k... 2022年03月02日 1,073 阅读 0 评论
2022-02-28 微信小程序开发用户授权登录、获取手机号、昵称、头像 微信小程序开发用户授权登录、获取手机号、昵称、头像 login.wxml<button open-type="getUserProfile" bindtap="getUserProfile"> 获取头像昵称 </button> <button bindtap='onLogin'>授权登录</button> <button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">获取手机号</button> server.js// 服务接口地址 const base = 'http://localhost/'; // 开放接口配置 export default{ apiUrl:base + 'api.php' } login.js//加载公共api文件server.js import API from '../../config/server.js' Page({ /** * 页面的初始数据 *... 2022年02月28日 1,468 阅读 0 评论
2022-02-08 微信小程序获取json数据 微信小程序获取json数据 注意:需要先在微信公众平台后台里添加request合法域名,还有必须用httpsindex.wxml<view> <text>{{name}}</text> </view> index.jsonLoad:function(options){ //页面加载完成之后,发送请求获取json数据,options为页面跳转所带来的参数 var that = this; wx.request({ url: '接口地址', method: 'get', dataType: 'json', data: {id: 1}, success:function(res){ console.log(res.data); that.setData({ name: res.data.name }) }, fail:function(){ console.log('请求失败'); } }) } 2022年02月08日 1,041 阅读 0 评论