Quellcode durchsuchen

fix: 处理分享海报无法下载,小程序环境要求图片必须为https 的问题

joe vor 4 Jahren
Ursprung
Commit
2d944d5cc9
2 geänderte Dateien mit 11 neuen und 8 gelöschten Zeilen
  1. 10 7
      app/api/controller/user/UserBillController.php
  2. 1 1
      config/app.php

+ 10 - 7
app/api/controller/user/UserBillController.php

@@ -161,6 +161,7 @@ class UserBillController
             $resRoutine = true;//小程序
             $resWap = true;//公众号
             $siteUrl = sys_config('site_url');
+            // 配置的海报背景模板
             $routineSpreadBanner = sys_data('routine_spread_banner');
             if (!count($routineSpreadBanner)) {
                 return app('json')->fail('暂无海报');
@@ -195,12 +196,12 @@ class UserBillController
                 $imageInfo = SystemAttachment::getInfo($name, 'name');
                 //检测远程文件是否存在
                 // 20210722 注释掉,太卡
-                // if (isset($imageInfo['att_dir']) && 
-                //     strstr($imageInfo['att_dir'], 'http') !== false && 
-                //     curl_file_exist($imageInfo['att_dir']) === false) {
-                //     $imageInfo = null;
-                //     SystemAttachment::where(['name' => $name])->delete();
-                // }
+                if (isset($imageInfo['att_dir']) && 
+                    strstr($imageInfo['att_dir'], 'http') !== false && 
+                    curl_file_exist($imageInfo['att_dir']) === false) {
+                    $imageInfo = null;
+                    SystemAttachment::where(['name' => $name])->delete();
+                }
                 if (!$imageInfo) {
                     $res = RoutineCode::getShareCode($user['uid'], 'spread', '', '');
                     if (!$res) return app('json')->fail('二维码生成失败');
@@ -220,8 +221,10 @@ class UserBillController
                     }
                     $upload->delete($name);
                     $imageInfo = $upload->getUploadInfo();
+                    // 20210919 为了能小程序下载,这个函数上传的图片全部使用 https
+                    $httpsUrl = set_http_type($imageInfo['dir']);
                     $imageInfo['image_type'] = $uploadType;
-                    SystemAttachment::attachmentAdd(basename($imageInfo['name']), $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time'], 2);
+                    SystemAttachment::attachmentAdd(basename($imageInfo['name']), $imageInfo['size'], $imageInfo['type'], $httpsUrl, $httpsUrl, 1, $imageInfo['image_type'], $imageInfo['time'], 2);
                     RoutineQrcode::setRoutineQrcodeFind($res['id'], ['status' => 1, 'url_time' => time(), 'qrcode_url' => $imageInfo['dir']]);
                     $urlCode = $imageInfo['dir'];
                 } else {

+ 1 - 1
config/app.php

@@ -62,7 +62,7 @@ return [
     'mining_sec_unit' => 1,
     'mining_num_per_unit' => 0.01,
 
-    // 排行榜 banner 750 x 142
+    // 排行榜 banner 750 x 142 首页 banner 750x375 精品推荐滚动图 750x282
     'leader_board_banner' => 'http://twongstatic.shotshock.shop/banner_rank_750x142.jpg',
     
     'header_cs_1' => 'http://twongstatic.shotshock.shop/headers/customer_service_1.jpg',