Commit ddfd31cb authored by hujun's avatar hujun

修改密码和头像上传

parent eda66d39
......@@ -78,6 +78,9 @@ class Broker extends Basic
* 获取经纪人列表
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getBroker() {
$data['status'] = 200;
......@@ -109,6 +112,7 @@ class Broker extends Basic
/**
* 新增-客户电话跟进
*
* @return \think\Response
*/
public function add_phone_follow_up()
......@@ -142,11 +146,13 @@ class Broker extends Basic
}
}
/**
* 客户搜索
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function user_search()
{
......@@ -199,10 +205,13 @@ class Broker extends Basic
}
}
/**
* 客户动态展示加搜索加客户详情
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function useraction_search()
{
......@@ -264,4 +273,75 @@ class Broker extends Basic
return $this->response("101", "失败!");
}
}
/**
* 编辑密码
*/
public function editAgent() {
$data['code'] = 200;
$data['msg'] = "";
$data['data'] = [];
if ($this->params['pwd'] || $this->params['old_pwd']) {
$agents = new AAgents();
$result = $agents->editPwd($this->userId, $this->params['pwd'], $this->params['old_pwd']);
if (!$result) {
$data['code'] = 101;
$data['msg'] = 'change failed';
}
} else {
$data['code'] = 101;
$data['msg'] = 'pwd or old_pwd is null';
}
return $this->response($data['code'], $data['msg'], $data['data']);
}
/**
* 上传头像
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function uploadHeadImg() {
$data['status'] = 101;
$data['msg'] = '';
$data['data'] = '';
$file = request()->file('image');
if($file){
$path = ROOT_PATH . 'public' . DS . 'static'. DS . 'agent_head_portrait';
$info = $file->validate(['size'=>512000,'ext'=>'jpg,png']) //限制500KB
->move($path);
if($info){
if ($this->userId) {
$user = new AAgents();
$user_data = $user->field('img')->where('id',$this->userId)->find();
@unlink($path.DS.$user_data->img); //删除原来的图片
$img_path = $info->getSaveName(); //生成的图片路径
//更新用户信息
$user_data->img = $img_path;
$user_data->save();
$static_path = $path.DS.$img_path; //生成图片的绝对路径
$image = \think\Image::open($static_path);
$image->thumb(500, 500)->save($static_path); //生成缩略图
$data['status'] = 200;
$data['msg'] = '上传成功';
$data['data'] = ['file_name' => HEADERIMGURL . $img_path];
}
}else{
// 上传失败获取错误信息
$data['msg'] = $file->getError();
}
} else {
$data['msg'] = '没有该文件';
}
return $this->response($data['status'], $data['msg'], $data['data']);
}
}
\ No newline at end of file
......@@ -209,9 +209,13 @@ public function saveList(){
/**
* 获取经纪人
* @param $field
*
* @param string $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAgentById($field = "id",$params){
$where_ = [];
......@@ -224,7 +228,23 @@ public function saveList(){
->select();
}
/**
* 修改密码
*
* @param $id
* @param $pwd
* @param $old_pwd
* @return bool|false|int
*/
public function editPwd($id, $pwd, $old_pwd) {
$field_pwd = $this->where('id',$id)->value('password');
if ($field_pwd == md5($old_pwd)) {
$result = $this->save(['password'=>md5($pwd)],['id'=>$id]);
} else {
$result = false;
}
return $result;
}
}
\ No newline at end of file
......@@ -233,6 +233,8 @@ Route::group('broker', [
'bargain' => [ 'api_broker/OrderLog/bargain', [ 'method' => 'get|post' ] ],
'statusBargain' => [ 'api_broker/OrderLog/statusBargain', [ 'method' => 'get|post' ] ],
'login' => [ 'api_broker/Broker/login', [ 'method' => 'post' ] ], //经纪人登陆
'editAgent' => [ 'api_broker/Broker/editAgent', [ 'method' => 'post' ] ], //经纪人修改密码
'uploadHeadImg' => [ 'api_broker/Broker/uploadHeadImg', [ 'method' => 'post' ] ], //经纪人上传头像
'editClient' => [ 'api_broker/Client/editClient', [ 'method' => 'get|post' ] ],//添加和编辑客户
'getBroker' => [ 'api_broker/broker/getBroker',['method'=>'get']],//获取经纪人列表
'labelEdit' => [ 'api_broker/label/index',['method'=>'get|post']], //编辑标签
......
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