Kaynağa Gözat

Wesmiler 校企小程序 更新 6.14

wesmiler 3 yıl önce
ebeveyn
işleme
fac0b3639a

+ 4 - 0
app/api/model/SchoolSpeciality.php

@@ -135,6 +135,10 @@ class SchoolSpeciality extends SchoolSpecialityModel
             throwError('很抱歉,当前数据不存在');
         }
 
+        $datas = $detail['speciality_logo']? [getPreview($detail['speciality_logo'])] : [];
+        $albums = isset($detail['albums'])? $detail['albums'] : [];
+        $detail['albums'] = array_merge($datas, $albums);
+
         // 累积阅读数
         static::setIncViews($id);
         return (new SchoolSpeciality)->setDataFromApi($detail);

+ 5 - 3
app/common/model/SchoolSpeciality.php

@@ -152,8 +152,10 @@ class SchoolSpeciality extends BaseModel
      * @param $value
      * @return false|string[]
      */
-    public function getAlbumsAttr($value, $data){
-        $datas = $data['speciality_logo']? [$data['speciality_logo']] : [];
+    public function getAlbumsAttr($value){
+        if(is_array($value)){
+            return $value;
+        }
         $albums = $value? explode(',', $value):[];
         if($albums){
             foreach ($albums as &$v){
@@ -161,7 +163,7 @@ class SchoolSpeciality extends BaseModel
             }
         }
 
-        return array_merge($datas, $albums);
+        return $albums;
     }
 
     /**