123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- <?php
- namespace app\api\controller;
- use app\common\model\Config;
- use app\common\model\User;
- use app\common\controller\Api;
- use think\Db;
- use think\facade\Validate;
- /**
- * @title 登录注册
- * @controller Login
- * @group user
- */
- class Login extends Api
- {
- /**
- * @title 注册
- * @desc 注册
- * @url /api/Login/register
- * @method POST
- * @tag 基础
- * @header
- * @param name:phone type:string require:1 desc:手机号
- * @param name:password type:string require:1 desc:密码
- * @param name:ver_code type:string require:1 desc:验证码
- * @param name:invite_code type:string require:0 desc:邀请码
- */
- public function register(){
- $phone = input('phone'); //手机号
- $password = input('password'); //密码
- $ver_code = input('ver_code'); //验证码
- $invite_code = input('invite_code'); //邀请码
- if (!$phone || !$password){
- $this->error('参数错误');
- }
- if (!Validate::regex($phone, "^1\d{10}$")) {
- $this->error('手机号格式错误');
- }
- $us = User::register($phone,$password,$ver_code,$invite_code);
- if ($us['code']){
- $this->success($us['msg'],$us['data']);
- }else{
- $this->error($us['msg']);
- }
- }
- /**
- * @title 登录
- * @desc 登录
- * @url /api/Login/login
- * @method POST
- * @tag 基础
- * @header
- * @param name:phone type:string require:1 desc:手机号
- * @param name:type type:string require:1 desc:1:密码登录2:验证码登录
- * @param name:password type:string require:0 desc:密码(密码登录时传)
- * @param name:ver_code type:string require:0 desc:验证码(验证码登录时传)
- * @param name:come type:int require:0 desc:1:用户端2:设计师端(默认为1)
- *
- *
- * @return name:token type:string desc:token
- * @return name:type type:int desc:1:未申请2:待审核3:审核失败4:登录成功
- */
- public function login(){
- $phone = input('phone'); //手机号
- $type = input('type',1); //1:密码登录 2:验证码登录
- $password = input('password'); //密码
- $ver_code = input('ver_code'); //验证码
- $come = input('come',1); //1:用户端2:设计师端(默认为1)
- if (!$phone || !Validate::regex($phone, "^1\d{10}$")) {
- $this->error('手机号格式错误');
- }
- if (!in_array($type,['1','2'])){
- $this->error('非法操作');
- }
- if ($type==1){
- if (!$password){
- $this->error('密码为空');
- }
- }elseif ($type==2){
- if (!$ver_code){
- $this->error('短信验证码为空');
- }
- }
- $result = User::login($phone,$password,$type,$ver_code,$come);
- if ($result['code']){
- $this->success($result['msg'],$result['data']);
- }else{
- $this->error($result['msg']);
- }
- }
- /**
- * @title 忘记密码
- * @desc 忘记密码
- * @url /api/Login/forgot_password
- * @method POST
- * @tag 基础
- * @header
- * @param name:phone type:string require:1 desc:手机号
- * @param name:password type:string require:0 desc:密码
- * @param name:ver_code type:string require:0 desc:验证码
- *
- */
- public function forgot_password(){
- $phone = input('phone'); //手机号
- $password = input('password'); //密码
- $ver_code = input('ver_code'); //验证码
- if (!$phone || !$password){
- $this->error('参数错误');
- }
- if (!$phone || !Validate::regex($phone, "^1\d{10}$")) {
- $this->error('手机号格式错误');
- }
- $result = User::forgotPassword($phone,$password,$ver_code);
- if ($result['code']){
- $this->success($result['msg'],$result['data']);
- }else{
- $this->error($result['msg']);
- }
- }
- /**
- * @title 微信授权登录
- * @desc 微信授权登录
- * @url /api/Login/wechat_login
- * @method POST
- * @tag 基础
- * @header
- * @param name:code type:string require:1 desc:微信code
- *
- */
- public function wechat_login(){
- $code = input('code');
- if (!$code) $this->error('code为空');
- $result = User::wechatLogin($code);
- if ($result['code']){
- $this->success($result['msg'],$result['data']);
- }else{
- $this->error($result['msg']);
- }
- }
- /**
- * @title 微信授权绑定手机号信息
- * @desc 微信授权绑定手机号信息
- * @url /api/Login/wechat_login_bind_phone
- * @method POST
- * @tag 基础
- * @header
- * @param name:code type:string require:1 desc:微信code
- * @param name:rawData type:string require:1 desc:用户信息
- * @param name:phone type:string require:1 desc:手机号
- * @param name:ver_code type:string require:1 desc:验证码
- * @param name:password type:string require:1 desc:密码
- *
- */
- public function wechat_login_bind_phone(){
- $code = input('code');
- if (!$code) $this->error('code为空');
- $rawData = input('rawData'); //用户信息
- $phone = input('phone'); //手机号
- $ver_code = input('ver_code'); //验证码
- $password = input('password'); //密码
- if (!$phone || !Validate::regex($phone, "^1\d{10}$")) {
- $this->error('手机号格式错误');
- }
- if (!$ver_code){
- $this->error('短信验证码为空');
- }
- if (!$password){
- $this->error('密码为空');
- }
- $result = User::wechatLoginBindPhone($code,$rawData,$phone,$ver_code,$password);
- if ($result['code']){
- $this->success($result['msg'],$result['data']);
- }else{
- $this->error($result['msg']);
- }
- }
- /**
- * @title 设计师注册
- * @desc 设计师注册
- * @url /api/Login/designer_register
- * @method POST
- * @tag 基础
- * @header
- * @param name:type type:int require:1 desc:1:第一页验证手机号、验证码2:填写设计师信息
- * @param name:phone type:string require:1 desc:手机号
- * @param name:ver_code type:string require:1 desc:验证码
- * @param name:password type:string require:1 desc:密码
- *
- * @param name:name type:string require:1 desc:姓名
- * @param name:design_classifi type:string require:1 desc:设计分类
- * @param name:skills_label type:string require:1 desc:技能标签
- * @param name:good_type type:string require:1 desc:擅长类型
- * @param name:province type:string require:1 desc:省
- * @param name:city type:string require:1 desc:市
- * @param name:area type:string require:1 desc:区
- * @param name:work_year type:string require:1 desc:工作年限
- * @param name:identity_card_zheng type:string require:1 desc:身份证正面
- * @param name:identity_card_fan type:string require:1 desc:身份证反面
- * @param name:related_certificate type:string require:1 desc:相关证书,数组
- * @param name:works type:string require:1 desc:作品,数组
- * @param name:wd type:string require:1 desc:当前位置纬度
- * @param name:jd type:string require:1 desc:当前位置经度
- *
- *
- *
- *
- * @return name:type type:int desc:1:手机号未注册2:手机号已注册,未申请成为设计师或者正在审核中
- */
- public function designer_register(){
- $phone = input('phone'); //手机号
- $password = input('password'); //密码
- $ver_code = input('ver_code'); //验证码
- $type = input('type'); //1:第一页验证手机号、验证码 2:填写商家信息
- if (!$phone || !Validate::regex($phone, "^1\d{10}$")) {
- $this->error('手机号格式错误');
- }
- if (!in_array($type,['1','2'])){
- $this->error('非法操作');
- }
- if ($type==1){
- if (!$phone || !$password || !$password){
- $this->error('参数错误');
- }
- $result = User::designer_register_one($phone,$ver_code);
- }else{
- $data['phone'] = $phone;
- $data['name'] = input('name'); //姓名
- $data['design_classifi'] = input('design_classifi'); //设计分类
- $data['skills_label'] = input('skills_label'); //技能标签
- $data['good_type'] = input('good_type'); //擅长类型
- $data['province'] = input('province'); //省
- $data['city'] = input('city'); //市
- $data['area'] = input('area'); //区
- $data['work_year'] = input('work_year'); //工作年限
- $data['identity_card_zheng'] = input('identity_card_zheng'); //身份证正面
- $data['identity_card_fan'] = input('identity_card_fan'); //身份证反面
- $data['related_certificate'] = input('related_certificate'); //相关证书
- $data['works'] = input('works'); //作品
- $data['wd'] = input('wd'); //当前位置纬度
- $data['jd'] = input('jd'); //当前位置经度
- if (!$data['name'] || !$data['design_classifi'] || !$data['design_classifi'] || !$data['skills_label'] || !$data['good_type'] || !$data['identity_card_zheng'] || !$data['identity_card_fan'] || !$data['province']
- || !$data['city'] || !$data['area'] || !$data['work_year'] || !$data['works']){
- $this->error('参数错误');
- }
- $data['related_certificate'] = implode(',',$data['related_certificate']);
- $data['works'] = implode(',',$data['works']);
- $data['skills_label'] = implode(',',$data['skills_label']);
- $data['good_type'] = implode(',',$data['good_type']);
- $result = User::designer_register_two($data);
- }
- if ($result['code']){
- $this->success($result['msg'],$result['data']);
- }else{
- $this->error($result['msg']);
- }
- }
- }
|