gq 7 anni fa
parent
commit
bc3f91d1e3

+ 42 - 26
server/app/Http/Controllers/Admin/Dream/InfoController.php

xqd xqd xqd
@@ -152,6 +152,7 @@ class InfoController extends Controller
             $arr[] = $pic['pic'];
         }
         $data->imgs = $arr;
+//        dd($data);
         $data['sign'] = explode(',',$data['sign']);
         $signs = BaseSettingsModel::where('category','sign')->orderBy('id')->get();
         return view('admin.dream.info.edit',compact('data','signs'));
@@ -193,35 +194,50 @@ class InfoController extends Controller
             $data['score'] = (log($care_num) + ($a/$t) + $b)*100000000 ;
         }
         $pics = (array) request('pic');
-        if (empty($pics)) {
-            $url[] = array('url'=>U( 'Dream/Info/index'),'title'=>'返回列表');
-            return $this->showWarning('请添加图片',$url);
+        if (request("file")) {
+            $file = request("file");
+            $fileSize = $file->getSize();
+            $size =  200 * 1024 * 1024;
+            if ($fileSize > $size) {
+                return back()->with('error','请上传小于200 MB的文件!');
+            }
+            $mimeType = [
+                'video/mp4',
+            ];
+            $fileMimeType = $file->getMimeType();
+            if (!empty($mimeType) && !in_array($fileMimeType, $mimeType)) {
+                return back()->with('error','File type allow MP4!');
+            }
+            if (!$file = VideoUpload::mvFile('file')) return back()->with('error','上传失败');
+            $data["video"] = $file;
         }
-        $old_data_pics =  $this->repository->find(request('id'))->imgs->toArray();
-        $old_pics = array_column($old_data_pics,'pic');
-        $a = array_diff($pics['url'],$old_pics);
-        $b = array_diff($old_pics,$pics['url']);
-        if (!empty($a) || !empty($b)) {       //有图片变化执行
-            //        删除以前图片 重新插入
-            if (!empty($b)) {
-                foreach ($b as $old_pic){
-                    if (is_file('.'.str_replace(getenv('APP_URL'),'',$old_pic))) {
-                        unlink('.'.str_replace(getenv('APP_URL'),'',$old_pic));
+        if (!empty($pics)) {
+            $old_data_pics =  $this->repository->find(request('id'))->imgs->toArray();
+            $old_pics = array_column($old_data_pics,'pic');
+            $a = array_diff($pics['url'],$old_pics);
+            $b = array_diff($old_pics,$pics['url']);
+            if (!empty($a) || !empty($b)) {       //有图片变化执行
+                //        删除以前图片 重新插入
+                if (!empty($b)) {
+                    foreach ($b as $old_pic){
+                        if (is_file('.'.str_replace(getenv('APP_URL'),'',$old_pic))) {
+                            unlink('.'.str_replace(getenv('APP_URL'),'',$old_pic));
+                        }
+                        BaseAttachmentModel::where('url',$old_pic)->delete();
+                        DreamImages::where('pic',$old_pic)->delete();
                     }
-                    BaseAttachmentModel::where('url',$old_pic)->delete();
-                    DreamImages::where('pic',$old_pic)->delete();
                 }
+                $arr = [];                         //插入新的图片
+                foreach ($a as $pic) {
+                    $arr[] = [
+                        'pic'=>getenv('APP_URL').$pic,
+                        'dream_id'=>request('id'),
+                        'created_at'=>date('Y-m-d H:i:s'),
+                        'updated_at'=>date('Y-m-d H:i:s'),
+                    ];
+                }
+                DreamImages::insert($arr);
             }
-            $arr = [];                         //插入新的图片
-            foreach ($a as $pic) {
-                $arr[] = [
-                    'pic'=>getenv('APP_URL').$pic,
-                    'dream_id'=>request('id'),
-                    'created_at'=>date('Y-m-d H:i:s'),
-                    'updated_at'=>date('Y-m-d H:i:s'),
-                ];
-            }
-            DreamImages::insert($arr);
         }
         $ok = $this->repository->update(request('id'),$data);
         if ($data['status'] == 1) {   //审核通过
@@ -233,7 +249,7 @@ class InfoController extends Controller
             SystemInfoModel::create($info);
 
 //            长连接
-            $this->jPush($message,'',$data['user_id']);
+//            $this->jPush($message,'',$data['user_id']);
         }
         if($ok) {
             $url[] = array('url'=>U( 'Dream/Info/index'),'title'=>'返回列表');

+ 2 - 1
server/app/Http/Controllers/Api/V1/MyController.php

xqd xqd
@@ -273,6 +273,7 @@ class MyController extends Controller
         if (count($data2) > 0) {
             if (count($data2) >= 5) {
                 $data2[0]['message'] = "已经有".count($data2)."个人收藏了你的梦想!";
+                $data2[0]['is_url'] = 1;
                 $new_data2[] = $data2[0];
             }else{
                 $new_data2 = $data2;
@@ -351,7 +352,7 @@ class MyController extends Controller
                         "is_max" => 0,
                         "is_ok" => 0,
                         "is_end" => 0,
-                        "is_url" => 0,
+                        "is_url" => 1,
                         "type_id" => 2,
                     ];
                 }

+ 2 - 2
server/resources/views/admin/dream/info/edit.blade.php

xqd xqd
@@ -72,7 +72,7 @@
 
                     <div class="col-sm-9">
                         @foreach(dict()->get('global','bool') as $key => $val)
-                            <input type="radio" class="is_video" value="{{$key}}" name="" {{ !empty($data) && $data['is_video'] == $key ? 'checked' : '' }}>{{$val}}
+                            <input type="radio" class="is_video" name="type_id" value="{{$key}}" name="" {{ !empty($data) && $data['is_video'] == $key ? 'checked' : '' }}>{{$val}}
                         @endforeach
                     </div>
                 </div>
@@ -219,7 +219,7 @@
         });
     </script>
     <script>
-        if ($('input:radio[name="data[type_id]"]:checked').val() == 1) {
+        if ($('input:radio[name="type_id"]:checked').val() == 1) {
             $('#is_video').show();
             $('#data_media').hide();
         }else{