From 140ded75b690a84079804db2d5f38bc6d7df6973 Mon Sep 17 00:00:00 2001 From: wang hou sheng <76928547+wanghousheng@users.noreply.github.com> Date: Wed, 10 Apr 2024 00:05:28 +0800 Subject: [PATCH] 1 --- app/common/library/wxserver/Server.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/common/library/wxserver/Server.php b/app/common/library/wxserver/Server.php index 341318c3..5acd3761 100644 --- a/app/common/library/wxserver/Server.php +++ b/app/common/library/wxserver/Server.php @@ -5,6 +5,7 @@ namespace app\common\library\wxserver; use app\common\model\WxserverAccount; use cores\exception\BaseException; +use Qiniu\Http\Client; use think\db\exception\DataNotFoundException; use think\db\exception\DbException; use think\db\exception\ModelNotFoundException; @@ -136,24 +137,27 @@ class Server */ public function getQrcode($appid) { + $savePath = root_path() . "public/wxserve/experience"; + !is_dir($savePath) && mkdir($savePath, 0755, true); + $savePath .= '/' . $appid . '.jpg'; + if (file_exists($savePath)) { + return '/wxserve/experience/' . $appid . '.jpg?time=' . time(); + } $model = new WxserverAccount(); $info = $model->where(['appid' => $appid])->find(); if (!empty($info)) { $info = $info->toArray(); $access_token = $this->authorizerAccessToken($appid, $info['refresh_token']); if ($access_token) { - $savePath = root_path() . "public/wxserve/experience"; - !is_dir($savePath) && mkdir($savePath, 0755, true); - $savePath .= '/' . $appid . '.jpg'; //Client $url = 'https://api.weixin.qq.com/wxa/get_qrcode?access_token=' . $access_token; - $client = new \Qiniu\Http\Client(); + $client = new Client(); $response = $client->get($url); $res = $response->body(); if ($res) { $newFile = fopen($savePath, "a"); fwrite($newFile, $res); fclose($newFile); - return '/wxserve/experience/' . $appid . '.jpg'; + return '/wxserve/experience/' . $appid . '.jpg?time=' . time(); } } } @@ -195,7 +199,7 @@ class Server } $data['template_id'] = $template_id; $data['user_version'] = $version; - $data['user_desc'] = $desc; + $data['user_desc'] = urlencode($desc); $ext_json['extAppid'] = $appid; $ext_json['ext']['store_id'] = $info['store_id']; $ext_json['window'] = [];