Browse Source

fix:数据

super-yimizi 3 weeks ago
parent
commit
c1e5e9229e

+ 26 - 1
application/common/model/BodyProfile.php

@@ -113,6 +113,31 @@ class BodyProfile extends Model
     }
     }
 
 
     /**
     /**
+     * 获取身体照片数组(带CDN处理)
+     */
+    public function getBodyPhotosAttr($value, $data)
+    {
+        if (empty($data['body_photos'])) {
+            return [
+                'front' => '',
+                'side' => '',
+                'back' => ''
+            ];
+        }
+        
+        $photos = json_decode($data['body_photos'], true);
+        if (is_array($photos)) {
+            foreach ($photos as $key => &$photo) {
+                if (!empty($photo)) {
+                    $photo = cdnurl($photo, true);
+                }
+            }
+        }
+        
+        return $photos;
+    }
+
+    /**
      * 设置身体照片
      * 设置身体照片
      */
      */
     public function setBodyPhotosAttr($value)
     public function setBodyPhotosAttr($value)
@@ -138,7 +163,7 @@ class BodyProfile extends Model
             $profile['body_types'][$selection['type_category']] = [
             $profile['body_types'][$selection['type_category']] = [
                 'type_id' => $selection['selected_type_id'],
                 'type_id' => $selection['selected_type_id'],
                 'type_name' => $selection->typeConfig ? $selection->typeConfig['type_name'] : '',
                 'type_name' => $selection->typeConfig ? $selection->typeConfig['type_name'] : '',
-                'type_image' => $selection->typeConfig ? $selection->typeConfig['type_image'] : ''
+                'type_image' => $selection->typeConfig ? cdnurl($selection->typeConfig['type_image'], true) : ''
             ];
             ];
         }
         }
         
         

+ 12 - 6
application/common/model/BodyTypeConfig.php

@@ -39,7 +39,7 @@ class BodyTypeConfig extends Model
     }
     }
 
 
     /**
     /**
-     * 获取完整图片URL
+     * 获取完整图片URL(带CDN处理)
      */
      */
     public function getFullImageUrlAttr($value, $data)
     public function getFullImageUrlAttr($value, $data)
     {
     {
@@ -47,13 +47,19 @@ class BodyTypeConfig extends Model
             return '';
             return '';
         }
         }
         
         
-        // 如果已经是完整URL,直接返回
-        if (strpos($data['type_image'], 'http') === 0) {
-            return $data['type_image'];
+        return cdnurl($data['type_image'], true);
+    }
+
+    /**
+     * 获取类型图片(带CDN处理)
+     */
+    public function getTypeImageAttr($value, $data)
+    {
+        if (empty($data['type_image'])) {
+            return '';
         }
         }
         
         
-        // 拼接完整URL
-        return request()->domain() . $data['type_image'];
+        return cdnurl($data['type_image'], true);
     }
     }
 
 
     /**
     /**