Commit d7b7f0a5 authored by hujun's avatar hujun

经纪人登录

parent ca6ddbbf
<?php
//配置文件
error_reporting(E_ERROR | E_PARSE);
return [
'jwt_key' => 'tonglian+123',
// 应用模式状态
'app_status' => 'dev-config',
];
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: hu jun
* Date: 2018/2/8
* Time: 16:59
*/
namespace app\api_broker\controller;
use app\api\untils\JwtUntils;
use app\api_broker\extend\Basic;
use app\model\AAgents;
use think\Request;
class Broker extends Basic
{
protected $a_agents;
public function __construct(Request $request = null)
{
parent::__construct($request);
$this->a_agents = new AAgents();
}
/**
* 经纪人登录
*
* @return \think\Response
* @throws \think\exception\DbException
*/
public function login() {
$data['data'] = array();
$data['status'] = 101;
if ($this->params['phone'] && $this->params['pwd']) {
$agents_data = $this->a_agents->get([
'phone' => $this->params['phone'],
'status' => 0
]);
if (isset($agents_data->id) && ($agents_data->status == 0)) {
if ($agents_data->password == md5($this->params['pwd'])) {
$agents_data->last_login_ip = ip2long($this->request->ip());
$agents_data->last_login_time = date('Y-m-d H:i:s');
$agents_data->save();
if ($agents_data->img) {
$agents_data->img = HEADERIMGURL.$agents_data->img;
}
$jwt_data['id'] = $agents_data->id;
$jwt_data['name'] = $agents_data->name;
$jwt_data['phone'] = $agents_data->phone;
$jwt_data['level'] = $agents_data->level;
$jwt = new JwtUntils();
$data['data'] = $agents_data->getData();
$data['data']['last_login_ip'] = long2ip($data['data']['last_login_ip']);
$data['data']['AuthToken'] = $jwt->createToken($jwt_data);
$data['msg'] = '登陆成功';
$data['status'] = 200;
} else {
$data['msg'] = '密码错误';
}
} else {
$data['msg'] = '没有该用户';
}
} else {
$data['msg'] = '用户名或密码为空';
}
return $this->response($data['status'], $data['msg'],$data['data']);
}
}
\ No newline at end of file
...@@ -213,6 +213,7 @@ Route::group('broker', [ ...@@ -213,6 +213,7 @@ Route::group('broker', [
'refund' => [ 'api_broker/OrderLog/refund', [ 'method' => 'get|post' ] ], 'refund' => [ 'api_broker/OrderLog/refund', [ 'method' => 'get|post' ] ],
'bargain' => [ 'api_broker/OrderLog/bargain', [ 'method' => 'get|post' ] ], 'bargain' => [ 'api_broker/OrderLog/bargain', [ 'method' => 'get|post' ] ],
'statusBargain' => [ 'api_broker/OrderLog/statusBargain', [ 'method' => 'get|post' ] ], 'statusBargain' => [ 'api_broker/OrderLog/statusBargain', [ 'method' => 'get|post' ] ],
'login' => [ 'api_broker/Broker/login', [ 'method' => 'get' ] ],
]); ]);
//Route::miss('api/index/miss');//处理错误的url //Route::miss('api/index/miss');//处理错误的url
\ No newline at end of file
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