Parcourir la source

Merge branch 'gq' of http://git.9026.com/roobe/miao

Mike il y a 7 ans
Parent
commit
77d317b5f0

+ 72 - 6
server/app/Http/Controllers/Admin/Interaction/InfoController.php

xqd xqd xqd xqd
@@ -16,7 +16,9 @@ class InfoController extends Controller
     public function view(Request $request)
     {
         $dream_id = $request->id;
-        $dream = DreamInfoModel::where('id',$request->id)->with('interactions')->first();
+        $dream = DreamInfoModel::where('id',$request->id)->with(['interactions'=> function ($query) {
+            $query->orderBy('id','desc');
+        }])->first();
         $list = $dream->interactions;
         foreach ($list as $item){
             $comments = CommentInfoModel::where('interaction_id',$item->id)->orderBy('created_at')->get();
@@ -101,6 +103,12 @@ class InfoController extends Controller
             }
         }
         $data->imgs = $arr;
+        if (empty($data->video)) {
+            $data->is_video = 0;
+        }else{
+            $data->is_video = 1;
+
+        }
         return view('admin.interaction.info.edit',compact('data'));
     }
 
@@ -135,16 +143,50 @@ class InfoController extends Controller
             }
 
             $a = array_values($a);
+            $c = -1;
             for ($i = 1; $i <=9; $i++) {
                 if (empty($interaction['pic'.($i)])) {
-                    $c = -1;
                     $c++;
-                    $interaction['pic'.($i)] = getenv('APP_URL').$a[$c];
+                    if (array_key_exists($c,$a)) {
+                        $interaction['pic'.($i)] = getenv('APP_URL').$a[$c];
+                    }
+
                 }
             }
-
         }
