where('receve_id',Session::get('user_id'))->where(['is_read'=>0,'delete_time'=>0])->select(); $count = $msg->count(); if($count){ $res=['status' =>0,'count' => $count, 'msg' => 'nums']; } else { $res=['status' =>0,'count' => 0, 'msg' => $count]; } return json($res); } //消息查询 public function find() { $uid = Session::get('user_id'); $msg = MessageApi::receveMsg($uid); $count = $msg->count(); $res = []; if($count){ $res = ['status'=>0,'msg'=>'','count'=>$count]; foreach ($msg as $k => $v){ $data = ['id'=>$v['id'],'name'=>$v['name'],'content'=>$v['title'],'time'=>date("Y-m-d H:i",$v['create_time']),'link'=>$v['link'],'read'=>$v['is_read'] ? '已读':'未读']; $res['rows'][] = $data; } } else { $res = ['status'=>0,'msg'=>'','rows'=>''];; } return json($res); } //读消息 public function read() { $id =input('id'); $msg = Db::name('message_to')->where('id',$id)->save(['is_read'=>1]); $res=['status' =>0]; return json($res); } //消息删除 public function remove() { $uid = Session::get('user_id'); $id = Request::only(['id']); if($id['id'] == 'true'){ $msg = Db::name('message_to')->where(['receve_id'=>$uid,'delete_time'=>0])->useSoftDelete('delete_time',time())->delete(); } else { $msg = Db::name('message_to')->where('id',$id['id'])->useSoftDelete('delete_time',time())->delete(); } if($msg){ $res = ['status'=>0]; } return $res; } }