소스 검색

修复调用相册的BUG

moshaorui 3 주 전
부모
커밋
ee5deac9f0
3개의 변경된 파일8개의 추가작업 그리고 4개의 파일을 삭제
  1. 1 1
      app/Admin/Controllers/ImportProductController.php
  2. 1 1
      app/Distributor/Controllers/SiteAlbumController.php
  3. 6 2
      app/Libraries/CommonHelper.php

+ 1 - 1
app/Admin/Controllers/ImportProductController.php

@@ -189,7 +189,7 @@ class ImportProductController extends AdminController
 
             $show->field('video')->as(function ($items) {
                 $items = json_decode($items);
-                return CommonHelper::displayVideo($items,'cover','video_src','150');
+                return CommonHelper::displayVideo($items,'cover','video_src','150',2);
             })->unescape();
 
             $show->field('poster')->as(function ($images) {

+ 1 - 1
app/Distributor/Controllers/SiteAlbumController.php

@@ -171,7 +171,7 @@ class SiteAlbumController extends AdminController
                     $items = json_decode($items);
                     //倒序
                     $items = array_reverse($items);
-                    return CommonHelper::displayVideo($items,'cover','video_src','150');
+                    return CommonHelper::displayVideo($items,'cover','video_src','150',2);
                 })->unescape();
             }
             //海报

+ 6 - 2
app/Libraries/CommonHelper.php

@@ -95,7 +95,7 @@ class CommonHelper
     /*
      * 显示视频
      */
-    public static function displayVideo($items,$videoCover,$videoSrc,$boxSize=150)
+    public static function displayVideo($items,$videoCover,$videoSrc,$boxSize=150,$ossSource=1)
     {
         $html = '';
         if (is_array($items)) {
@@ -103,7 +103,11 @@ class CommonHelper
                 $item = (array) $item;
                 $cover = $item[$videoCover];
                 $src = $item[$videoSrc];
-                $videoUrl = CommonHelper::ossUrl($src);
+                if ($ossSource == 1) {
+                    $videoUrl = CommonHelper::ossUrl($src);
+                } else {
+                    $videoUrl = CommonHelper::albumUrl($src);
+                }
                 $thumbnailUrl = CommonHelper::ossUrl($cover) ."?x-oss-process=image/resize,m_pad,h_{$boxSize},w_{$boxSize},color_ffffff";;
                 $html .= '<div class="video-container"><a href="#" class="playVideo" videoUrl="'.$videoUrl.'")"><img src="'.$thumbnailUrl.'" alt="Video Thumbnail"><div class="play-button"></div></a></div>';
             }