-        $ok = InteractionInfo::find(request('id'))->update($interaction);
+        if (!empty(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','上传失败');
+            $interaction["video"] = $file;
+        }else{
+//            更新是视频不存在则删除
+            $info = InteractionInfo::find(request('id'));
+            if (is_file('.'.str_replace(getenv('APP_URL'),'',$info->video))) {
+                unlink('.'.str_replace(getenv('APP_URL'),'',$info->video));
+            }
+//            $info->update(['video'=>'']);
+            $info->video = null;
+            $info->save();
+//            dd($info);
+        }
+        if (empty(request("file"))) {
+            $ok = InteractionInfo::find(request('id'))->update($interaction);
+        }else{
+            InteractionInfo::find(request('id'))->update($interaction);
+            $ok=1;
+        }
         if($ok) {
             $url[] = array('url'=>U( 'Interaction/Info/index'),'title'=>'返回列表');
             return $this->showMessage('操作成功',urldecode(request('_referer')));
@@ -159,7 +201,31 @@ class InfoController extends Controller
      */
     public function destroy(Request $reqeust)
     {
-
+        //        删除动态的图片 视频 评论...
+        $data = InteractionInfo::find($reqeust->get('id'));
+        $arr = [];
+        for ($i = 1; $i <=9; $i++) {
+            if (!empty($data['pic'.($i)])) {
+                $arr[] = $data['pic'.($i)];
+            }
+        }
+//        删除图片
+        if (!empty($arr)) {
+            foreach ($arr 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();
+            }
+        }
+//        删除视频
+        if (!empty($data->video)) {
+            if (is_file('.'.str_replace(getenv('APP_URL'),'',$data->video))) {
+                unlink('.'.str_replace(getenv('APP_URL'),'',$data->video));
+            }
+        }
+//        删除评论
+        CommentInfoModel::where('interaction_id',$reqeust->get('id'))->delete();
         $ok = InteractionInfo::destroy($reqeust->get('id'));
         if ($ok) {
             return $this->showMessage('操作成功');

+ 10 - 2
server/app/Http/Controllers/Api/V1/AuthController.php

xqd xqd
@@ -113,7 +113,15 @@ class AuthController extends Controller
         }else{
             $phone_user = UserInfoModel::where('phone',$phone)->first();
             if(!empty($phone_user)){
-                return $this->error(ErrorCode::USER_DOES_EXIST);
+//                return $this->error(ErrorCode::USER_DOES_EXIST);
+                if (Auth::attempt(['phone'=>$phone,'password'=>$password])) {
+                    $user = Auth::user();
+                    \Log::info($user);
+                    $token = $user->createToken($user->phone)->accessToken;
+                    return $this->api(compact( 'user', 'code','token'));
+                }else{
+                    return $this->error(ErrorCode::INCORRECT_USER_OR_PASS);
+                }
             }
         }
         if (empty($user)) {
@@ -310,7 +318,7 @@ class AuthController extends Controller
         $keyexist = $this->keySmsCodeExist . $phone;
         $times = Cache::store('file')->get($keyexist);
 
-        if($times>20) {
+        if($times>40) {
             return $this->error(ErrorCode::VERIFY_CODE_TOO_MUCH);
         }else{
             $times++;

+ 3 - 0
server/app/Http/Controllers/Api/V1/DreamController.php

xqd xqd xqd
@@ -16,6 +16,7 @@ use App\Models\UserCareUser;
 use App\Models\UserInfoModel;
 use Illuminate\Http\Request;
 use App\Services\Base\ErrorCode;
+use Illuminate\Support\Facades\Log;
 
 class DreamController extends Controller
 {
@@ -440,6 +441,7 @@ class DreamController extends Controller
             $dream->mark += $coin*$number;
             $dream->save();
 //            在支持梦想时 如果梦主排名配取代时发送系统消息
+            dd($old_top_user_id);
             $this->systemInfo($dream->id,$user->id,$old_top_user_id);
 
 
@@ -546,6 +548,7 @@ class DreamController extends Controller
         }else{
             $top_user_id = $old_top_user_id;
         }
+        Log::info('-----------'.$top_user_id.'-----------'.$old_top_user_id.'-----------');
         if ($top_user_id != $old_top_user_id) {   //新的最大支持者不是以前的最大支持者时
             $arr = [
                 'user_id'=>0,

+ 3 - 0
server/app/Http/Controllers/Api/V1/MyController.php

xqd xqd xqd
@@ -264,6 +264,7 @@ class MyController extends Controller
             if (count($data1) >= 5) {
                 $data1[0]['message'] = "已经有".count($data1)."个人支持了你的梦想!";
                 $data2[0]['is_url'] = 1;
+                $data2[0]['is_reply'] = 0;
                 $new_data1[] = $data1[0];
             }else{
                 $new_data1 = $data1;
@@ -275,6 +276,7 @@ class MyController extends Controller
             if (count($data2) >= 5) {
                 $data2[0]['message'] = "已经有".count($data2)."个人收藏了你的梦想!";
                 $data2[0]['is_url'] = 1;
+                $data2[0]['is_reply'] = 0;
                 $new_data2[] = $data2[0];
             }else{
                 $new_data2 = $data2;
@@ -286,6 +288,7 @@ class MyController extends Controller
             if (count($data3) >= 5) {
                 $data3[0]['message'] = "你的互动已经有".count($data3)."个留言啦!快点击看看!";
                 $data2[0]['is_url'] = 1;
+                $data2[0]['is_reply'] = 0;
                 $new_data3[] = $data3[0];
             }else{
                 $new_data3 = $data3;

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

xqd xqd
@@ -64,7 +64,7 @@
                                             @endif>
                                         <label class="control-label col-sm-3" >&nbsp;</label>
                                         <div class="col-sm-9" style="width: 50%;height: 50%">
-                                            <video style="width: 300px" src="{{ $data['video'] or ''}}" poster="{{ $data['poster'] or ''}}" controls >
+                                            <video style="width: 300px" src="{{ $data['video'] or ''}}" controls >
                                             </video>
                                         </div>
                                     </div>
@@ -115,7 +115,7 @@
 @endsection
 @section('footer')
     <script>
-        if ($('input:radio[name="data[type_id]"]:checked').val() == 1) {
+        if ($('input:radio[name="data[is_video]"]:checked').val() == 1) {
             $('#is_video').show();
             $('#data_media').hide();
         }else{