...
|
...
|
@@ -9,6 +9,7 @@ |
|
|
namespace api\portal\controller;
|
|
|
|
|
|
|
|
|
use api\portal\model\CodeModel;
|
|
|
use api\portal\model\MemberModel;
|
|
|
use api\portal\model\PortalPostModel;
|
|
|
use cmf\controller\RestBaseController;
|
...
|
...
|
@@ -52,7 +53,7 @@ class UserController extends CommonController |
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 获取短信验证码(用户注册/中介注册)
|
|
|
* @title 获取短信验证码(sure1)
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/getSmsResult
|
...
|
...
|
@@ -61,11 +62,17 @@ class UserController extends CommonController |
|
|
* @param name:imgCode type:int require:1 default: other:genre=2时传 desc:图片验证码
|
|
|
* @param name:genre type:int require:1 default: other: desc:类型(1->用户注册/中介注册,2->密码找回,3->发布需求,4->修改手机号,5->绑定银行卡)
|
|
|
* @param name:connect type:int require:1 default: other:1 登录注册 ,2其他 desc:1
|
|
|
* @param name:token type:int require:1 default: other: desc:token
|
|
|
*/
|
|
|
// 获取短信验证码(登录)
|
|
|
public function getSmsResult(Request $request){
|
|
|
// 短信验证码
|
|
|
// 查询以前发过的验证码,并删除
|
|
|
$data = $request->param();
|
|
|
$where_isDouble['status'] = 1;
|
|
|
$where_isDouble['type'] = $data['genre'];
|
|
|
$where_isDouble['tel'] = $data['tel'];
|
|
|
$updateDouble['status'] = 9;
|
|
|
$updateD = Db::name('Code')->where($where_isDouble)->update($updateDouble);
|
|
|
if(!$request->param('tel')){
|
|
|
$this->apiResponse('0','请输入手机号');
|
|
|
}else{
|
...
|
...
|
@@ -110,7 +117,7 @@ class UserController extends CommonController |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 用户注册
|
|
|
* @title 用户注册(sure)
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/join
|
...
|
...
|
@@ -126,6 +133,7 @@ class UserController extends CommonController |
|
|
public function join(Request $request)
|
|
|
{
|
|
|
if($request->Post() && $request->Post('name')) {
|
|
|
Db::startTrans();
|
|
|
// 验证
|
|
|
$validate = Loader::validate('User');
|
|
|
if (!$validate->scene('user')->check($_POST)) {
|
...
|
...
|
@@ -135,6 +143,7 @@ class UserController extends CommonController |
|
|
$sure_password = $this->md5($_POST['sure_password']);
|
|
|
// 确认密码
|
|
|
if ($data['password'] != $sure_password) {
|
|
|
Db::rollback();
|
|
|
$this->apiResponse('0', '两次密码不一致');
|
|
|
}
|
|
|
|
...
|
...
|
@@ -146,12 +155,15 @@ class UserController extends CommonController |
|
|
$where_code['create_time'] = array('lt',(time()+300));
|
|
|
$find_code = Db::name('Code')->where($where_code)->order('create_time desc')->field('code')->find();
|
|
|
if(!$find_code){
|
|
|
Db::rollback();
|
|
|
$this->apiResponse('0','验证码错误,请重新获取1');
|
|
|
}
|
|
|
if($code != $find_code['code']){
|
|
|
Db::rollback();
|
|
|
$this->apiResponse('0','验证码错误,请重新获取');
|
|
|
}else{
|
|
|
Db::name('Code')->where($where_code)->delete();
|
|
|
$updateCode['status'] = 9;
|
|
|
Db::name('Code')->where($where_code)->update($updateCode);
|
|
|
}
|
|
|
|
|
|
$data['name'] = $_POST['name'];
|
...
|
...
|
@@ -168,6 +180,7 @@ class UserController extends CommonController |
|
|
$data['type'] = 1;
|
|
|
$data['start'] = 50;
|
|
|
$add = $user->allowField(true)->save($data);
|
|
|
$uid = $user->id;
|
|
|
if($add){
|
|
|
$startAdd['detail'] = '注册获得';
|
|
|
$startAdd['star'] = 50;
|
...
|
...
|
@@ -176,13 +189,16 @@ class UserController extends CommonController |
|
|
$startAdd['update_time'] = time();
|
|
|
$star = Db::name('StartDetail')->insertGetId($startAdd);
|
|
|
if($star){
|
|
|
$this->apiResponse('1','注册成功',$data['token']);
|
|
|
Db::commit();
|
|
|
$final['token'] = $data['token'];
|
|
|
$final['uid'] = $uid;
|
|
|
$this->apiResponse('1','注册成功',$final);
|
|
|
}else{
|
|
|
|
|
|
Db::rollback();
|
|
|
$this->apiResponse('0','注册失败');
|
|
|
}
|
|
|
|
|
|
|
|
|
}else{
|
|
|
Db::rollback();
|
|
|
$this->apiResponse('0','注册失败');
|
|
|
}
|
|
|
|
...
|
...
|
@@ -191,6 +207,7 @@ class UserController extends CommonController |
|
|
$where_pro['status'] = 1;
|
|
|
$where_pro['type'] = 1;
|
|
|
$list = Db::name('Protocol')->where($where_pro)->order("update_time desc")->field("title,content")->find();
|
|
|
$list['content'] = htmlspecialchars_decode($list['content']);
|
|
|
// 推荐人(未完)
|
|
|
|
|
|
|
...
|
...
|
@@ -204,7 +221,7 @@ class UserController extends CommonController |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 用户登录
|
|
|
* @title 用户登录(sure)
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/login
|
...
|
...
|
@@ -224,12 +241,12 @@ class UserController extends CommonController |
|
|
$tel = $request->param('tel');
|
|
|
$password = $request->param('password');
|
|
|
$true = $request->param('imgCode');
|
|
|
$token = $request->param('token');
|
|
|
if(empty($tel)){
|
|
|
$this->apiResponse('0','手机号不能为空');
|
|
|
}else if(empty($password)){
|
|
|
$this->apiResponse('0','密码不能为空');
|
|
|
}else if(empty($true)){
|
|
|
}else
|
|
|
if(empty($true)){
|
|
|
$this->apiResponse('0','验证码不能为空');
|
|
|
}
|
|
|
// 验证
|
...
|
...
|
@@ -240,17 +257,27 @@ class UserController extends CommonController |
|
|
$this->apiResponse('0','验证码错误');
|
|
|
}
|
|
|
// 手机、密码
|
|
|
// $member_model = new MemberModel();
|
|
|
$memberModel = new MemberModel();
|
|
|
$where_member['tel'] = $tel;
|
|
|
$where_member['password'] = $this->md5($password);
|
|
|
$token_str = rand(1000,9999).time().rand(100,999);
|
|
|
$update_member['token'] = $this->md5($token_str);
|
|
|
$update_member['update_time'] = time();
|
|
|
$member = Db::name('Member')->where($where_member)->update($update_member);
|
|
|
if($member){
|
|
|
$this->apiResponse('1','登录成功',$member);
|
|
|
}else{
|
|
|
$this->apiResponse('0','您输入的账号或密码不正确');
|
|
|
$uid = Db::name('Member')->where($where_member)->field('id,token,type')->find();
|
|
|
if($uid){
|
|
|
// 登录重置token
|
|
|
$token_str = rand(1000,9999).time().rand(100,999);
|
|
|
$update_member['id'] = $uid['id'];
|
|
|
$update_member['token'] = $this->md5($token_str);
|
|
|
// $update_member['update_time'] = time();
|
|
|
$member = $memberModel->isUpdate(true)->save($update_member);
|
|
|
if($member){
|
|
|
session('uid',$uid['id']);
|
|
|
session('token',$uid['token']);
|
|
|
$final['token'] = $uid['token'];
|
|
|
$final['uid'] = $uid['id'];
|
|
|
$final['type'] = $uid['type'];
|
|
|
$this->apiResponse('1','登录成功',$final);
|
|
|
}else{
|
|
|
$this->apiResponse('0','您输入的账号或密码不正确');
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
|
// 返回验证码图片
|
...
|
...
|
@@ -296,6 +323,80 @@ class UserController extends CommonController |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 用户修改手机号(第一步)(sure)
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/changetTel
|
|
|
* @method POST
|
|
|
* @param name:Password type:int require:1 default: other: desc:登录密码
|
|
|
* @param name:token type:int require:1 default: other: desc:token
|
|
|
*/
|
|
|
public function changetTel(){
|
|
|
$data = $this->request->param();
|
|
|
$user = $this->myleft($data['token']);
|
|
|
if(!empty($data['password'])){
|
|
|
$userModel = new MemberModel();
|
|
|
$where_change['status'] = 1;
|
|
|
$where_change['token'] = $data['token'];
|
|
|
$where_change['password'] = $this->md5($data['password']);
|
|
|
$findChange = $userModel->where($where_change)->find();
|
|
|
if($findChange){
|
|
|
$this->apiResponse('1','验证成功');
|
|
|
}else{
|
|
|
$this->apiResponse('0','验证失败');
|
|
|
}
|
|
|
}else{
|
|
|
$final['user'] = $user;
|
|
|
$this->apiResponse('1','成功',$final);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 用户修改手机号(第二步)
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/changetTelNext
|
|
|
* @method POST
|
|
|
* @param name:newTel type:int require:1 default: other: desc:新手机号
|
|
|
* @param name:code type:int require:1 default: other: desc:验证码
|
|
|
* @param name:token type:int require:1 default: other: desc:token
|
|
|
*/
|
|
|
public function changetTelNext(){
|
|
|
$data = $this->request->param();
|
|
|
$user = $this->myleft($data['token']);
|
|
|
if(!empty($data['newTel'])){
|
|
|
if(empty($data['code'])){
|
|
|
$this->apiResponse('0','验证码不能为空');
|
|
|
}
|
|
|
$codeModel = new CodeModel();
|
|
|
$where_code['status'] = 1;
|
|
|
$where_code['type'] = 4;
|
|
|
$where_code['tel'] = $data['newTel'];
|
|
|
$findCode = $codeModel->where($where_code)->find();
|
|
|
if($findCode['code'] != $data['code']){
|
|
|
$this->apiResponse('0','验证码错误');
|
|
|
}
|
|
|
$userModel = new MemberModel();
|
|
|
// $change['token'] = $data['token'];
|
|
|
$change['id'] = $user['id'];
|
|
|
$change['tel'] = $data['newTel'];
|
|
|
$findChange = $userModel->isUpdate(true)->save($change);
|
|
|
if($findChange){
|
|
|
$this->apiResponse('1','修改成功');
|
|
|
}else{
|
|
|
$this->apiResponse('0','修改失败');
|
|
|
}
|
|
|
}else{
|
|
|
$final['user'] = $user;
|
|
|
$this->apiResponse('1','成功',$final);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 用户修改密码
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
...
|
...
|
@@ -600,25 +701,23 @@ class UserController extends CommonController |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 我的资料
|
|
|
* @title 我的资料(sure)
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/myMes
|
|
|
* @method POST
|
|
|
* @param name:token type:int require:1 default: other: desc:token
|
|
|
* @param name:need_id type:int require:1 default: other: desc:需求id
|
|
|
* @param name:agency_id type:int require:1 default: other: desc:中介报价id
|
|
|
* @return data:''@
|
|
|
*/
|
|
|
public function myMes(Request $request){
|
|
|
$data = $request->param();
|
|
|
$user = $this->myleft($data['token']);
|
|
|
// $where_member['status'] = 1;
|
|
|
// $where_member['id'] = $user['id'];
|
|
|
// $member = Db::name('Member')->where($where_member)->field('referee_tel')->find();
|
|
|
$where_card['status'] = 1;
|
|
|
$where_card['user_id'] = $user['id'];
|
|
|
$card = Db::name('Card')->where($where_card)->field('referee_tel')->find();
|
|
|
$card = Db::name('Card')->where($where_card)->field('id,card_name,card_num')->select()->toArray();
|
|
|
foreach ($card as $cardk=>$cardv){
|
|
|
$card[$cardk]['user_name'] = $user['name'];
|
|
|
}
|
|
|
$final['card'] = $card;
|
|
|
$final['user'] = $user;
|
|
|
if($card){
|
...
|
...
|
|