首页
关于
归档
朋友
壁纸
留言
API平台
告白墙
更多
休闲游戏
留言板
练字贴
Layui手册
Search
1
【PHP】PHPoffice/PHPSpreadsheet读取和写入Excel
1,339 阅读
2
【Git】No tracked branch configured for branch master or the branch doesn't exist.
1,038 阅读
3
【Layui】控制页面元素展示隐藏
858 阅读
4
【composer】composer常用命令
787 阅读
5
【PHP】PHP实现JWT生成和验证
769 阅读
默认分类
PHP
ThinkPHP
Laravel
面向对象
设计模式
算法
基础
网络安全
Web
HTML
CSS
JavaScript
jQuery
Layui
VUE
uni-app
Database
MySQL
Redis
RabbitMQ
Nginx
Git
Linux
Soft Ware
Windows
网赚
Go
登录
Search
标签搜索
PHP
函数
方法
类
MySQL
ThinkPHP
OOP
JavaScript
Layui
Web
Linux
Array
设计模式
Git
PHPSpreadsheet
PHPoffice
排序算法
基础
面试题
Windows
小破孩
累计撰写
223
篇文章
累计收到
33
条评论
首页
栏目
默认分类
PHP
ThinkPHP
Laravel
面向对象
设计模式
算法
基础
网络安全
Web
HTML
CSS
JavaScript
jQuery
Layui
VUE
uni-app
Database
MySQL
Redis
RabbitMQ
Nginx
Git
Linux
Soft Ware
Windows
网赚
Go
页面
关于
归档
朋友
壁纸
留言
API平台
告白墙
休闲游戏
留言板
练字贴
Layui手册
搜索到
219
篇与
的结果
2025-03-13
【JavaScript】网页实现打印
<html> <title>山东尼惜亚食品有限公司(尼惜亚冻品工厂仓:https://www.nixiyadp.com)</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <head> <style> .content { border-collapse: collapse; width: 100%; } .content th, .content td { border: 1px solid black; padding: 8px; text-align: center; } h2{ text-align: center; } .order-info{ display: flex; align-items: center; justify-content: space-between; font-size: 16px; margin-bottom: 6px; } .boutton{ margin: 0 auto; width: 200px; height: 60px; text-align: center; line-height: 60px; color: #fff; background-color: #009688; margin-top: 100px; border-radius: 8px; } </style> </head> <body> <!--startprint--><!--注意要加上html里star和end的这两个标记--> <br> <h2>要货申请单</h2> <table border="0" style="width: 100%; border-collapse: collapse; text-align: left;"> <tr> <!-- <td>订单编号:{$v.o_uuid}</td>--> <!-- --> <!-- <td>山货仓库:{$v.warehouse_name}</td>--> <td>商品总数:{$num}件</td> <td>商品总价:{$total}元</td> <tr> <!-- <tr>--> <!-- <td></td>--> <!-- <td></td>--> <!-- <td></td>--> <!-- </tr>--> <tr> <!-- <td>中请时间:{$v.o_create_time}</td>--> <!-- <td>门店名称:{$v.withorderinfo.u_shop_user_name}</td>--> <tr> <!-- <tr>--> <!-- <td></td>--> <!-- <td></td>--> <!-- <td></td>--> <!-- </tr>--> <tr> <!-- <td>审核时间:{$v.o_pay_receipt_allow_time}</td>--> <!-- <td>联系方式:{$v.o_address_tel}</td>--> <tr> </table> <br> <table class="content"> <tr> <th width="32px">序号</th> <th width="32px">类型</th> <th>商品名称</th> <th width="32px">数量</th> <th width="62px">单价</th> <th width="62px">总价</th> <!-- <th>备注</th>--> </tr> {volist name="$list" id="v"} <tr> <td>{$i}</td> <td>{empty name="$v.oi_issendgoods"} 商品{else /} 赠品{/empty}</td> <td>{$v['oi_sku_info']['goods_info']['withgoodsinfoinfo']['sg_name']}({$v['oi_sku_info']['sgcs_name']})</td> <td>{$v.total_num}</td> <td>{$v.unit_price}</td> <td>{$v.total_price}</td> <!-- <td>{$v.o_reamrk}</td>--> </tr> {/volist} </table> <br><br> <table border="0" style="width: 100%; border-collapse: collapse; text-align: left;"> <tr> <!-- <td>收 货 人:{$v.o_address_name}</td>--> <td>打印时间:{php}echo date('Y-m-d H:i:s');{/php}</td> <tr> <!-- <tr>--> <!-- <td>联系方式:{$v.o_address_tel}</td>--> <!-- <tr>--> <!-- <tr>--> <!-- <td>收货地址:{$v.o_address_info}</td>--> <!-- <tr>--> <!-- <tr>--> <!-- <td>备 注:{$v.o_reamrk}</td>--> <!-- <tr>--> </table> <!--endprint--> <div class="boutton" onclick="doPrint()"> 打 印 </div> </body> <script type="text/javascript"> function doPrint() { bdhtml=window.document.body.innerHTML; sprnstr="<!--startprint-->"; eprnstr="<!--endprint-->"; prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17); prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr)); window.document.body.innerHTML=prnhtml; window.print(); location.reload(); } </script> </html>
2025年03月13日
5 阅读
0 评论
0 点赞
2025-03-13
【PHP】通联支付 通企付 生产签名 PHP版本
/** * @Author:小破孩 * @Email:3584685883@qq.com * @Time:2025/2/17 15:25 * @param $array * @return string * @Description:数组以key=value&key=value 返回字符串 */ public function arrayKeyValueToString($array) { $result = ''; foreach ($array as $key => $value) { $result.= $key. '='. $value. '&'; } // 去除末尾多余的 & 符号 return rtrim($result, '&'); } /** * @Author:小破孩 * @Email:3584685883@qq.com * @Time:2025/2/14 15:32 * @return string * @Description:生产签名 */ public function setSign() { $data = [ 'mchNo' => $this->payConfig['tppay_mchid'], // 商户号 'appId' => $this->payConfig['tppay_appid'], // appid 'reqTime' => $this->currentTimestamp, // 13位时间戳 'version' => "1.0", // 固定值 'signType' => 'RSA', // 验签方式 'mchOrderNo' => $this->orderNo, // 订单号 'amount' => (string)$this->amount, // 金额 单位 分 'body' => $this->body, // 商品描述 'notifyUrl' => $this->getNotifyUrl(), // 回调通知地址 'expiredTime' => '1800', // 订单超时支付时间 单位 秒 'channelExtra' => $this->channelExtra, 'payTypeInfo' => (string)$this->payTypeInfo(), // 收银台展示的付款方式 // 'directPayType'=> (string)$this->getPayType(), // 直接支付的支付方式 ]; ksort($data); // Log::write("发起签名的参数:".var_export($data,true),"tppay"); $instanceArr = new \app\common\lib\data\Arr(); $encodedParams = $instanceArr->arrayKeyValueToString($data); Log::write("处理后的签名字符串:".PHP_EOL.var_export($encodedParams,true),"tppay"); $privateKey = "-----BEGIN PRIVATE KEY-----\n" . $this->payConfig['tppay_rsa_private_key'] . "\n-----END PRIVATE KEY-----"; $publicKey = "-----BEGIN PUBLIC KEY-----\n" . $this->payConfig['tppay_rsa_public_key'] . "\n-----END PUBLIC KEY-----"; // Log::write("发起签名的私钥:".var_export($privateKey,true),"tppay"); $instanceRsa = new \app\common\lib\pay\tppay\Rsa(null, null, $privateKey, $publicKey); $encryptedWithPrivate = $instanceRsa->sign($encodedParams); //签名使用SHA1withRSA // Log::write("签名的结果:".var_export($encryptedWithPrivate,true),"tppay"); return $encryptedWithPrivate; }
2025年03月13日
6 阅读
0 评论
0 点赞
2025-03-13
【PHP】ThinkPHP6.1 参数验证中间件
public function handle($request, \Closure $next) { try { // 获取并清理参数 $params = array_filter(array_map(function ($value) { return is_string($value) ? trim($value) : $value; }, $request->param()), function ($value) { return is_numeric($value) || !empty($value); }); unset($params['controller'], $params['function']); if (empty($params)) return $next($request); // 设置请求属性,方便后续使用 $request->checkParam = $params; // 获取应用名、控制器和操作名 $appName = app('http')->getName(); $controller = Request::instance()->controller(true); $action = Request::instance()->action(true); // 动态构建验证器路径 $controllerParts = explode('.', $controller); $validatePathParts = array_merge([$appName, 'validate'], $controllerParts); $validatePath = implode('\\', array_map('ucfirst', $validatePathParts)); // 检查验证器是否存在及场景是否定义 if (!class_exists($validatePath) || !$this->sceneExists($validatePath, $action)) { return $next($request); } // 验证数据 $validateInstance = new $validatePath; if (!$validateInstance->scene($action)->check($params)) { throw new Exception($validateInstance->getError()); } } catch (Exception $e) { return show(100, $e->getMessage()); } return $next($request); } /** * 检查指定验证场景是否存在 * * @param string $validateClass 验证类名 * @param string $scene 场景名 * @return bool */ protected function sceneExists(string $validateClass, string $scene): bool { return (new $validateClass)->hasScene($scene); }
2025年03月13日
7 阅读
0 评论
0 点赞
2025-03-13
【PHP】发送腾讯云短信
优化空间很大,先用着,能用<?php namespace app\common\lib\sms\tencent; //缓存 use think\facade\Cache; use TencentCloud\Common\Credential; use TencentCloud\Common\Profile\ClientProfile; use TencentCloud\Common\Profile\HttpProfile; use TencentCloud\Common\Exception\TencentCloudSDKException; use TencentCloud\Sms\V20210111\SmsClient; use TencentCloud\Sms\V20210111\Models\SendSmsRequest; class Sms{ public $SecretID = "......................"; public $SecretKey = "......................."; public $SmsSdkAppId = "..........."; public $TemplateId = "........."; public $SignName = "............"; public $code; public $phone; public function __construct($phone = '', $code = '', $tempID = '') { $this->phone = $phone; $this->code = $code; if(!empty($tempID)){ $this->TemplateId = $tempID; } } public function send(){ try { //控制台 >API密钥管理页面获取 SecretID 和 SecretKey $cred = new Credential($this->SecretID, $this->SecretKey); //实例化一个http选项 [可选] $httpProfile = new HttpProfile(); $httpProfile->setEndpoint("sms.tencentcloudapi.com"); //实例化一个client选项 [可选] $clientProfile = new ClientProfile(); $clientProfile->setHttpProfile($httpProfile); /** * 实例化以sms为例的client对象, [第三个参数 可选] * * 第二个参数是地域信息,可以直接填 ap-guangzhou */ $client = new SmsClient($cred, "ap-beijing", $clientProfile); // 实例化一个sms发送短信请求对象,每个接口都会对应一个request对象。 $req = new SendSmsRequest(); //生成随机验证码 // $code = rand(11111, 99999); // $params = array( // //接收方手机号,带上+86 示例:+8613711112222 // "PhoneNumberSet" => array((string)$this->phone), // //短信应用ID:在 [短信控制台] 添加应用后生成的实际SdkAppId // "SmsSdkAppId" => (string)$this->SmsSdkAppId, // //短信签名内容:[不理解可以看文章里的截图] // "SignName" => (string)$this->SignName, // //模板ID:必须填写已审核通过的模板 // "TemplateId" => (string)$this->TemplateId, // //我的模板中有两个参数 第一个是验证码参数 第二个是有效时间 若无模板参数,则设置为空 // "TemplateParamSet" => array((string)$this->code, '10'), // //SecretID // // "SenderId" => (string)$this->SecretID // ); $params = array( "PhoneNumberSet" => array( (string)$this->phone ), "SmsSdkAppId" => (string)$this->SmsSdkAppId, "SignName" => (string)$this->SignName, "TemplateId" => (string)$this->TemplateId, "TemplateParamSet" => array( (string)$this->code), // "SenderId" => (string)$this->SecretID ); $req->fromJsonString(json_encode($params)); //发出请求,返回一个实例 $resp = $client->SendSms($req); // print_r($resp);die; //如果成功,把验证码存入缓存 //成功实例中的Code值为 Ok if ($resp->SendStatusSet[0]->Code === "Ok") { return true; // Cache::set('name', $code, 600); // return json(['msg' => "发送成功", 'code' => 200]); } } catch (TencentCloudSDKException $e) { echo $e; } } }
2025年03月13日
7 阅读
0 评论
0 点赞
2025-03-13
【PHP】打印猿&蜂打打 开放平台 完整对接
基础类<?php namespace app\common\lib\printman; use think\facade\Log; class Basic { #APPID public $AppId; #密钥 public $AppSecret; #API地址 public $ApiUrl; #打印机ID public $PrinterId; public function __construct($AppId, $AppSecret, $PrinterId) { $this->AppId = $AppId; $this->AppSecret = $AppSecret; $this->ApiUrl = "https://iot-app-prod.fengdada.cn/mk/api"; $this->PrinterId = $PrinterId; } public function encode($BizData, $nonce) { // global $AppSecret; $jsonBytes = mb_convert_encoding($BizData , 'utf-8'); $bizData = strval($jsonBytes); $sign_ori = $bizData . $nonce . $this->AppSecret; $md5_hash = md5($sign_ori, true); $sign = base64_encode($md5_hash); return $sign; } public function generate_verification_code() { $verification_code = ""; for ($i = 0; $i < 6; $i++) { $verification_code .= strval(rand(0, 9)); } return $verification_code; } public function requests_post($url, $data, $headers) { $ch = curl_init(); curl_setopt($ch, CURLOPT_CAINFO, "cacert-2023-01-10.pem"); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); return $response; } public function DoMyPost($URL, $json_BizData) { $ts = round(microtime(true) * 1000); $nonce = $this->generate_verification_code(); $sign = $this->encode($json_BizData, $nonce); $data = array( "bizData" => $json_BizData, "nonce" => $nonce, "appId" => $this->AppId, "timestamp" => strval($ts) ); $headers = array( 'Content-Type: application/json', 'sign:'.$sign ); // $response = $this->requests_post($URL, json_encode($data), $headers); $response = $this->curlRequest($URL, "POST",json_encode($data),true,false, $headers); Log::write("打印机日志:".print_r($response,true),'printman'); if(empty($response)) { echo "Error: no response received"; }else{ return $response; } } // 云打印验证码 public function PrintCaptcha() { $URL = $this->ApiUrl."/print/captcha"; $BizData = array('printerId' => $this->PrinterId); $json_BizData = json_encode($BizData); return $this->DoMyPost($URL, $json_BizData); } // 云打印机绑定 public function PrintBind($VerificationCode) { $URL = $this->ApiUrl."/printer/bind"; $BizData = array('printerId' => $this->PrinterId, 'captcha' => $VerificationCode); $json_BizData = json_encode($BizData); return $this->DoMyPost($URL, $json_BizData); } // 云打印 public function CloudPrint( $ShareCode, $PrintDataList) { $URL = $this->ApiUrl."/print"; $BizData = array('printerId' => $this->PrinterId, 'shareCode' => $ShareCode, 'printData' => $PrintDataList); $json_BizData = json_encode($BizData); return $this->DoMyPost($URL, $json_BizData); } // 云打印状态查询 public function QueryPrintStatus($ShareCode) { $URL = $this->ApiUrl."/printer/status/query"; $BizData = array('printerId' => $this->PrinterId, 'shareCode' => $ShareCode); $json_BizData = json_encode($BizData); return $this->DoMyPost($URL, $json_BizData); } //云打印解绑//0标识解绑失败,1标识解绑成功 public function unbind($ShareCode){ $URL = $this->ApiUrl."/printer/unbind"; $BizData = array('printerId' => $this->PrinterId, 'shareCode' => $ShareCode); $json_BizData = json_encode($BizData); return $this->DoMyPost($URL, $json_BizData); } /** * @Author: 小破孩嫩 * @Email: 3584685883@qq.com * @Time: 2021/4/1 10:39 * @param string $url url地址 * @param string $method 请求方法,默认为 'GET',可选值为 'GET' 或 'POST' * @param mixed $data 要发送的数据,如果是 POST 请求则为数据内容,否则为 null * @param array $headers 自定义请求头信息 * @param int $timeout 超时时间,默认为 30 秒 * @param bool $verifySSL 是否验证 SSL 证书,默认为 true * @param bool $flbg 返回值是否转成数组,默认不转 * @param bool $headercontent 是否获取请求的header值内容,默认不获取 * @return array|bool|mixed|string * @Description:curl请求 */ protected function curlRequest($url, $method = 'GET', $data = null, $flbg = false, $verifySSL = true, $headers = [], $headerContent = false, $timeout = 30) { // 初始化 cURL 会话 $ch = curl_init(); // 设置要请求的 URL curl_setopt($ch, CURLOPT_URL, $url); // 设置获取的信息以字符串形式返回,而不是直接输出 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 设置超时时间 curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); // 设置请求方法 if ($method === 'POST') { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); } // 设置请求头 if (!empty($headers)) { curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); } // 设置是否验证 SSL 证书 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $verifySSL); // 执行 cURL 会话并获取响应 $response = curl_exec($ch); // 获取 HTTP 响应码 $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); // 如果 cURL 执行出错 if (curl_errno($ch)) { // 输出错误信息 echo 'Curl error: ' . curl_error($ch); // 关闭 cURL 会话并返回 false curl_close($ch); return false; } // 如果 HTTP 响应码大于等于 400(表示错误) elseif ($httpCode >= 400) { // 输出错误信息 echo "HTTP error: $httpCode"; // 关闭 cURL 会话并返回 false curl_close($ch); return false; } // 处理是否获取请求头内容 if ($headerContent && $httpCode == 200) { $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $headers = substr($response, 0, $headerSize); $body = substr($response, $headerSize); curl_close($ch); return [$headers, $body]; } // 关闭 cURL 会话 curl_close($ch); // 处理是否将响应转换为数组 if ($flbg) { $response = json_decode($response, true); } // 返回响应内容 return $response; } /** * @Author:小破孩 * @Email:3584685883@qq.com * @Time:2025/1/10 14:02 * @param $code * @return string * @Description:打印机错误码 */ public function errorCode($code){ $errorCodes = [ 200 => "success 成功", 500 => "sys fail 系统异常", 2001 => "sign check fail 签名失败", 2002 => "not find partner 查无合作伙伴", 2003 => "illegal access 非法访问", 3001 => "param check error 参数错误", 3002 => "please input params 请输入参数", 40001 => "please input APPID 请输入appid", 40002 => "biz exception 业务异常", 40003 => "printer xxx is offline 打印机离线", 40004 => "printer xxx is not auth 打印机未授权", 40005 => "shareCode is error 分享码错误", 40006 => "printer xxx after 5 minutes reprinting 请5分钟后重试", 40007 => "printer xxx captcha error 验证码错误", 40008 => "printer xxx captcha expired 验证码过期", 40009 => "printer xxx bind fail 绑定失败", 40023 => "lip not close 盖子未闭合", 40023 => "sticker 粘纸", 40023 => "sticker and lip not close 粘纸并且盖子未闭合", 40023 => "no page 缺纸", 40023 => "no page and lip not close 缺纸并且盖子未闭合", 40023 => "temperature too high 温度过高", 40023 => "temperature too high and lip not close 温度过高且盖子未闭合", 40023 => "temperature too high and sticker 温度过高且粘纸", 40023 => "temperature too high and lip not close and sticker 温度过高且粘纸,盖子未闭合", 40023 => "command error 指令错误" ]; return $errorCodes[$code]; } }模板<?php namespace app\common\lib\printman\template; use app\common\lib\printman\Template; class Temp1 implements Template { protected $id; public function __construct($id = "") { $this->id = $id; } /** * @Author:小破孩 * @Email:3584685883@qq.com * @Time:2025/1/10 10:51 * @return string * @Description:打印模板1 */ public function temp($order = ""){ if(empty($order)){ return "没有订单信息"; } $height = ceil(self::getTempHight($order)/10+50); $i = 40; $template = ""; $template .= "SIZE 72 mm, ".$height." mm\r\n"; $template .= "CODEPAGE 437\r\n"; $template .= "DENSITY 8\r\n"; $template .= "CLS \r\n"; $template .= "CODEPAGE 936\r\n"; $template .= "DIRECTION 0\r\n"; $template .= "TEXT 220,0,\"4\",0,1,1,\""."订单详情"."\"\r\n"; //小票标题 $template .= "TEXT 220,".$i.",\"4\",0,1,1,\"".""."\"\r\n"; //换行 $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"订单编号:".$order['o_uuid']."\"\r\n"; $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"打印时间:".date("Y-m-d H:i:s")."\"\r\n"; $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"申 请 人:".$order['o_address_name']."\"\r\n"; $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"联系方式:".$order['o_address_tel_default']."\"\r\n"; $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"收货地址:".mb_substr($order['o_address_info'],0,16)."\"\r\n"; if(mb_strlen($order['o_address_info']) > 16){ $template .= "TEXT 40,"; $template .= $i+=30; $template .=",\"0\",0,1,1,\" ".mb_substr($order['o_address_info'],16)."\"\r\n"; } $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"申请时间:".$order['o_create_time']."\"\r\n"; // $template .= "TEXT 40,"; // $template .= $i+=30; // $template .= ",\"0\",0,1,1,\"审核时间:".date("Y-m-d H:i:s",$order['o_pay_receipt_allow_time'])."\"\r\n"; $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"配 送 员:".$order['salesmaninfo']['sm_name']."\"\r\n"; $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"配送电话:".$order['salesmaninfo']['sm_phone']."\"\r\n"; $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"出货仓库:".$order['warehouse_name']."\"\r\n"; $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"商品总数:".$order['goods_total_num']."\"\r\n"; $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"商品总价:".$order['o_real_price']."\"\r\n"; $template .= "BAR 20,"; $template .= $i+=28; $template .= ",720,2\r\n"; $template .= "TEXT 40,"; $template .= $i+=16; $template .= ",\"0\",0,1,1,\"商品 数量 单价 金额\"\r\n"; $template .= "BAR 20,"; $template .= $i+=28; $template .= ",720,2\r\n"; foreach ($order['order_list'] as $kk => $vv){ if(!empty($vv['oi_issendgoods'])){ $firstNamaText = "赠品:"; }else{ $firstNamaText = "商品:"; } $knum = $kk+=1; $template .= "TEXT 30,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"$knum.". mb_substr($firstNamaText.$vv['oi_sku_info']['goods_info']['withgoodsinfoinfo']['sg_name'].'('.$vv['oi_sku_info']['sgcs_name'].')',0,26)."\"\r\n"; if(mb_strlen($firstNamaText.$vv['oi_sku_info']['goods_info']['withgoodsinfoinfo']['sg_name'].'('.$vv['oi_sku_info']['sgcs_name'].')') > 26){ $template .= "TEXT 30,"; $template .= $i+=30; $template .=",\"0\",0,1,1,\" ".mb_substr($firstNamaText.$vv['oi_sku_info']['goods_info']['withgoodsinfoinfo']['sg_name'].'('.$vv['oi_sku_info']['sgcs_name'].')',26)."\"\r\n"; } $template .= "TEXT 65,"; $template .= $i+=30; if(!empty($vv['oi_issendgoods'])){ $template .=",\"0\",0,1,1,\"".$vv['oi_sku_info']['num'].'件'.' '."0.00".' '."0.00"."\"\r\n"; }else{ $template .=",\"0\",0,1,1,\"".$vv['oi_sku_info']['num'].'件'.' '.sprintf("%.2f",$vv['oi_sku_info']['sgcs_price']/$vv['oi_sku_info']['num']).' '.$vv['oi_real_price']."\"\r\n"; } } $template .= "BAR 20,"; $template .= $i+=28; $template .= ",720,2\r\n"; $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"数量总计:".$order['goods_total_num'].'件'."\"\r\n"; $template .= "PRINT 1,1"; $instacneStr = new \app\common\lib\data\Str(); $data = [ 'waybillPrinterData' => $instacneStr->gzipAndBase64Encode($template), 'printType' => 'tspl', 'id' => $this->id ]; return [$data]; } protected function getTempHight($order){ $i = 50; $template = ""; $template .= "SIZE 72 mm, 90 mm\r\n"; $template .= "CODEPAGE 437\r\n"; $template .= "DENSITY 8\r\n"; $template .= "CLS \r\n"; $template .= "CODEPAGE 936\r\n"; $template .= "DIRECTION 0\r\n"; $template .= "TEXT 220,0,\"4\",0,1,1,\""."订单详情"."\"\r\n"; //小票标题 $template .= "TEXT 220,".$i.",\"4\",0,1,1,\"".""."\"\r\n"; //换行 $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"订单编号:".$order['o_uuid']."\"\r\n"; $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"打印时间:".date("Y-m-d H:i:s")."\"\r\n"; $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"申 请 人:".$order['o_address_name']."\"\r\n"; $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"联系方式:".$order['o_address_tel_default']."\"\r\n"; $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"收货地址:".mb_substr($order['o_address_info'],0,16)."\"\r\n"; if(mb_strlen($order['o_address_info']) > 16){ $template .= "TEXT 40,"; $template .= $i+=30; $template .=",\"0\",0,1,1,\" ".mb_substr($order['o_address_info'],16)."\"\r\n"; } $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"申请时间:".$order['o_create_time']."\"\r\n"; // if(empty($order['o_help'])){ // $template .= "TEXT 40,"; // $template .= $i+=30; // $template .= ",\"0\",0,1,1,\"审核时间:".date("Y-m-d H:i:s",$order['o_pay_receipt_allow_time'])."\"\r\n"; // } $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"配送员姓名:".$order['salesmaninfo']['sm_name']."\"\r\n"; $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"配送员电话:".$order['salesmaninfo']['sm_phone']."\"\r\n"; $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"出货仓库:".$order['warehouse_name']."\"\r\n"; $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"商品总数:".$order['goods_total_num']."\"\r\n"; $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"商品总价:".$order['o_real_price']."\"\r\n"; $template .= "BAR 20,"; $template .= $i+=28; $template .= ",720,2\r\n"; $template .= "TEXT 40,"; $template .= $i+=16; $template .= ",\"0\",0,1,1,\"商品 数量 单价 金额\"\r\n"; $template .= "BAR 20,"; $template .= $i+=28; $template .= ",720,2\r\n"; // foreach ($order as $key => $val){ foreach ($order['order_list'] as $kk => $vv){ if(!empty($vv['oi_issendgoods'])){ $firstNamaText = "赠品:"; }else{ $firstNamaText = "商品:"; } $knum = $kk+=1; $template .= "TEXT 30,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"$knum.". mb_substr($firstNamaText.$vv['oi_sku_info']['goods_info']['withgoodsinfoinfo']['sg_name'].'('.$vv['oi_sku_info']['sgcs_name'].')',0,26)."\"\r\n"; if(mb_strlen($firstNamaText.$vv['oi_sku_info']['goods_info']['withgoodsinfoinfo']['sg_name'].'('.$vv['oi_sku_info']['sgcs_name'].')') > 26){ $template .= "TEXT 30,"; $template .= $i+=30; $template .=",\"0\",0,1,1,\" ".mb_substr($firstNamaText.$vv['oi_sku_info']['goods_info']['withgoodsinfoinfo']['sg_name'].'('.$vv['oi_sku_info']['sgcs_name'].')',26)."\"\r\n"; } $template .= "TEXT 65,"; $template .= $i+=30; $template .=",\"0\",0,1,1,\"".$vv['oi_sku_info']['num'].'件'.' '.$vv['oi_sku_info']['sgcs_price'].' '.$vv['oi_sku_info']['sgcs_price']*$vv['oi_sku_info']['num']."\"\r\n"; } $template .= "BAR 20,"; $template .= $i+=28; $template .= ",720,2\r\n"; $template .= "TEXT 40,"; $template .= $i+=30; $template .= ",\"0\",0,1,1,\"数量总计:".$order['goods_total_num']."\"\r\n"; // } $template .= "PRINT 1,1"; return $i; } }
2025年03月13日
5 阅读
0 评论
0 点赞
2025-03-13
【PHP】给富文本内容的图片,视频,文件 拼接当前网址域名
/** * @Author:小破孩 * @Email:3584685883@qq.com * @Time:2024/11/18 15:20 * @param $text * @param $domain * @return string|string[]|null * @Description:给服务文本拼接当前网址域名 */ public function addDomainToPaths($text, $domain){ // 匹配图片路径 $text = preg_replace('/<img.*?src="([^"]+)"/i', '<img src="' . $domain . '$1"', $text); // 匹配视频路径 $text = preg_replace('/<video.*?src="([^"]+)"/i', '<video src="' . $domain . '$1"', $text); // 匹配文件路径(可根据具体文件类型的链接特征进行修改) $text = preg_replace('/<a.*?href="([^"]+)"/i', '<a href="' . $domain . '$1"', $text); return $text; }
2025年03月13日
9 阅读
0 评论
0 点赞
2025-03-13
【PHP】过滤富文本内容
/** * @Author:小破孩 * @Email:3584685883@qq.com * @Time:2024/10/24 13:50 * @param $text * @return string|string[]|null * @Description:过滤富文本 */ public static function filterRichText($text){ // 定义要过滤的 SQL 关键字模式 $sqlPatterns = [ '/\b(SELECT|INSERT|UPDATE|DELETE|FROM|WHERE|AND|OR|JOIN|DROP|CREATE|ALTER|TRUNCATE|GRANT|REVOKE|SET)\b/i', '/\b(AS|LIKE|NOT|IN|BETWEEN|IS|NULL|COUNT|SUM|AVG|MIN|MAX)\b/i', '/\b(UNION|ALL|ANY|EXISTS)\b/i', '/\b(ORDER\s+BY|LIMIT)\b/i' ]; // 定义要过滤的常见函数模式 $functionPatterns = [ '/\b(function\s+\w+\s*\([^)]*\))\b/i', '/\b(eval|exec|system|passthru|shell_exec|assert)\b/i' ]; // 定义要过滤的特殊字符和表达式模式 $specialPatterns = [ '/\$\{.*?\}/', // 过滤类似 ${expression} 的表达式 '/@.*?;/', // 过滤以 @ 开头并以 ; 结尾的表达式 '/\b(phpinfo|var_dump)\b/i', // 过滤特定的 PHP 函数 '/<\s*(script|iframe|object|embed|applet)[^>]*>/i' // 过滤危险的脚本标签 ]; // 定义要过滤的危险属性模式 $dangerousAttributesPatterns = [ '/on\w+\s*=/i', // 过滤以 "on" 开头的事件属性 '/javascript:[^"]*"/i' // 过滤 JavaScript 协议的链接 ]; // 先过滤 SQL 关键字 $filteredText = preg_replace($sqlPatterns, '', $text); // 再过滤函数 $filteredText = preg_replace($functionPatterns, '', $filteredText); // 然后过滤特殊字符和表达式 $filteredText = preg_replace($specialPatterns, '', $filteredText); // 接着过滤危险的属性 $filteredText = preg_replace($dangerousAttributesPatterns, '', $filteredText); // 处理可能出现的连续空格 $filteredText = preg_replace('/\s+/', ' ', $filteredText); // 去除前后的空格 $filteredText = trim($filteredText); // 转换 HTML 实体 $filteredText = htmlentities($filteredText, ENT_QUOTES, 'UTF-8'); return $filteredText; }
2025年03月13日
7 阅读
0 评论
0 点赞
2025-03-13
【PHP】获取二维数组里面最小的值
/** * @Author:小破孩 * @Email:3584685883@qq.com * @Time:2024/12/5 17:16 * @param $array * @return array * @Description:获取一个二维数组,数据最小的,并返回对应的key和value */ public function getMinValueKey($array) { $minValue = PHP_INT_MAX; $desiredKey = null; foreach ($array as $key => $subArray) { foreach ($subArray as $subKey => $value) { if ($value < $minValue) { $minValue = $value; $desiredKey = $subKey; } } } return [$desiredKey, $minValue]; } //使用场景 $inatanceMap = new \app\common\lib\map\baidu\Lnglat($this->param['ac_address']); $lnglat = $inatanceMap->addressToLngLat(); $this->param['u_lng'] = $lnglat['lng'];//经度 $this->param['u_lat'] = $lnglat['lat'];//纬度 $companyList = M("AdminCompany")::getCompanyListUseSelect(); $instanceDis = new \app\common\lib\map\Distance(); foreach ($companyList as $key => $val){ $arrAddress[$key][$val['ac_uuid']] = $instanceDis->getdistance($val['ac_lng'],$val['ac_lat'],$lnglat['lng'],$lnglat['lat']); } $instanceArr = new \app\common\lib\data\Arr(); list($minKey, $minValue) = $instanceArr->getMinValueKey($arrAddress); $this->param['u_company_uuid'] = $minKey; $this->param['u_address'] = $this->param['ac_address'];
2025年03月13日
7 阅读
0 评论
0 点赞
2025-03-13
【PHP】按照个商品金额,等比例分配优惠劵
/** * @Author:小破孩 * @Email:3584685883@qq.com * @Time:2024/11/23 11:41 * @param $products ['id' => 'price','id' => price] * @param $totalCouponAmount 优惠劵优惠金额 * @return array * @Description:按照商品比例拆分优惠劵,分配给对应的商品 */ public function getSplitCoupon($products, $totalCouponAmount) { $totalAmount = array_sum($products); $discounts = []; $allocatedDiscount = 0; foreach ($products as $id => $amount) { $ratio = $amount / $totalAmount; $discount = $ratio * $totalCouponAmount; $roundedDiscount = round($discount, 2); $discounts[$id] = $roundedDiscount; $allocatedDiscount += $roundedDiscount; } // 调整以使总和为指定的优惠券总额 $diff = $totalCouponAmount - $allocatedDiscount; if ($diff!= 0) { $sortedDiscounts = $discounts; arsort($sortedDiscounts); $i = 0; foreach ($sortedDiscounts as $id => $discount) { if ($i < abs($diff)) { $discounts[$id] += ($diff > 0)? 0.01 : -0.01; } $i++; } } return $discounts; }
2025年03月13日
5 阅读
0 评论
0 点赞
2024-10-26
【ThinkPHP】最新版本上传文件的类
<?php namespace app\common\lib\file; use think\Exception; use think\exception\ValidateException; class Uploads { private $domain; protected $name; protected $type; protected $module; protected $image; public function __construct($name = '',$image = []) { $this->name = $name; $this->module = app('http')->getName(); $this->image = $image; $this->domain = Request()->domain(); } protected $config = [ 'image' => [ 'validate' => [ 'size' => 10*1024*1024, 'ext' => 'jpg,png,gif,jpeg', ], 'path' => '/images', ], 'audio' => [ 'validate' => [ 'size' => 100*1024*1024, 'ext' => 'mp3,wav,cd,ogg,wma,asf,rm,real,ape,midi', ], 'path' => '/audios', ], 'video' => [ 'validate' => [ 'size' => 100*1024*1024, 'ext' => 'mp4,avi,rmvb,rm,mpg,mpeg,wmv,mkv,flv', ], 'path' => '/videos', ], 'file' => [ 'validate' => [ 'size' => 5*1024*1024, 'ext' => 'doc,docx,xls,xlsx,pdf,ppt,pptx,txt,rar,zip,pem,p12', ], 'path' => '/files', ], ]; private function determineFileType($file) { $mime = $file->getMime(); if (strpos($mime, 'image/') === 0) { $this->type = 'image'; } elseif (strpos($mime, 'video/') === 0) { $this->type = 'video'; } elseif (strpos($mime, 'audio/') === 0) { $this->type = 'audio'; } else { $this->type = 'file'; } if (!in_array($this->type, array_keys($this->config))) { throw new ValidateException("the file type does not exist"); } validate(['file' => self::validateFile()])->check(['file' => $file]); } public function upfile($infoSwitch = false,$savelocal = 'local'){ try{ $file = request()->file($this->name); //检测文件 if($file == null) throw new ValidateException("the file cannot be empty"); //验证文件 $this->determineFileType($file); //上传文件 switch ($savelocal){ case 'aliyun': $savename = \think\facade\Filesystem::disk('aliyun')->putFile( $this->module.$this->config[$this->type]['path'], $file); break; case 'qiniu': $savename = \think\facade\Filesystem::disk('qiniu')->putFile( $this->module.$this->config[$this->type]['path'], $file); break; case 'qcloud': $savename = \think\facade\Filesystem::disk('qcloud')->putFile( $this->module.$this->config[$this->type]['path'], $file); break; case 'local': $savename = \think\facade\Filesystem::disk('public')->putFile( $this->module.$this->config[$this->type]['path'], $file); break; default : $savename = \think\facade\Filesystem::disk('public')->putFile( $this->module.$this->config[$this->type]['path'], $file); break; } // $savename = \think\facade\Filesystem::disk('public')->putFile( $this->module.$this->config[$this->type]['path'], $file); // $savename = \think\facade\Filesystem::disk('aliyun')->putFile( 'topic', $file); //返回文件详情和文件地址 if($infoSwitch){ return self::getFileInfo($file,$savename); } return $this->domain.config('filesystem.disks.public.url').'/'.str_replace('\\','/',$savename); }catch (\think\exception\ValidateException $e){ return show(100,self::languageChange($e->getMessage())); } } private function validateFile(){ if(empty($this->image)){ $validataType = [ 'fileSize' => $this->config[$this->type]['validate']['size'], 'fileExt' => $this->config[$this->type]['validate']['ext'], ]; }else{ if(is_array($this->image)) throw new ValidateException(""); $validataType = [ 'fileSize' => $this->config[$this->type]['validate']['size'], 'fileExt' => $this->config[$this->type]['validate']['ext'], 'image' => $this->image //示例值 [200,200] ]; } return $validataType; } private function languageChange($msg){ $data = [ 'the file type does not exist' => '文件类型不存在!', 'the file cannot be empty' => '文件不能为空!', 'unknown upload error' => '未知上传错误!', 'file write error' => '文件写入失败!', 'upload temp dir not found' => '找不到临时文件夹!', 'no file to uploaded' => '没有文件被上传!', 'only the portion of file is uploaded' => '文件只有部分被上传!', 'upload File size exceeds the maximum value' => '上传文件大小超过了最大值!', 'upload write error' => '文件上传保存错误!', ]; return $data[$msg] ?? $msg; } private function getFileInfo($file,$savename){ $info = [ 'path' => config('filesystem.disks.public.url').'/'.str_replace('\\','/',$savename), 'url' => $this->domain.config('filesystem.disks.public.url').'/'.str_replace('\\','/',$savename), 'size' => $file->getSize(), 'name' => $file->getOriginalName(), 'mime' => $file->getMime(), 'ext' => $file->extension(), 'type' => $this->type ]; return $info; } public function __clone() { throw new Exception("Cloning operation is not allowed"); // TODO: Implement __clone() method. } // 使用方法 : // $instanceUpload = new Uploads($fileName); // $info = $instanceUpload->upfile(true); } 如果要用建议封装一下,使用interface定义个规范,这里更像一个方法函数
2024年10月26日
54 阅读
0 评论
0 点赞
2024-09-30
【PHP】PHP函数详解:call_user_func()使用方法
PHP函数详解:call_user_func()使用方法 call_user_func函数类似于一种特别的调用函数的方法,使用方法如下: <?php function nowamagic($a,$b) { echo $a; echo $b; } call_user_func('nowamagic', "111","222"); call_user_func('nowamagic', "333","444"); //显示 111 222 333 444 ?> 调用类内部的方法比较奇怪,居然用的是array,不知道开发者是如何考虑的,当然省去了new,也挺有新意的: <?php class a { function b($c) { echo $c; } } call_user_func(array("a", "b"),"111"); //实例化a类并调用b方法 //显示 111 ?> call_user_func_array函数和call_user_func很相似,只不过是换了一种方式传递了参数,让参数的结构更清晰: <?php function a($b, $c) { echo $b; echo $c; } call_user_func_array('a', array("111", "222")); //显示 111 222 ?> call_user_func_array函数也可以调用类内部的方法的 <?php Class ClassA { function bc($b, $c) { $bc = $b + $c; echo $bc; } } call_user_func_array(array('ClassA','bc'), array("111", "222")); //显示 333 ?> call_user_func函数和call_user_func_array函数都支持引用,这让他们和普通的函数调用更趋于功能一致: <?php function a($b) { $b++; } $c = 0; call_user_func('a', $c); echo $c;//显示 1 call_user_func_array('a', array($c)); echo $c;//显示 2 ?> 另外,call_user_func函数和call_user_func_array函数都支持引用。 <?php function increment(&$var) { $var++; } $a = 0; call_user_func('increment', $a); echo $a; // 0 call_user_func_array('increment', array(&$a)); // You can use this instead echo $a; // 1 ?>
2024年09月30日
62 阅读
0 评论
0 点赞
2024-06-23
【PHP】H5微信网页自定义分享功能实现
<?php namespace app\index\lib\wechat; header("Access-Control-Allow-Origin:*"); class share { public $appid; public $secret; // 步骤1.appid和secret //header("Access-Control-Allow-Origin:*"); //$appid = "appid"; //$secret = "secret"; public function __construct($appid,$secret) { $this->appid = $appid; $this->secret = $secret; } // 步骤2.生成签名的随机串 public function nonceStr($length){ $str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJK1NGJBQRSTUVWXYZ';//随即串,62个字符 $strlen = 62; while($length > $strlen){ $str .= $str; $strlen += 62; } $str = str_shuffle($str); return substr($str,0,$length); } // 步骤3.获取access_token public function http_get($url){ $oCurl = curl_init(); if(stripos($url,"https://")!==FALSE){ curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($oCurl, CURLOPT_SSLVERSION, 1); //CURL_SSLVERSION_TLSv1 } curl_setopt($oCurl, CURLOPT_URL, $url); curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1 ); $sContent = curl_exec($oCurl); $aStatus = curl_getinfo($oCurl); curl_close($oCurl); if(intval($aStatus["http_code"])==200){ return $sContent; }else{ return false; } } // 步骤4.获取ticket public function getTicket(){ $result = $this->http_get('https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$this->appid.'&secret='.$this->secret); $json = json_decode($result,true); $access_token = $json['access_token']; $url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token=$access_token"; $res = json_decode ( $this->http_get ( $url ) ); return $res->ticket; } // 步骤5.生成wx.config需要的参数 //$surl = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; //$ws = getWxConfig( $ticket,$surl,time(),nonceStr(16) ); // public function getWxConfig($jsapiTicket,$url,$timestamp,$nonceStr) { public function getWxConfig() { $jsapiTicket=$this->getTicket(); $url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; $timestamp = time(); $nonceStr = $this->nonceStr(rand(8,15)); $string = "jsapi_ticket=".$jsapiTicket."&noncestr=".$nonceStr."×tamp=".$timestamp."&url=".$url; $signature = sha1 ($string); $WxConfig["appId"] = $this->appid; $WxConfig["nonceStr"] = $nonceStr; $WxConfig["timestamp"] = $timestamp; $WxConfig["url"] = $url; $WxConfig["signature"] = $signature; $WxConfig["rawString"] = $string; return $WxConfig; } } public function getWxShareConfig(){ $instanceWxShare = new \app\index\lib\wechat\share('appid','secret'); return $instanceWxShare->getWxConfig(); } <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script> <script> // console.log(timestamp); wx.config({ debug: false, appId: '{$wxsc.appId}', timestamp: '{$wxsc.timestamp}', nonceStr: '{$wxsc.nonceStr}', signature: '{$wxsc.signature}', jsApiList: ['updateAppMessageShareData','updateTimelineShareData'] }); wx.ready(function () { //需在用户可能点击分享按钮前就先调用 wx.updateAppMessageShareData({ title: '医博:', // 分享标题 desc: '专业肛肠、胃肠、中医交流平台,为业界名专家们搭建教学、学术平台,为专业医生提供手术直播、科普交流基地,为学者提供学习、沟通、上升平台。', // 分享描述 link: 'https://wx.kmyebo.com', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 imgUrl: 'https://wx.kmyebo.com/yb_share_icon.jpg', // 分享图标 success: function () { // 设置成功 } }) }); wx.ready(function () { //需在用户可能点击分享按钮前就先调用 wx.updateTimelineShareData({ title: '医博:', // 分享标题 link: 'https://wx.kmyebo.com', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 imgUrl: 'https://wx.kmyebo.com', // 分享图标 success: function () { // 设置成功 } }) }); </script>http://www.xmyfw.com.cn/pc/show.php?id=55
2024年06月23日
103 阅读
0 评论
0 点赞
2024-04-19
【Dos】如何快速修改,替换文件名或者文件部分名
Get-ChildItem -Path "文件路径tip:直接复制硬盘路径" -Filter "*.html" | ForEach-Object { >> $newName = $_.Name -replace '原内容', '替换成' >> Rename-Item -Path $_.FullName -NewName $newName >> }.
2024年04月19日
111 阅读
0 评论
0 点赞
2023-08-09
【Layui】图片预览
要在 layui 中点击图片实现预览功能,你可以使用 layui 的 layer.photos 方法来轻松实现图片预览。以下是如何在点击图片时使用 layer.photos 来创建图片预览的示例代码:<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Layui Image Preview</title> <link rel="stylesheet" href="path/to/layui/css/layui.css"> <script src="path/to/layui/layui.js"></script> </head> <body> <div class="images-container"> <img class="preview-image" src="path/to/image1.jpg" alt="Image 1"> <img class="preview-image" src="path/to/image2.jpg" alt="Image 2"> <img class="preview-image" src="path/to/image3.jpg" alt="Image 3"> </div> <script> layui.use(['layer'], function() { var layer = layui.layer; // 点击事件处理 $('.preview-image').on('click', function() { var images = []; // 存放图片信息的数组 var currentImage = this.src; // 获取所有图片信息 $('.preview-image').each(function() { images.push({ alt: $(this).attr('alt'), src: $(this).attr('src') }); }); // 在弹窗中预览图片 layer.photos({ photos: { title: '图片预览', // 弹窗标题 data: images, start: images.findIndex(img => img.src === currentImage) // 从当前图片开始预览 }, shadeClose: true, // 点击遮罩关闭弹窗 closeBtn: 2 // 显示关闭按钮 }); }); }); </script> </body> </html> 在上述示例代码中,我们创建了一个包含多个图片的容器,然后为每个图片添加了共同的类名 preview-image。通过点击图片,会触发 layer.photos 方法,该方法可以用来创建一个图片预览弹窗。我们使用一个包含图片信息的数组来配置预览图片,其中 title 为弹窗标题,data 包含图片信息,start 指定从数组中的哪个索引开始预览。请注意,替换代码中的图片 URL 和其他相关信息。此示例为演示目的,你可以根据实际需求进行调整和修改。
2023年08月09日
345 阅读
0 评论
0 点赞
2023-07-20
【PHP】打开文件路径的所有文件
<?php function open_dir($path) { if (!is_dir($path) || empty($path)) die("该" . $path . "不是目录"); $path = $path . '/'; $fileList = []; $dirFile = scandir($path); if (!empty($dirFile) && is_array($dirFile)) { foreach ($dirFile as $file) { if ($file != '.' && $file != '..') { $fullPath = $path . $file; if (is_dir($fullPath)) { // 子文件夹,进行递归 $fileList[$file] = open_dir($fullPath); } else { //根目录下的文件 $fileList[] = $file; } } } } return $fileList; } $list = open_dir("/www/wwwroot/8688web.com/one"); // echo '<pre>'; // print_r($list); // echo '</pre>'; ?>
2023年07月20日
179 阅读
0 评论
0 点赞
2023-07-20
【JavaScript】鼠标禁止右键禁止打开控制台及键盘禁用
// 1.禁用右键菜单 document.oncontextmenu = new Function("event.returnValue=false"); // 2.禁用鼠标选中 document.onselectstart = new Function("event.returnValue=false"); document.onkeydown = () => { console.log(window.event.keyCode); for (let i = 9; i < 47; i++) { if (window.event && window.event.keyCode == i) { return false; } } for (let i = 58; i < 65; i++) { if (window.event && window.event.keyCode == i) { return false; } } for (let i = 91; i < 300; i++) { if (window.event && window.event.keyCode == i) { return false; } } // 禁用ctrl+shift+i if (window.event.ctrlKey && window.event.shiftKey && window.event.keyCode == 73) { return false; } if (window.event.shiftKey) { return false; } // 禁用ctrl+r if (window.event.ctrlKey && window.event.keyCode == 82) { return false; } }
2023年07月20日
201 阅读
0 评论
0 点赞
2023-07-13
【PHP】$_SERVER内容
Array ( [ALLUSERSPROFILE] => C:\ProgramData [APPDATA] => C:\Users\Administrator\AppData\Roaming [CommonProgramFiles] => C:\Program Files\Common Files [CommonProgramFiles(x86)] => C:\Program Files (x86)\Common Files [CommonProgramW6432] => C:\Program Files\Common Files [COMPUTERNAME] => USER-20230417GP [ComSpec] => C:\Windows\system32\cmd.exe [DriverData] => C:\Windows\System32\Drivers\DriverData [EFC_7072] => 1 [FPS_BROWSER_APP_PROFILE_STRING] => Internet Explorer [FPS_BROWSER_USER_PROFILE_STRING] => Default [HOMEDRIVE] => C: [HOMEPATH] => \Users\Administrator [LOCALAPPDATA] => C:\Users\Administrator\AppData\Local [LOGONSERVER] => \\USER-20230417GP [NUMBER_OF_PROCESSORS] => 4 [OneDrive] => C:\Users\Administrator\OneDrive [OS] => Windows_NT [Path] => C:\Program Files (x86)\Common Files\NetSarang;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;E:\krhwork\phpstudy_pro\Extensions\php\php7.3.4nts;C:\ProgramData\ComposerSetup\bin;D:\krhsoftware\Git\cmd;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\AppData\Roaming\Composer\vendor\bin [PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC [PROCESSOR_ARCHITECTURE] => AMD64 [PROCESSOR_IDENTIFIER] => Intel64 Family 6 Model 158 Stepping 10, GenuineIntel [PROCESSOR_LEVEL] => 6 [PROCESSOR_REVISION] => 9e0a [ProgramData] => C:\ProgramData [ProgramFiles] => C:\Program Files [ProgramFiles(x86)] => C:\Program Files (x86) [ProgramW6432] => C:\Program Files [PSModulePath] => C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules [PUBLIC] => C:\Users\Public [SESSIONNAME] => Console [SystemDrive] => C: [SystemRoot] => C:\Windows [TEMP] => C:\Users\ADMINI~1\AppData\Local\Temp [TMP] => C:\Users\ADMINI~1\AppData\Local\Temp [USERDOMAIN] => USER-20230417GP [USERDOMAIN_ROAMINGPROFILE] => USER-20230417GP [USERNAME] => Administrator [USERPROFILE] => C:\Users\Administrator [windir] => C:\Windows [HTTP_COOKIE] => thinkphp_show_page_trace=0|0; thinkphp_show_page_trace=0|0; PHPSESSID=42ebce2914dea21a3b2a6408724e3b03; thinkphp_show_page_trace=0|0; web_token=74a57df797654a2f56951be092c992e1; user_uuid=20221111111111000001 [HTTP_ACCEPT_LANGUAGE] => zh-CN,zh;q=0.9 [HTTP_ACCEPT_ENCODING] => gzip, deflate [HTTP_REFERER] => http://local.huizhan.com/backend/business.register/index [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7 [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 [HTTP_UPGRADE_INSECURE_REQUESTS] => 1 [HTTP_CACHE_CONTROL] => max-age=0 [HTTP_CONNECTION] => keep-alive [HTTP_HOST] => local.huizhan.com [REDIRECT_STATUS] => 200 [SERVER_NAME] => local.huizhan.com [SERVER_PORT] => 80 [SERVER_ADDR] => 127.0.0.1 [REMOTE_PORT] => 61008 [REMOTE_ADDR] => 127.0.0.1 [SERVER_SOFTWARE] => nginx/1.15.11 [GATEWAY_INTERFACE] => CGI/1.1 [REQUEST_SCHEME] => http [SERVER_PROTOCOL] => HTTP/1.1 [DOCUMENT_ROOT] => E:/krhwork/phpstudy_pro/WWW/thinkphp/huizhan/public [DOCUMENT_URI] => /index.php [REQUEST_URI] => /backend/business.register/index [SCRIPT_NAME] => /index.php [CONTENT_LENGTH] => [CONTENT_TYPE] => [REQUEST_METHOD] => GET [QUERY_STRING] => s=//backend/business.register/index [PATH_TRANSLATED] => E:/krhwork/phpstudy_pro/WWW/thinkphp/huizhan/public [PATH_INFO] => [SCRIPT_FILENAME] => E:/krhwork/phpstudy_pro/WWW/thinkphp/huizhan/public/index.php [FCGI_ROLE] => RESPONDER [PHP_SELF] => /index.php [REQUEST_TIME_FLOAT] => 1689236577.974 [REQUEST_TIME] => 1689236577 )
2023年07月13日
154 阅读
0 评论
0 点赞
2023-06-09
【PHP】PHP实现二维数组转一维数组
可以使用 array_reduce() 函数将二维数组转换为一维数组。array_reduce() 函数将通过一个回调函数迭代数组中的所有值,并将它们合并为一个单一的值。在这种情况下,我们将使用 array_merge() 函数将所有子数组合并为一个单一的数组。示例代码如下:function flatten_array($arr) { return array_reduce($arr, function($carry, $item) { return array_merge($carry, is_array($item) ? flatten_array($item) : array($item)); }, array()); } // 测试 $arr = array( array(1, 2, 3), array(4, 5, 6), array( array(7, 8), 9, array(10, 11, 12), ), ); $result = flatten_array($arr); print_r($result); // 输出: // Array // ( // [0] => 1 // [1] => 2 // [2] => 3 // [3] => 4 // [4] => 5 // [5] => 6 // [6] => 7 // [7] => 8 // [8] => 9 // [9] => 10 // [10] => 11 // [11] => 12 // )在上面的示例代码中,我们定义了一个 flatten_array() 函数,该函数使用 array_reduce() 函数和递归调用来将二维数组转换为一维数组。
2023年06月09日
299 阅读
0 评论
0 点赞
2023-05-22
【Layui】控制页面元素展示隐藏
页面打开监听 layer.ready(function () { $(".integralnum").show(); $(".jichugoods").hide(); });
2023年05月22日
858 阅读
4 评论
0 点赞
2023-05-10
【Layui】layui点击输入框选择时间,时间控件闪烁或消失
解决办法:在render的时候添加 ,trigger: 'click' 属性 来解决.laydate.render({ elem: '#issueDate_id' ,type: 'datetime' ,trigger: 'click' //自动弹出控件的事件,采用click弹出 ,可以解决控件点击闪烁的问题 });
2023年05月10日
255 阅读
0 评论
0 点赞
1
2
...
11