Commit 5fa70bbe authored by clone's avatar clone Committed by hujun

上传图片

parent 05eb5d3e
......@@ -96,16 +96,6 @@ class AppChat extends Basic
}
}
/**
* c端根据经纪人的手机号获取唯一id
* @return \think\Response
*/
public function getAgentOnlyId()
{
//todo
return $this->response("200", "success", "");
}
/**
* 获取经纪人或用户的信息
......@@ -200,9 +190,39 @@ class AppChat extends Basic
$msgModel = new ChatMsg();
$history_result = $msgModel->getChatHistory($params, $field, $page_no, $page_size);
if ($history_result) {
return $this->response("200", "request success", array_reverse($history_result));
return $this->response("200", "request success", array_reverse($history_result));
}
/**
* 上传聊天图片
* @return \think\Response
*/
public function uploadImg()
{
$file = request()->file('image');
$data = [];
if ($file) {
$path = ROOT_PATH . 'public' . DS . 'static' . DS . 'chat_image';
$info = $file->validate([ 'size' => 512000, 'ext' => 'jpg,png' ])//限制500KB
->move($path);
if ($info) {
$img_path = $info->getSaveName(); //生成的图片路径
$static_path = $path . DS . $img_path; //生成图片的绝对路径
$image = \think\Image::open($static_path);
$image->thumb(500, 500)->save($static_path); //生成缩略图
$data = [ 'file_name' => HEADERIMGURL . $img_path ];
} else {
// 上传失败获取错误信息
return $this->response("101", $file->getError());
}
} else {
return $this->response("101", "没有该文件");
}
return $this->response("200", "request success", $data);
}
......
......@@ -95,7 +95,7 @@ class ChatService
$where_["id"] = $userId;
$agentsResult = $this->agentsModel->getAgentsById("id", $where_);
if ($agentsResult -> id > 0)
if ($agentsResult->id > 0)
$onlyId = self::SOURCE_TYPE_AGENT . $userId;
break;
case 2:
......@@ -227,6 +227,7 @@ class ChatService
}
return $info;
}
/**
* 保存用户发送的消息
......
......@@ -2,4 +2,4 @@
# http://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
a1.easemob.com FALSE / FALSE 1516860430 rememberMe deleteMe
a1.easemob.com FALSE / FALSE 1516861121 rememberMe deleteMe
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