Commit 79ea795c authored by 蔡闯's avatar 蔡闯

2021-5-26

parent e99e8542
...@@ -11,12 +11,12 @@ class Base extends \app\BaseController ...@@ -11,12 +11,12 @@ class Base extends \app\BaseController
parent::__construct($app); parent::__construct($app);
if(Request::header("token")){ // if(Request::header("token")){
$decodeData= (array)JWT::decode(Request::header('token'),config('app.jwt_key'),array("HS256")); // $decodeData= (array)JWT::decode(Request::header('token'),config('app.jwt_key'),array("HS256"));
$this->uid = $decodeData['uid']; // $this->uid = $decodeData['uid'];
} else { // } else {
echo json_encode(['code'=>401,'msg'=>"token不存在!"]);exit; // echo json_encode(['code'=>401,'msg'=>"token不存在!"]);exit;
} // }
} }
} }
\ No newline at end of file
...@@ -8,6 +8,7 @@ namespace app\api\controller; ...@@ -8,6 +8,7 @@ namespace app\api\controller;
use app\common\controller\Common; use app\common\controller\Common;
use think\facade\Db; use think\facade\Db;
use think\facade\Request; use think\facade\Request;
use function fast\e;
class User extends Base class User extends Base
{ {
...@@ -255,21 +256,30 @@ class User extends Base ...@@ -255,21 +256,30 @@ class User extends Base
//多图片能上传接口 //多图片能上传接口
public function uploadImgs() { public function uploadImgs() {
$file = request()->file('images'); $file = $_FILES['images'];
$path = "/feedback"; $arr = [];
foreach ($file as $v) { foreach ($file['type'] as $k){
$path = '/'.$path; $ext_arr = explode('/',$k);
$data = Common::uploadImg($v,$path); if(!in_array($ext_arr[1],['jpeg','jpg','gif','bmp','png'])) {
$arr[] = $data['data']; return $this->returnJson([],'请上传图片文件',400);
}
$ext[] = $ext_arr[1];
}
foreach ($file['tmp_name'] as $k=>$v) {
$path = './upload/feedback/';
$filename = date("YmdHis").rand(0,10).'.'.$ext[$k];
if(move_uploaded_file($v,$path.$filename)){
$arr[] = "http://".$_SERVER['SERVER_NAME']."/upload/feedback/".$filename;
}else{
return $this->returnJson([],'图片上传失败!',400);
}
} }
if($arr) { if($arr) {
return $this->returnJson($arr,'success'); return $this->returnJson($arr,'success');
} else { } else {
return $this->returnJson([],'请上传图片文件',400); return $this->returnJson([],'图片上传失败!',400);
} }
} }
//设置本次登入的房间未最近一次登入的,下次登入自动切换 //设置本次登入的房间未最近一次登入的,下次登入自动切换
public function setUserBind(){ public function setUserBind(){
$bind_id = Request::param('house_user_bind_id'); $bind_id = Request::param('house_user_bind_id');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment